stream-chat 8.41.0 → 8.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.es.js +1729 -804
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +1730 -800
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +1729 -804
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1730 -800
- package/dist/index.js.map +1 -1
- package/dist/types/channel.d.ts +1 -1
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +1 -5
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +27 -15
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/index.d.ts +8 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/poll.d.ts +64 -0
- package/dist/types/poll.d.ts.map +1 -0
- package/dist/types/poll_manager.d.ts +31 -0
- package/dist/types/poll_manager.d.ts.map +1 -0
- package/dist/types/store.d.ts +2 -1
- package/dist/types/store.d.ts.map +1 -1
- package/dist/types/thread.d.ts.map +1 -1
- package/dist/types/types.d.ts +33 -20
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/channel.ts +2 -25
- package/src/channel_state.ts +0 -92
- package/src/client.ts +112 -70
- package/src/index.ts +8 -6
- package/src/poll.ts +414 -0
- package/src/poll_manager.ts +162 -0
- package/src/store.ts +22 -2
- package/src/thread.ts +7 -4
- package/src/thread_manager.ts +5 -5
- package/src/types.ts +60 -36
package/dist/index.es.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { fromByteArray } from 'base64-js';
|
|
2
|
-
import _extends from '@babel/runtime/helpers/extends';
|
|
3
|
-
import _typeof from '@babel/runtime/helpers/typeof';
|
|
4
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
6
2
|
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
7
3
|
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
8
4
|
import _createClass from '@babel/runtime/helpers/createClass';
|
|
9
5
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
10
6
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
7
|
+
import _extends from '@babel/runtime/helpers/extends';
|
|
8
|
+
import _typeof from '@babel/runtime/helpers/typeof';
|
|
9
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
10
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
11
11
|
import axios from 'axios';
|
|
12
12
|
import https from 'https';
|
|
13
13
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
@@ -94,15 +94,220 @@ var decodeBase64 = function decodeBase64(s) {
|
|
|
94
94
|
return r;
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
var Campaign = /*#__PURE__*/function () {
|
|
98
|
+
function Campaign(client, id, data) {
|
|
99
|
+
_classCallCheck(this, Campaign);
|
|
98
100
|
|
|
99
|
-
|
|
101
|
+
_defineProperty(this, "id", void 0);
|
|
100
102
|
|
|
101
|
-
|
|
103
|
+
_defineProperty(this, "data", void 0);
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
_defineProperty(this, "client", void 0);
|
|
104
106
|
|
|
105
|
-
|
|
107
|
+
this.client = client;
|
|
108
|
+
this.id = id;
|
|
109
|
+
this.data = data;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
_createClass(Campaign, [{
|
|
113
|
+
key: "create",
|
|
114
|
+
value: function () {
|
|
115
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
116
|
+
var _this$data, _this$data2, _this$data3, _this$data4, _this$data5, _this$data6, _this$data7, _this$data8;
|
|
117
|
+
|
|
118
|
+
var body, result;
|
|
119
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
120
|
+
while (1) {
|
|
121
|
+
switch (_context.prev = _context.next) {
|
|
122
|
+
case 0:
|
|
123
|
+
body = {
|
|
124
|
+
id: this.id,
|
|
125
|
+
message_template: (_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.message_template,
|
|
126
|
+
segment_ids: (_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2.segment_ids,
|
|
127
|
+
sender_id: (_this$data3 = this.data) === null || _this$data3 === void 0 ? void 0 : _this$data3.sender_id,
|
|
128
|
+
channel_template: (_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : _this$data4.channel_template,
|
|
129
|
+
create_channels: (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5.create_channels,
|
|
130
|
+
description: (_this$data6 = this.data) === null || _this$data6 === void 0 ? void 0 : _this$data6.description,
|
|
131
|
+
name: (_this$data7 = this.data) === null || _this$data7 === void 0 ? void 0 : _this$data7.name,
|
|
132
|
+
user_ids: (_this$data8 = this.data) === null || _this$data8 === void 0 ? void 0 : _this$data8.user_ids
|
|
133
|
+
};
|
|
134
|
+
_context.next = 3;
|
|
135
|
+
return this.client.createCampaign(body);
|
|
136
|
+
|
|
137
|
+
case 3:
|
|
138
|
+
result = _context.sent;
|
|
139
|
+
this.id = result.campaign.id;
|
|
140
|
+
this.data = result.campaign;
|
|
141
|
+
return _context.abrupt("return", result);
|
|
142
|
+
|
|
143
|
+
case 7:
|
|
144
|
+
case "end":
|
|
145
|
+
return _context.stop();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}, _callee, this);
|
|
149
|
+
}));
|
|
150
|
+
|
|
151
|
+
function create() {
|
|
152
|
+
return _create.apply(this, arguments);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return create;
|
|
156
|
+
}()
|
|
157
|
+
}, {
|
|
158
|
+
key: "verifyCampaignId",
|
|
159
|
+
value: function verifyCampaignId() {
|
|
160
|
+
if (!this.id) {
|
|
161
|
+
throw new Error('Campaign id is missing. Either create the campaign using campaign.create() or set the id during instantiation - const campaign = client.campaign(id)');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}, {
|
|
165
|
+
key: "start",
|
|
166
|
+
value: function () {
|
|
167
|
+
var _start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
|
|
168
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
169
|
+
while (1) {
|
|
170
|
+
switch (_context2.prev = _context2.next) {
|
|
171
|
+
case 0:
|
|
172
|
+
this.verifyCampaignId();
|
|
173
|
+
_context2.next = 3;
|
|
174
|
+
return this.client.startCampaign(this.id, options);
|
|
175
|
+
|
|
176
|
+
case 3:
|
|
177
|
+
return _context2.abrupt("return", _context2.sent);
|
|
178
|
+
|
|
179
|
+
case 4:
|
|
180
|
+
case "end":
|
|
181
|
+
return _context2.stop();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}, _callee2, this);
|
|
185
|
+
}));
|
|
186
|
+
|
|
187
|
+
function start(_x) {
|
|
188
|
+
return _start.apply(this, arguments);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return start;
|
|
192
|
+
}()
|
|
193
|
+
}, {
|
|
194
|
+
key: "update",
|
|
195
|
+
value: function () {
|
|
196
|
+
var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
|
|
197
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
198
|
+
while (1) {
|
|
199
|
+
switch (_context3.prev = _context3.next) {
|
|
200
|
+
case 0:
|
|
201
|
+
this.verifyCampaignId();
|
|
202
|
+
return _context3.abrupt("return", this.client.updateCampaign(this.id, data));
|
|
203
|
+
|
|
204
|
+
case 2:
|
|
205
|
+
case "end":
|
|
206
|
+
return _context3.stop();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}, _callee3, this);
|
|
210
|
+
}));
|
|
211
|
+
|
|
212
|
+
function update(_x2) {
|
|
213
|
+
return _update.apply(this, arguments);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return update;
|
|
217
|
+
}()
|
|
218
|
+
}, {
|
|
219
|
+
key: "delete",
|
|
220
|
+
value: function () {
|
|
221
|
+
var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
222
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
223
|
+
while (1) {
|
|
224
|
+
switch (_context4.prev = _context4.next) {
|
|
225
|
+
case 0:
|
|
226
|
+
this.verifyCampaignId();
|
|
227
|
+
_context4.next = 3;
|
|
228
|
+
return this.client.deleteCampaign(this.id);
|
|
229
|
+
|
|
230
|
+
case 3:
|
|
231
|
+
return _context4.abrupt("return", _context4.sent);
|
|
232
|
+
|
|
233
|
+
case 4:
|
|
234
|
+
case "end":
|
|
235
|
+
return _context4.stop();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}, _callee4, this);
|
|
239
|
+
}));
|
|
240
|
+
|
|
241
|
+
function _delete() {
|
|
242
|
+
return _delete2.apply(this, arguments);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return _delete;
|
|
246
|
+
}()
|
|
247
|
+
}, {
|
|
248
|
+
key: "stop",
|
|
249
|
+
value: function () {
|
|
250
|
+
var _stop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
251
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
252
|
+
while (1) {
|
|
253
|
+
switch (_context5.prev = _context5.next) {
|
|
254
|
+
case 0:
|
|
255
|
+
this.verifyCampaignId();
|
|
256
|
+
return _context5.abrupt("return", this.client.stopCampaign(this.id));
|
|
257
|
+
|
|
258
|
+
case 2:
|
|
259
|
+
case "end":
|
|
260
|
+
return _context5.stop();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}, _callee5, this);
|
|
264
|
+
}));
|
|
265
|
+
|
|
266
|
+
function stop() {
|
|
267
|
+
return _stop.apply(this, arguments);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return stop;
|
|
271
|
+
}()
|
|
272
|
+
}, {
|
|
273
|
+
key: "get",
|
|
274
|
+
value: function () {
|
|
275
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
276
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
277
|
+
while (1) {
|
|
278
|
+
switch (_context6.prev = _context6.next) {
|
|
279
|
+
case 0:
|
|
280
|
+
this.verifyCampaignId();
|
|
281
|
+
return _context6.abrupt("return", this.client.getCampaign(this.id));
|
|
282
|
+
|
|
283
|
+
case 2:
|
|
284
|
+
case "end":
|
|
285
|
+
return _context6.stop();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}, _callee6, this);
|
|
289
|
+
}));
|
|
290
|
+
|
|
291
|
+
function get() {
|
|
292
|
+
return _get.apply(this, arguments);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return get;
|
|
296
|
+
}()
|
|
297
|
+
}]);
|
|
298
|
+
|
|
299
|
+
return Campaign;
|
|
300
|
+
}();
|
|
301
|
+
|
|
302
|
+
function ownKeys$c(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
303
|
+
|
|
304
|
+
function _objectSpread$c(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$c(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$c(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
305
|
+
|
|
306
|
+
function _createForOfIteratorHelper$5(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function (_e) { function e(_x) { return _e.apply(this, arguments); } e.toString = function () { return _e.toString(); }; return e; }(function (e) { throw e; }), f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function (_e2) { function e(_x2) { return _e2.apply(this, arguments); } e.toString = function () { return _e2.toString(); }; return e; }(function (e) { didErr = true; err = e; }), f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
307
|
+
|
|
308
|
+
function _unsupportedIterableToArray$5(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$5(o, minLen); }
|
|
309
|
+
|
|
310
|
+
function _arrayLikeToArray$5(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
106
311
|
|
|
107
312
|
/**
|
|
108
313
|
* logChatPromiseExecution - utility function for logging the execution of a promise..
|
|
@@ -187,7 +392,7 @@ function normalizeQuerySort(sort) {
|
|
|
187
392
|
var sortFields = [];
|
|
188
393
|
var sortArr = Array.isArray(sort) ? sort : [sort];
|
|
189
394
|
|
|
190
|
-
var _iterator = _createForOfIteratorHelper$
|
|
395
|
+
var _iterator = _createForOfIteratorHelper$5(sortArr),
|
|
191
396
|
_step;
|
|
192
397
|
|
|
193
398
|
try {
|
|
@@ -357,7 +562,7 @@ var axiosParamsSerializer = function axiosParamsSerializer(params) {
|
|
|
357
562
|
*/
|
|
358
563
|
|
|
359
564
|
function formatMessage(message) {
|
|
360
|
-
return _objectSpread$
|
|
565
|
+
return _objectSpread$c(_objectSpread$c({}, message), {}, {
|
|
361
566
|
/**
|
|
362
567
|
* @deprecated please use `html`
|
|
363
568
|
*/
|
|
@@ -562,7 +767,7 @@ var messagePaginationCreatedAtAround = function messagePaginationCreatedAtAround
|
|
|
562
767
|
returnedPage = _ref3.returnedPage,
|
|
563
768
|
messagePaginationOptions = _ref3.messagePaginationOptions;
|
|
564
769
|
|
|
565
|
-
var newPagination = _objectSpread$
|
|
770
|
+
var newPagination = _objectSpread$c({}, parentSet.pagination);
|
|
566
771
|
|
|
567
772
|
if (!(messagePaginationOptions !== null && messagePaginationOptions !== void 0 && messagePaginationOptions.created_at_around)) return newPagination;
|
|
568
773
|
var hasPrev;
|
|
@@ -627,7 +832,7 @@ var messagePaginationIdAround = function messagePaginationIdAround(_ref5) {
|
|
|
627
832
|
returnedPage = _ref5.returnedPage,
|
|
628
833
|
messagePaginationOptions = _ref5.messagePaginationOptions;
|
|
629
834
|
|
|
630
|
-
var newPagination = _objectSpread$
|
|
835
|
+
var newPagination = _objectSpread$c({}, parentSet.pagination);
|
|
631
836
|
|
|
632
837
|
var _ref6 = messagePaginationOptions || {},
|
|
633
838
|
id_around = _ref6.id_around;
|
|
@@ -685,7 +890,7 @@ var messagePaginationLinear = function messagePaginationLinear(_ref8) {
|
|
|
685
890
|
returnedPage = _ref8.returnedPage,
|
|
686
891
|
messagePaginationOptions = _ref8.messagePaginationOptions;
|
|
687
892
|
|
|
688
|
-
var newPagination = _objectSpread$
|
|
893
|
+
var newPagination = _objectSpread$c({}, parentSet.pagination);
|
|
689
894
|
|
|
690
895
|
var hasPrev;
|
|
691
896
|
var hasNext;
|
|
@@ -739,9 +944,9 @@ var DEFAULT_MESSAGE_SET_PAGINATION = {
|
|
|
739
944
|
hasPrev: true
|
|
740
945
|
};
|
|
741
946
|
|
|
742
|
-
function ownKeys$
|
|
947
|
+
function ownKeys$b(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
743
948
|
|
|
744
|
-
function _objectSpread$
|
|
949
|
+
function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$b(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
745
950
|
|
|
746
951
|
/**
|
|
747
952
|
* ChannelState - A container class for the channel state.
|
|
@@ -814,153 +1019,42 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
814
1019
|
};
|
|
815
1020
|
});
|
|
816
1021
|
|
|
817
|
-
_defineProperty(this, "
|
|
818
|
-
var
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
if (!message) return;
|
|
823
|
-
if (message.poll_id !== pollVote.poll_id) return;
|
|
824
|
-
|
|
825
|
-
var updatedPoll = _objectSpread$a({}, poll);
|
|
1022
|
+
_defineProperty(this, "updateUserMessages", function (user) {
|
|
1023
|
+
var _updateUserMessages = function _updateUserMessages(messages, user) {
|
|
1024
|
+
for (var i = 0; i < messages.length; i++) {
|
|
1025
|
+
var _m$user;
|
|
826
1026
|
|
|
827
|
-
|
|
1027
|
+
var m = messages[i];
|
|
828
1028
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
});
|
|
835
|
-
} else if (pollVote.answer_text) {
|
|
836
|
-
// remove all previous votes where option_id is empty
|
|
837
|
-
ownVotes = ownVotes.filter(function (vote) {
|
|
838
|
-
return vote.answer_text;
|
|
839
|
-
});
|
|
1029
|
+
if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
|
|
1030
|
+
messages[i] = _objectSpread$b(_objectSpread$b({}, m), {}, {
|
|
1031
|
+
user: user
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
840
1034
|
}
|
|
1035
|
+
};
|
|
841
1036
|
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
updatedPoll.own_votes = ownVotes;
|
|
846
|
-
|
|
847
|
-
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
848
|
-
poll: updatedPoll
|
|
1037
|
+
_this.messageSets.forEach(function (set) {
|
|
1038
|
+
return _updateUserMessages(set.messages, user);
|
|
849
1039
|
});
|
|
850
1040
|
|
|
851
|
-
|
|
852
|
-
|
|
1041
|
+
for (var parentId in _this.threads) {
|
|
1042
|
+
_updateUserMessages(_this.threads[parentId], user);
|
|
1043
|
+
}
|
|
853
1044
|
|
|
854
|
-
|
|
855
|
-
|
|
1045
|
+
_updateUserMessages(_this.pinnedMessages, user);
|
|
1046
|
+
});
|
|
856
1047
|
|
|
857
|
-
|
|
1048
|
+
_defineProperty(this, "deleteUserMessages", function (user) {
|
|
1049
|
+
var hardDelete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
858
1050
|
|
|
859
|
-
|
|
860
|
-
|
|
1051
|
+
var _deleteUserMessages = function _deleteUserMessages(messages, user) {
|
|
1052
|
+
var hardDelete = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
861
1053
|
|
|
862
|
-
|
|
1054
|
+
for (var i = 0; i < messages.length; i++) {
|
|
1055
|
+
var _m$user2;
|
|
863
1056
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
if (pollVote.user_id === _this._channel.getClient().userID) {
|
|
867
|
-
ownVotes.push(pollVote);
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
updatedPoll.own_votes = ownVotes;
|
|
871
|
-
|
|
872
|
-
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
873
|
-
poll: updatedPoll
|
|
874
|
-
});
|
|
875
|
-
|
|
876
|
-
_this.addMessageSorted(newMessage, false, false);
|
|
877
|
-
});
|
|
878
|
-
|
|
879
|
-
_defineProperty(this, "removePollVote", function (pollVote, poll, messageId) {
|
|
880
|
-
var _message$poll3;
|
|
881
|
-
|
|
882
|
-
var message = _this.findMessage(messageId);
|
|
883
|
-
|
|
884
|
-
if (!message) return;
|
|
885
|
-
if (message.poll_id !== pollVote.poll_id) return;
|
|
886
|
-
|
|
887
|
-
var updatedPoll = _objectSpread$a({}, poll);
|
|
888
|
-
|
|
889
|
-
var ownVotes = _toConsumableArray(((_message$poll3 = message.poll) === null || _message$poll3 === void 0 ? void 0 : _message$poll3.own_votes) || []);
|
|
890
|
-
|
|
891
|
-
if (pollVote.user_id === _this._channel.getClient().userID) {
|
|
892
|
-
var index = ownVotes.findIndex(function (vote) {
|
|
893
|
-
return vote.option_id === pollVote.option_id;
|
|
894
|
-
});
|
|
895
|
-
|
|
896
|
-
if (index > -1) {
|
|
897
|
-
ownVotes.splice(index, 1);
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
updatedPoll.own_votes = ownVotes;
|
|
902
|
-
|
|
903
|
-
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
904
|
-
poll: updatedPoll
|
|
905
|
-
});
|
|
906
|
-
|
|
907
|
-
_this.addMessageSorted(newMessage, false, false);
|
|
908
|
-
});
|
|
909
|
-
|
|
910
|
-
_defineProperty(this, "updatePoll", function (poll, messageId) {
|
|
911
|
-
var _message$poll4;
|
|
912
|
-
|
|
913
|
-
var message = _this.findMessage(messageId);
|
|
914
|
-
|
|
915
|
-
if (!message) return;
|
|
916
|
-
|
|
917
|
-
var updatedPoll = _objectSpread$a(_objectSpread$a({}, poll), {}, {
|
|
918
|
-
own_votes: _toConsumableArray(((_message$poll4 = message.poll) === null || _message$poll4 === void 0 ? void 0 : _message$poll4.own_votes) || [])
|
|
919
|
-
});
|
|
920
|
-
|
|
921
|
-
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
922
|
-
poll: updatedPoll
|
|
923
|
-
});
|
|
924
|
-
|
|
925
|
-
_this.addMessageSorted(newMessage, false, false);
|
|
926
|
-
});
|
|
927
|
-
|
|
928
|
-
_defineProperty(this, "updateUserMessages", function (user) {
|
|
929
|
-
var _updateUserMessages = function _updateUserMessages(messages, user) {
|
|
930
|
-
for (var i = 0; i < messages.length; i++) {
|
|
931
|
-
var _m$user;
|
|
932
|
-
|
|
933
|
-
var m = messages[i];
|
|
934
|
-
|
|
935
|
-
if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
|
|
936
|
-
messages[i] = _objectSpread$a(_objectSpread$a({}, m), {}, {
|
|
937
|
-
user: user
|
|
938
|
-
});
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
|
|
943
|
-
_this.messageSets.forEach(function (set) {
|
|
944
|
-
return _updateUserMessages(set.messages, user);
|
|
945
|
-
});
|
|
946
|
-
|
|
947
|
-
for (var parentId in _this.threads) {
|
|
948
|
-
_updateUserMessages(_this.threads[parentId], user);
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
_updateUserMessages(_this.pinnedMessages, user);
|
|
952
|
-
});
|
|
953
|
-
|
|
954
|
-
_defineProperty(this, "deleteUserMessages", function (user) {
|
|
955
|
-
var hardDelete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
956
|
-
|
|
957
|
-
var _deleteUserMessages = function _deleteUserMessages(messages, user) {
|
|
958
|
-
var hardDelete = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
959
|
-
|
|
960
|
-
for (var i = 0; i < messages.length; i++) {
|
|
961
|
-
var _m$user2;
|
|
962
|
-
|
|
963
|
-
var m = messages[i];
|
|
1057
|
+
var m = messages[i];
|
|
964
1058
|
|
|
965
1059
|
if (((_m$user2 = m.user) === null || _m$user2 === void 0 ? void 0 : _m$user2.id) !== user.id) {
|
|
966
1060
|
continue;
|
|
@@ -988,7 +1082,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
988
1082
|
user: m.user
|
|
989
1083
|
};
|
|
990
1084
|
} else {
|
|
991
|
-
messages[i] = _objectSpread$
|
|
1085
|
+
messages[i] = _objectSpread$b(_objectSpread$b({}, m), {}, {
|
|
992
1086
|
type: 'deleted',
|
|
993
1087
|
deleted_at: user.deleted_at ? new Date(user.deleted_at) : null
|
|
994
1088
|
});
|
|
@@ -1306,7 +1400,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1306
1400
|
var parseMessage = function parseMessage(m) {
|
|
1307
1401
|
var _m$pinned_at, _m$updated_at;
|
|
1308
1402
|
|
|
1309
|
-
return _objectSpread$
|
|
1403
|
+
return _objectSpread$b(_objectSpread$b({}, m), {}, {
|
|
1310
1404
|
created_at: m.created_at.toISOString(),
|
|
1311
1405
|
pinned_at: (_m$pinned_at = m.pinned_at) === null || _m$pinned_at === void 0 ? void 0 : _m$pinned_at.toISOString(),
|
|
1312
1406
|
updated_at: (_m$updated_at = m.updated_at) === null || _m$updated_at === void 0 ? void 0 : _m$updated_at.toISOString()
|
|
@@ -1316,8 +1410,8 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1316
1410
|
var update = function update(messages) {
|
|
1317
1411
|
var updatedMessages = messages.reduce(function (acc, msg) {
|
|
1318
1412
|
if (msg.quoted_message_id === message.id) {
|
|
1319
|
-
acc.push(_objectSpread$
|
|
1320
|
-
quoted_message: remove ? _objectSpread$
|
|
1413
|
+
acc.push(_objectSpread$b(_objectSpread$b({}, parseMessage(msg)), {}, {
|
|
1414
|
+
quoted_message: remove ? _objectSpread$b(_objectSpread$b({}, message), {}, {
|
|
1321
1415
|
attachments: []
|
|
1322
1416
|
}) : message
|
|
1323
1417
|
}));
|
|
@@ -1800,15 +1894,15 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1800
1894
|
return ChannelState;
|
|
1801
1895
|
}();
|
|
1802
1896
|
|
|
1803
|
-
function _createForOfIteratorHelper$
|
|
1897
|
+
function _createForOfIteratorHelper$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$4(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
1804
1898
|
|
|
1805
|
-
function _unsupportedIterableToArray$
|
|
1899
|
+
function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen); }
|
|
1806
1900
|
|
|
1807
|
-
function _arrayLikeToArray$
|
|
1901
|
+
function _arrayLikeToArray$4(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
1808
1902
|
|
|
1809
|
-
function ownKeys$
|
|
1903
|
+
function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
1810
1904
|
|
|
1811
|
-
function _objectSpread$
|
|
1905
|
+
function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$a(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1812
1906
|
/**
|
|
1813
1907
|
* Channel - The Channel class manages it's own state.
|
|
1814
1908
|
*/
|
|
@@ -1881,7 +1975,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1881
1975
|
while (1) {
|
|
1882
1976
|
switch (_context.prev = _context.next) {
|
|
1883
1977
|
case 0:
|
|
1884
|
-
defaultOptions = _objectSpread$
|
|
1978
|
+
defaultOptions = _objectSpread$a(_objectSpread$a({}, options), {}, {
|
|
1885
1979
|
watch: false,
|
|
1886
1980
|
state: false,
|
|
1887
1981
|
presence: false
|
|
@@ -1953,7 +2047,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1953
2047
|
|
|
1954
2048
|
this.data = data; // this._data is used for the requests...
|
|
1955
2049
|
|
|
1956
|
-
this._data = _objectSpread$
|
|
2050
|
+
this._data = _objectSpread$a({}, data);
|
|
1957
2051
|
this.cid = "".concat(type, ":").concat(id);
|
|
1958
2052
|
this.listeners = {}; // perhaps the state variable should be private
|
|
1959
2053
|
|
|
@@ -2015,7 +2109,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2015
2109
|
switch (_context2.prev = _context2.next) {
|
|
2016
2110
|
case 0:
|
|
2017
2111
|
_context2.next = 2;
|
|
2018
|
-
return this.getClient().post(this._channelURL() + '/message', _objectSpread$
|
|
2112
|
+
return this.getClient().post(this._channelURL() + '/message', _objectSpread$a({
|
|
2019
2113
|
message: message
|
|
2020
2114
|
}, options));
|
|
2021
2115
|
|
|
@@ -2131,7 +2225,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2131
2225
|
|
|
2132
2226
|
case 3:
|
|
2133
2227
|
// Return a list of channels
|
|
2134
|
-
payload = _objectSpread$
|
|
2228
|
+
payload = _objectSpread$a(_objectSpread$a({
|
|
2135
2229
|
filter_conditions: {
|
|
2136
2230
|
cid: this.cid
|
|
2137
2231
|
}
|
|
@@ -2228,7 +2322,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2228
2322
|
|
|
2229
2323
|
_context5.next = 6;
|
|
2230
2324
|
return this.getClient().get(this.getClient().baseURL + '/members', {
|
|
2231
|
-
payload: _objectSpread$
|
|
2325
|
+
payload: _objectSpread$a({
|
|
2232
2326
|
type: type,
|
|
2233
2327
|
id: id,
|
|
2234
2328
|
members: members,
|
|
@@ -2334,7 +2428,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2334
2428
|
|
|
2335
2429
|
case 4:
|
|
2336
2430
|
_context7.next = 6;
|
|
2337
|
-
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(messageID), "/reaction"), _objectSpread$
|
|
2431
|
+
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(messageID), "/reaction"), _objectSpread$a({
|
|
2338
2432
|
reaction: reaction
|
|
2339
2433
|
}, options));
|
|
2340
2434
|
|
|
@@ -2415,7 +2509,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2415
2509
|
delete channelData[key];
|
|
2416
2510
|
});
|
|
2417
2511
|
_context8.next = 7;
|
|
2418
|
-
return this._update(_objectSpread$
|
|
2512
|
+
return this._update(_objectSpread$a({
|
|
2419
2513
|
message: updateMessage,
|
|
2420
2514
|
data: channelData
|
|
2421
2515
|
}, options));
|
|
@@ -2587,7 +2681,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2587
2681
|
case 0:
|
|
2588
2682
|
options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
2589
2683
|
_context12.next = 3;
|
|
2590
|
-
return this.getClient().delete(this._channelURL(), _objectSpread$
|
|
2684
|
+
return this.getClient().delete(this._channelURL(), _objectSpread$a({}, options));
|
|
2591
2685
|
|
|
2592
2686
|
case 3:
|
|
2593
2687
|
return _context12.abrupt("return", _context12.sent);
|
|
@@ -2663,7 +2757,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2663
2757
|
case 0:
|
|
2664
2758
|
options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
2665
2759
|
_context14.next = 3;
|
|
2666
|
-
return this._update(_objectSpread$
|
|
2760
|
+
return this._update(_objectSpread$a({
|
|
2667
2761
|
accept_invite: true
|
|
2668
2762
|
}, options));
|
|
2669
2763
|
|
|
@@ -2704,7 +2798,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2704
2798
|
case 0:
|
|
2705
2799
|
options = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
|
|
2706
2800
|
_context15.next = 3;
|
|
2707
|
-
return this._update(_objectSpread$
|
|
2801
|
+
return this._update(_objectSpread$a({
|
|
2708
2802
|
reject_invite: true
|
|
2709
2803
|
}, options));
|
|
2710
2804
|
|
|
@@ -2746,7 +2840,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2746
2840
|
case 0:
|
|
2747
2841
|
options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
|
|
2748
2842
|
_context16.next = 3;
|
|
2749
|
-
return this._update(_objectSpread$
|
|
2843
|
+
return this._update(_objectSpread$a({
|
|
2750
2844
|
add_members: members,
|
|
2751
2845
|
message: message
|
|
2752
2846
|
}, options));
|
|
@@ -2789,7 +2883,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2789
2883
|
case 0:
|
|
2790
2884
|
options = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
|
|
2791
2885
|
_context17.next = 3;
|
|
2792
|
-
return this._update(_objectSpread$
|
|
2886
|
+
return this._update(_objectSpread$a({
|
|
2793
2887
|
add_moderators: members,
|
|
2794
2888
|
message: message
|
|
2795
2889
|
}, options));
|
|
@@ -2832,7 +2926,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2832
2926
|
case 0:
|
|
2833
2927
|
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
2834
2928
|
_context18.next = 3;
|
|
2835
|
-
return this._update(_objectSpread$
|
|
2929
|
+
return this._update(_objectSpread$a({
|
|
2836
2930
|
assign_roles: roles,
|
|
2837
2931
|
message: message
|
|
2838
2932
|
}, options));
|
|
@@ -2875,7 +2969,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2875
2969
|
case 0:
|
|
2876
2970
|
options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
|
2877
2971
|
_context19.next = 3;
|
|
2878
|
-
return this._update(_objectSpread$
|
|
2972
|
+
return this._update(_objectSpread$a({
|
|
2879
2973
|
invites: members,
|
|
2880
2974
|
message: message
|
|
2881
2975
|
}, options));
|
|
@@ -2918,7 +3012,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2918
3012
|
case 0:
|
|
2919
3013
|
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
|
2920
3014
|
_context20.next = 3;
|
|
2921
|
-
return this._update(_objectSpread$
|
|
3015
|
+
return this._update(_objectSpread$a({
|
|
2922
3016
|
remove_members: members,
|
|
2923
3017
|
message: message
|
|
2924
3018
|
}, options));
|
|
@@ -2961,7 +3055,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2961
3055
|
case 0:
|
|
2962
3056
|
options = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : {};
|
|
2963
3057
|
_context21.next = 3;
|
|
2964
|
-
return this._update(_objectSpread$
|
|
3058
|
+
return this._update(_objectSpread$a({
|
|
2965
3059
|
demote_moderators: members,
|
|
2966
3060
|
message: message
|
|
2967
3061
|
}, options));
|
|
@@ -3046,7 +3140,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3046
3140
|
case 0:
|
|
3047
3141
|
opts = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
|
|
3048
3142
|
_context23.next = 3;
|
|
3049
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$
|
|
3143
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$a({
|
|
3050
3144
|
channel_cid: this.cid
|
|
3051
3145
|
}, opts));
|
|
3052
3146
|
|
|
@@ -3088,7 +3182,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3088
3182
|
case 0:
|
|
3089
3183
|
opts = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {};
|
|
3090
3184
|
_context24.next = 3;
|
|
3091
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$
|
|
3185
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$a({
|
|
3092
3186
|
channel_cid: this.cid
|
|
3093
3187
|
}, opts));
|
|
3094
3188
|
|
|
@@ -3173,7 +3267,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3173
3267
|
|
|
3174
3268
|
this.lastTypingEvent = new Date();
|
|
3175
3269
|
_context25.next = 10;
|
|
3176
|
-
return this.sendEvent(_objectSpread$
|
|
3270
|
+
return this.sendEvent(_objectSpread$a({
|
|
3177
3271
|
type: 'typing.start',
|
|
3178
3272
|
parent_id: parent_id
|
|
3179
3273
|
}, options || {}));
|
|
@@ -3217,7 +3311,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3217
3311
|
this.lastTypingEvent = null;
|
|
3218
3312
|
this.isTyping = false;
|
|
3219
3313
|
_context26.next = 6;
|
|
3220
|
-
return this.sendEvent(_objectSpread$
|
|
3314
|
+
return this.sendEvent(_objectSpread$a({
|
|
3221
3315
|
type: 'typing.stop',
|
|
3222
3316
|
parent_id: parent_id
|
|
3223
3317
|
}, options || {}));
|
|
@@ -3304,7 +3398,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3304
3398
|
|
|
3305
3399
|
case 4:
|
|
3306
3400
|
_context27.next = 6;
|
|
3307
|
-
return this.getClient().post(this._channelURL() + '/read', _objectSpread$
|
|
3401
|
+
return this.getClient().post(this._channelURL() + '/read', _objectSpread$a({}, data));
|
|
3308
3402
|
|
|
3309
3403
|
case 6:
|
|
3310
3404
|
return _context27.abrupt("return", _context27.sent);
|
|
@@ -3351,7 +3445,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3351
3445
|
|
|
3352
3446
|
case 3:
|
|
3353
3447
|
_context28.next = 5;
|
|
3354
|
-
return this.getClient().post(this._channelURL() + '/unread', _objectSpread$
|
|
3448
|
+
return this.getClient().post(this._channelURL() + '/unread', _objectSpread$a({}, data));
|
|
3355
3449
|
|
|
3356
3450
|
case 5:
|
|
3357
3451
|
return _context28.abrupt("return", _context28.sent);
|
|
@@ -3419,7 +3513,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3419
3513
|
defaultOptions.watch = false;
|
|
3420
3514
|
}
|
|
3421
3515
|
|
|
3422
|
-
combined = _objectSpread$
|
|
3516
|
+
combined = _objectSpread$a(_objectSpread$a({}, defaultOptions), options);
|
|
3423
3517
|
_context29.next = 7;
|
|
3424
3518
|
return this.query(combined, 'latest');
|
|
3425
3519
|
|
|
@@ -3513,7 +3607,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3513
3607
|
case 0:
|
|
3514
3608
|
normalizedSort = sort ? normalizeQuerySort(sort) : undefined;
|
|
3515
3609
|
_context31.next = 3;
|
|
3516
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(parent_id), "/replies"), _objectSpread$
|
|
3610
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(parent_id), "/replies"), _objectSpread$a({
|
|
3517
3611
|
sort: normalizedSort
|
|
3518
3612
|
}, options));
|
|
3519
3613
|
|
|
@@ -3563,7 +3657,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3563
3657
|
sort = _args32.length > 1 && _args32[1] !== undefined ? _args32[1] : [];
|
|
3564
3658
|
_context32.next = 3;
|
|
3565
3659
|
return this.getClient().get(this._channelURL() + '/pinned_messages', {
|
|
3566
|
-
payload: _objectSpread$
|
|
3660
|
+
payload: _objectSpread$a(_objectSpread$a({}, options), {}, {
|
|
3567
3661
|
sort: normalizeQuerySort(sort)
|
|
3568
3662
|
})
|
|
3569
3663
|
});
|
|
@@ -3597,7 +3691,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3597
3691
|
}, {
|
|
3598
3692
|
key: "getReactions",
|
|
3599
3693
|
value: function getReactions(message_id, options) {
|
|
3600
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(message_id), "/reactions"), _objectSpread$
|
|
3694
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(message_id), "/reactions"), _objectSpread$a({}, options));
|
|
3601
3695
|
}
|
|
3602
3696
|
/**
|
|
3603
3697
|
* getMessagesById - Retrieves a list of messages by ID
|
|
@@ -3744,7 +3838,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3744
3838
|
}
|
|
3745
3839
|
|
|
3746
3840
|
_context33.next = 7;
|
|
3747
|
-
return this.getClient().post(queryURL + '/query', _objectSpread$
|
|
3841
|
+
return this.getClient().post(queryURL + '/query', _objectSpread$a({
|
|
3748
3842
|
data: this._data,
|
|
3749
3843
|
state: true
|
|
3750
3844
|
}, options));
|
|
@@ -3779,13 +3873,14 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3779
3873
|
|
|
3780
3874
|
|
|
3781
3875
|
_this$_initializeStat = this._initializeState(state, messageSetToAddToIfDoesNotExist), messageSet = _this$_initializeStat.messageSet;
|
|
3782
|
-
messageSet.pagination = _objectSpread$
|
|
3876
|
+
messageSet.pagination = _objectSpread$a(_objectSpread$a({}, messageSet.pagination), messageSetPagination({
|
|
3783
3877
|
parentSet: messageSet,
|
|
3784
3878
|
messagePaginationOptions: options === null || options === void 0 ? void 0 : options.messages,
|
|
3785
3879
|
requestedPageSize: (_options$messages$lim = options === null || options === void 0 ? void 0 : (_options$messages = options.messages) === null || _options$messages === void 0 ? void 0 : _options$messages.limit) !== null && _options$messages$lim !== void 0 ? _options$messages$lim : DEFAULT_QUERY_CHANNEL_MESSAGE_LIST_PAGE_SIZE,
|
|
3786
3880
|
returnedPage: state.messages,
|
|
3787
3881
|
logger: this.getClient().logger
|
|
3788
3882
|
}));
|
|
3883
|
+
this.getClient().polls.hydratePollCache(messageSet.messages, true);
|
|
3789
3884
|
areCapabilitiesChanged = _toConsumableArray(state.channel.own_capabilities || []).sort().join() !== _toConsumableArray(Array.isArray((_this$data6 = this.data) === null || _this$data6 === void 0 ? void 0 : _this$data6.own_capabilities) ? (_this$data7 = this.data) === null || _this$data7 === void 0 ? void 0 : _this$data7.own_capabilities : []).sort().join();
|
|
3790
3885
|
this.data = state.channel;
|
|
3791
3886
|
this.offlineMode = false;
|
|
@@ -3807,7 +3902,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3807
3902
|
});
|
|
3808
3903
|
return _context33.abrupt("return", state);
|
|
3809
3904
|
|
|
3810
|
-
case
|
|
3905
|
+
case 19:
|
|
3811
3906
|
case "end":
|
|
3812
3907
|
return _context33.stop();
|
|
3813
3908
|
}
|
|
@@ -3840,7 +3935,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3840
3935
|
this._checkInitialized();
|
|
3841
3936
|
|
|
3842
3937
|
_context34.next = 3;
|
|
3843
|
-
return this.getClient().banUser(targetUserID, _objectSpread$
|
|
3938
|
+
return this.getClient().banUser(targetUserID, _objectSpread$a(_objectSpread$a({}, options), {}, {
|
|
3844
3939
|
type: this.type,
|
|
3845
3940
|
id: this.id
|
|
3846
3941
|
}));
|
|
@@ -4012,7 +4107,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4012
4107
|
this._checkInitialized();
|
|
4013
4108
|
|
|
4014
4109
|
_context38.next = 3;
|
|
4015
|
-
return this.getClient().shadowBan(targetUserID, _objectSpread$
|
|
4110
|
+
return this.getClient().shadowBan(targetUserID, _objectSpread$a(_objectSpread$a({}, options), {}, {
|
|
4016
4111
|
type: this.type,
|
|
4017
4112
|
id: this.id
|
|
4018
4113
|
}));
|
|
@@ -4466,7 +4561,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4466
4561
|
});
|
|
4467
4562
|
}
|
|
4468
4563
|
|
|
4469
|
-
channel.data = _objectSpread$
|
|
4564
|
+
channel.data = _objectSpread$a(_objectSpread$a({}, event.channel), {}, {
|
|
4470
4565
|
hidden: (_event$channel$hidden = (_event$channel3 = event.channel) === null || _event$channel3 === void 0 ? void 0 : _event$channel3.hidden) !== null && _event$channel$hidden !== void 0 ? _event$channel$hidden : (_channel$data2 = channel.data) === null || _channel$data2 === void 0 ? void 0 : _channel$data2.hidden,
|
|
4471
4566
|
own_capabilities: (_event$channel$own_ca = (_event$channel4 = event.channel) === null || _event$channel4 === void 0 ? void 0 : _event$channel4.own_capabilities) !== null && _event$channel$own_ca !== void 0 ? _event$channel$own_ca : (_channel$data3 = channel.data) === null || _channel$data3 === void 0 ? void 0 : _channel$data3.own_capabilities
|
|
4472
4567
|
});
|
|
@@ -4474,49 +4569,6 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4474
4569
|
|
|
4475
4570
|
break;
|
|
4476
4571
|
|
|
4477
|
-
case 'poll.updated':
|
|
4478
|
-
if (event.poll) {
|
|
4479
|
-
var _event$message;
|
|
4480
|
-
|
|
4481
|
-
channelState.updatePoll(event.poll, ((_event$message = event.message) === null || _event$message === void 0 ? void 0 : _event$message.id) || '');
|
|
4482
|
-
}
|
|
4483
|
-
|
|
4484
|
-
break;
|
|
4485
|
-
|
|
4486
|
-
case 'poll.vote_casted':
|
|
4487
|
-
if (event.poll_vote && event.poll) {
|
|
4488
|
-
var _event$message2;
|
|
4489
|
-
|
|
4490
|
-
channelState.addPollVote(event.poll_vote, event.poll, ((_event$message2 = event.message) === null || _event$message2 === void 0 ? void 0 : _event$message2.id) || '');
|
|
4491
|
-
}
|
|
4492
|
-
|
|
4493
|
-
break;
|
|
4494
|
-
|
|
4495
|
-
case 'poll.vote_changed':
|
|
4496
|
-
if (event.poll_vote && event.poll) {
|
|
4497
|
-
var _event$message3;
|
|
4498
|
-
|
|
4499
|
-
channelState.updatePollVote(event.poll_vote, event.poll, ((_event$message3 = event.message) === null || _event$message3 === void 0 ? void 0 : _event$message3.id) || '');
|
|
4500
|
-
}
|
|
4501
|
-
|
|
4502
|
-
break;
|
|
4503
|
-
|
|
4504
|
-
case 'poll.vote_removed':
|
|
4505
|
-
if (event.poll_vote && event.poll) {
|
|
4506
|
-
var _event$message4;
|
|
4507
|
-
|
|
4508
|
-
channelState.removePollVote(event.poll_vote, event.poll, ((_event$message4 = event.message) === null || _event$message4 === void 0 ? void 0 : _event$message4.id) || '');
|
|
4509
|
-
}
|
|
4510
|
-
|
|
4511
|
-
break;
|
|
4512
|
-
|
|
4513
|
-
case 'poll.closed':
|
|
4514
|
-
if (event.message) {
|
|
4515
|
-
channelState.addMessageSorted(event.message, false, false);
|
|
4516
|
-
}
|
|
4517
|
-
|
|
4518
|
-
break;
|
|
4519
|
-
|
|
4520
4572
|
case 'reaction.new':
|
|
4521
4573
|
if (event.message && event.reaction) {
|
|
4522
4574
|
event.message = channelState.addReaction(event.reaction, event.message);
|
|
@@ -4540,7 +4592,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4540
4592
|
break;
|
|
4541
4593
|
|
|
4542
4594
|
case 'channel.hidden':
|
|
4543
|
-
channel.data = _objectSpread$
|
|
4595
|
+
channel.data = _objectSpread$a(_objectSpread$a({}, channel.data), {}, {
|
|
4544
4596
|
hidden: true
|
|
4545
4597
|
});
|
|
4546
4598
|
|
|
@@ -4551,26 +4603,26 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4551
4603
|
break;
|
|
4552
4604
|
|
|
4553
4605
|
case 'channel.visible':
|
|
4554
|
-
channel.data = _objectSpread$
|
|
4606
|
+
channel.data = _objectSpread$a(_objectSpread$a({}, channel.data), {}, {
|
|
4555
4607
|
hidden: false
|
|
4556
4608
|
});
|
|
4557
4609
|
break;
|
|
4558
4610
|
|
|
4559
4611
|
case 'user.banned':
|
|
4560
4612
|
if (!((_event$user11 = event.user) !== null && _event$user11 !== void 0 && _event$user11.id)) break;
|
|
4561
|
-
channelState.members[event.user.id] = _objectSpread$
|
|
4613
|
+
channelState.members[event.user.id] = _objectSpread$a(_objectSpread$a({}, channelState.members[event.user.id] || {}), {}, {
|
|
4562
4614
|
shadow_banned: !!event.shadow,
|
|
4563
4615
|
banned: !event.shadow,
|
|
4564
|
-
user: _objectSpread$
|
|
4616
|
+
user: _objectSpread$a(_objectSpread$a({}, ((_channelState$members = channelState.members[event.user.id]) === null || _channelState$members === void 0 ? void 0 : _channelState$members.user) || {}), event.user)
|
|
4565
4617
|
});
|
|
4566
4618
|
break;
|
|
4567
4619
|
|
|
4568
4620
|
case 'user.unbanned':
|
|
4569
4621
|
if (!((_event$user12 = event.user) !== null && _event$user12 !== void 0 && _event$user12.id)) break;
|
|
4570
|
-
channelState.members[event.user.id] = _objectSpread$
|
|
4622
|
+
channelState.members[event.user.id] = _objectSpread$a(_objectSpread$a({}, channelState.members[event.user.id] || {}), {}, {
|
|
4571
4623
|
shadow_banned: false,
|
|
4572
4624
|
banned: false,
|
|
4573
|
-
user: _objectSpread$
|
|
4625
|
+
user: _objectSpread$a(_objectSpread$a({}, ((_channelState$members2 = channelState.members[event.user.id]) === null || _channelState$members2 === void 0 ? void 0 : _channelState$members2.user) || {}), event.user)
|
|
4574
4626
|
});
|
|
4575
4627
|
break;
|
|
4576
4628
|
} // any event can send over the online count
|
|
@@ -4600,7 +4652,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4600
4652
|
|
|
4601
4653
|
|
|
4602
4654
|
if (state.members) {
|
|
4603
|
-
var _iterator = _createForOfIteratorHelper$
|
|
4655
|
+
var _iterator = _createForOfIteratorHelper$4(state.members),
|
|
4604
4656
|
_step;
|
|
4605
4657
|
|
|
4606
4658
|
try {
|
|
@@ -4644,7 +4696,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4644
4696
|
|
|
4645
4697
|
|
|
4646
4698
|
if (state.watchers) {
|
|
4647
|
-
var _iterator2 = _createForOfIteratorHelper$
|
|
4699
|
+
var _iterator2 = _createForOfIteratorHelper$4(state.watchers),
|
|
4648
4700
|
_step2;
|
|
4649
4701
|
|
|
4650
4702
|
try {
|
|
@@ -4680,7 +4732,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4680
4732
|
|
|
4681
4733
|
|
|
4682
4734
|
if (state.read) {
|
|
4683
|
-
var _iterator3 = _createForOfIteratorHelper$
|
|
4735
|
+
var _iterator3 = _createForOfIteratorHelper$4(state.read),
|
|
4684
4736
|
_step3;
|
|
4685
4737
|
|
|
4686
4738
|
try {
|
|
@@ -4754,11 +4806,11 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4754
4806
|
return Channel;
|
|
4755
4807
|
}();
|
|
4756
4808
|
|
|
4757
|
-
function _createForOfIteratorHelper$
|
|
4809
|
+
function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4758
4810
|
|
|
4759
|
-
function _unsupportedIterableToArray$
|
|
4811
|
+
function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
|
|
4760
4812
|
|
|
4761
|
-
function _arrayLikeToArray$
|
|
4813
|
+
function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
4762
4814
|
|
|
4763
4815
|
/**
|
|
4764
4816
|
* ClientState - A container class for the client state.
|
|
@@ -4781,7 +4833,7 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
4781
4833
|
_createClass(ClientState, [{
|
|
4782
4834
|
key: "updateUsers",
|
|
4783
4835
|
value: function updateUsers(users) {
|
|
4784
|
-
var _iterator = _createForOfIteratorHelper$
|
|
4836
|
+
var _iterator = _createForOfIteratorHelper$3(users),
|
|
4785
4837
|
_step;
|
|
4786
4838
|
|
|
4787
4839
|
try {
|
|
@@ -4829,9 +4881,9 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
4829
4881
|
return ClientState;
|
|
4830
4882
|
}();
|
|
4831
4883
|
|
|
4832
|
-
function ownKeys$
|
|
4884
|
+
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4833
4885
|
|
|
4834
|
-
function _objectSpread$
|
|
4886
|
+
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$9(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4835
4887
|
var InsightMetrics = function InsightMetrics() {
|
|
4836
4888
|
_classCallCheck(this, InsightMetrics);
|
|
4837
4889
|
|
|
@@ -4910,7 +4962,7 @@ var postInsights = /*#__PURE__*/function () {
|
|
|
4910
4962
|
};
|
|
4911
4963
|
}();
|
|
4912
4964
|
function buildWsFatalInsight(connection, event) {
|
|
4913
|
-
return _objectSpread$
|
|
4965
|
+
return _objectSpread$9(_objectSpread$9({}, event), buildWsBaseInsight(connection));
|
|
4914
4966
|
}
|
|
4915
4967
|
|
|
4916
4968
|
function buildWsBaseInsight(connection) {
|
|
@@ -4943,9 +4995,9 @@ function buildWsSuccessAfterFailureInsight(connection) {
|
|
|
4943
4995
|
return buildWsBaseInsight(connection);
|
|
4944
4996
|
}
|
|
4945
4997
|
|
|
4946
|
-
function ownKeys$
|
|
4998
|
+
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4947
4999
|
|
|
4948
|
-
function _objectSpread$
|
|
5000
|
+
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4949
5001
|
|
|
4950
5002
|
// Type guards to check WebSocket error type
|
|
4951
5003
|
var isCloseEvent = function isCloseEvent(res) {
|
|
@@ -5309,7 +5361,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
5309
5361
|
value: function _log(msg) {
|
|
5310
5362
|
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5311
5363
|
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5312
|
-
this.client.logger(level, 'connection:' + msg, _objectSpread$
|
|
5364
|
+
this.client.logger(level, 'connection:' + msg, _objectSpread$8({
|
|
5313
5365
|
tags: ['connection']
|
|
5314
5366
|
}, extra));
|
|
5315
5367
|
}
|
|
@@ -5900,9 +5952,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
5900
5952
|
return StableWSConnection;
|
|
5901
5953
|
}();
|
|
5902
5954
|
|
|
5903
|
-
function ownKeys$
|
|
5955
|
+
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5904
5956
|
|
|
5905
|
-
function _objectSpread$
|
|
5957
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
5906
5958
|
|
|
5907
5959
|
/**
|
|
5908
5960
|
* Creates the JWT token that can be used for a UserSession
|
|
@@ -5923,7 +5975,7 @@ function JWTUserToken(apiSecret, userId) {
|
|
|
5923
5975
|
throw new TypeError('userId should be a string');
|
|
5924
5976
|
}
|
|
5925
5977
|
|
|
5926
|
-
var payload = _objectSpread$
|
|
5978
|
+
var payload = _objectSpread$7({
|
|
5927
5979
|
user_id: userId
|
|
5928
5980
|
}, extraData); // make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
5929
5981
|
|
|
@@ -6333,9 +6385,9 @@ function isErrorResponse(res) {
|
|
|
6333
6385
|
return !res.status || res.status < 200 || 300 <= res.status;
|
|
6334
6386
|
}
|
|
6335
6387
|
|
|
6336
|
-
function ownKeys$
|
|
6388
|
+
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
6337
6389
|
|
|
6338
|
-
function _objectSpread$
|
|
6390
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6339
6391
|
var ConnectionState;
|
|
6340
6392
|
|
|
6341
6393
|
(function (ConnectionState) {
|
|
@@ -6398,7 +6450,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
6398
6450
|
_context.next = 4;
|
|
6399
6451
|
return _this.client.doAxiosRequest('get', _this.client.baseURL.replace(':3030', ':8900') + '/longpoll', // replace port if present for testing with local API
|
|
6400
6452
|
undefined, {
|
|
6401
|
-
config: _objectSpread$
|
|
6453
|
+
config: _objectSpread$6(_objectSpread$6({}, config), {}, {
|
|
6402
6454
|
cancelToken: (_this$cancelToken2 = _this.cancelToken) === null || _this$cancelToken2 === void 0 ? void 0 : _this$cancelToken2.token
|
|
6403
6455
|
}),
|
|
6404
6456
|
params: params
|
|
@@ -6676,7 +6728,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
6676
6728
|
value: function _log(msg) {
|
|
6677
6729
|
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6678
6730
|
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
6679
|
-
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$
|
|
6731
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$6({
|
|
6680
6732
|
tags: ['connection_fallback', 'connection']
|
|
6681
6733
|
}, extra));
|
|
6682
6734
|
}
|
|
@@ -6709,53 +6761,45 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
6709
6761
|
return WSConnectionFallback;
|
|
6710
6762
|
}();
|
|
6711
6763
|
|
|
6712
|
-
var
|
|
6713
|
-
function
|
|
6714
|
-
_classCallCheck(this,
|
|
6764
|
+
var Segment = /*#__PURE__*/function () {
|
|
6765
|
+
function Segment(client, type, id, data) {
|
|
6766
|
+
_classCallCheck(this, Segment);
|
|
6715
6767
|
|
|
6716
|
-
_defineProperty(this, "
|
|
6768
|
+
_defineProperty(this, "type", void 0);
|
|
6717
6769
|
|
|
6718
|
-
_defineProperty(this, "
|
|
6770
|
+
_defineProperty(this, "id", void 0);
|
|
6719
6771
|
|
|
6720
6772
|
_defineProperty(this, "client", void 0);
|
|
6721
6773
|
|
|
6774
|
+
_defineProperty(this, "data", void 0);
|
|
6775
|
+
|
|
6722
6776
|
this.client = client;
|
|
6777
|
+
this.type = type;
|
|
6723
6778
|
this.id = id;
|
|
6724
6779
|
this.data = data;
|
|
6725
6780
|
}
|
|
6726
6781
|
|
|
6727
|
-
_createClass(
|
|
6782
|
+
_createClass(Segment, [{
|
|
6728
6783
|
key: "create",
|
|
6729
6784
|
value: function () {
|
|
6730
6785
|
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
6731
|
-
var _this$data, _this$data2, _this$data3, _this$data4, _this$data5
|
|
6786
|
+
var _this$data, _this$data2, _this$data3, _this$data4, _this$data5;
|
|
6732
6787
|
|
|
6733
|
-
var body
|
|
6788
|
+
var body;
|
|
6734
6789
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
6735
6790
|
while (1) {
|
|
6736
6791
|
switch (_context.prev = _context.next) {
|
|
6737
6792
|
case 0:
|
|
6738
6793
|
body = {
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
create_channels: (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5.create_channels,
|
|
6745
|
-
description: (_this$data6 = this.data) === null || _this$data6 === void 0 ? void 0 : _this$data6.description,
|
|
6746
|
-
name: (_this$data7 = this.data) === null || _this$data7 === void 0 ? void 0 : _this$data7.name,
|
|
6747
|
-
user_ids: (_this$data8 = this.data) === null || _this$data8 === void 0 ? void 0 : _this$data8.user_ids
|
|
6794
|
+
name: (_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.name,
|
|
6795
|
+
filter: (_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2.filter,
|
|
6796
|
+
description: (_this$data3 = this.data) === null || _this$data3 === void 0 ? void 0 : _this$data3.description,
|
|
6797
|
+
all_sender_channels: (_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : _this$data4.all_sender_channels,
|
|
6798
|
+
all_users: (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5.all_users
|
|
6748
6799
|
};
|
|
6749
|
-
_context.
|
|
6750
|
-
return this.client.createCampaign(body);
|
|
6751
|
-
|
|
6752
|
-
case 3:
|
|
6753
|
-
result = _context.sent;
|
|
6754
|
-
this.id = result.campaign.id;
|
|
6755
|
-
this.data = result.campaign;
|
|
6756
|
-
return _context.abrupt("return", result);
|
|
6800
|
+
return _context.abrupt("return", this.client.createSegment(this.type, this.id, body));
|
|
6757
6801
|
|
|
6758
|
-
case
|
|
6802
|
+
case 2:
|
|
6759
6803
|
case "end":
|
|
6760
6804
|
return _context.stop();
|
|
6761
6805
|
}
|
|
@@ -6770,28 +6814,24 @@ var Campaign = /*#__PURE__*/function () {
|
|
|
6770
6814
|
return create;
|
|
6771
6815
|
}()
|
|
6772
6816
|
}, {
|
|
6773
|
-
key: "
|
|
6774
|
-
value: function
|
|
6817
|
+
key: "verifySegmentId",
|
|
6818
|
+
value: function verifySegmentId() {
|
|
6775
6819
|
if (!this.id) {
|
|
6776
|
-
throw new Error('
|
|
6820
|
+
throw new Error('Segment id is missing. Either create the segment using segment.create() or set the id during instantiation - const segment = client.segment(id)');
|
|
6777
6821
|
}
|
|
6778
6822
|
}
|
|
6779
6823
|
}, {
|
|
6780
|
-
key: "
|
|
6824
|
+
key: "get",
|
|
6781
6825
|
value: function () {
|
|
6782
|
-
var
|
|
6826
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
6783
6827
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
6784
6828
|
while (1) {
|
|
6785
6829
|
switch (_context2.prev = _context2.next) {
|
|
6786
6830
|
case 0:
|
|
6787
|
-
this.
|
|
6788
|
-
_context2.
|
|
6789
|
-
return this.client.startCampaign(this.id, options);
|
|
6790
|
-
|
|
6791
|
-
case 3:
|
|
6792
|
-
return _context2.abrupt("return", _context2.sent);
|
|
6831
|
+
this.verifySegmentId();
|
|
6832
|
+
return _context2.abrupt("return", this.client.getSegment(this.id));
|
|
6793
6833
|
|
|
6794
|
-
case
|
|
6834
|
+
case 2:
|
|
6795
6835
|
case "end":
|
|
6796
6836
|
return _context2.stop();
|
|
6797
6837
|
}
|
|
@@ -6799,11 +6839,11 @@ var Campaign = /*#__PURE__*/function () {
|
|
|
6799
6839
|
}, _callee2, this);
|
|
6800
6840
|
}));
|
|
6801
6841
|
|
|
6802
|
-
function
|
|
6803
|
-
return
|
|
6842
|
+
function get() {
|
|
6843
|
+
return _get.apply(this, arguments);
|
|
6804
6844
|
}
|
|
6805
6845
|
|
|
6806
|
-
return
|
|
6846
|
+
return get;
|
|
6807
6847
|
}()
|
|
6808
6848
|
}, {
|
|
6809
6849
|
key: "update",
|
|
@@ -6813,8 +6853,8 @@ var Campaign = /*#__PURE__*/function () {
|
|
|
6813
6853
|
while (1) {
|
|
6814
6854
|
switch (_context3.prev = _context3.next) {
|
|
6815
6855
|
case 0:
|
|
6816
|
-
this.
|
|
6817
|
-
return _context3.abrupt("return", this.client.
|
|
6856
|
+
this.verifySegmentId();
|
|
6857
|
+
return _context3.abrupt("return", this.client.updateSegment(this.id, data));
|
|
6818
6858
|
|
|
6819
6859
|
case 2:
|
|
6820
6860
|
case "end":
|
|
@@ -6824,28 +6864,24 @@ var Campaign = /*#__PURE__*/function () {
|
|
|
6824
6864
|
}, _callee3, this);
|
|
6825
6865
|
}));
|
|
6826
6866
|
|
|
6827
|
-
function update(
|
|
6867
|
+
function update(_x) {
|
|
6828
6868
|
return _update.apply(this, arguments);
|
|
6829
6869
|
}
|
|
6830
6870
|
|
|
6831
6871
|
return update;
|
|
6832
6872
|
}()
|
|
6833
6873
|
}, {
|
|
6834
|
-
key: "
|
|
6874
|
+
key: "addTargets",
|
|
6835
6875
|
value: function () {
|
|
6836
|
-
var
|
|
6876
|
+
var _addTargets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(targets) {
|
|
6837
6877
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
6838
6878
|
while (1) {
|
|
6839
6879
|
switch (_context4.prev = _context4.next) {
|
|
6840
6880
|
case 0:
|
|
6841
|
-
this.
|
|
6842
|
-
_context4.
|
|
6843
|
-
return this.client.deleteCampaign(this.id);
|
|
6844
|
-
|
|
6845
|
-
case 3:
|
|
6846
|
-
return _context4.abrupt("return", _context4.sent);
|
|
6881
|
+
this.verifySegmentId();
|
|
6882
|
+
return _context4.abrupt("return", this.client.addSegmentTargets(this.id, targets));
|
|
6847
6883
|
|
|
6848
|
-
case
|
|
6884
|
+
case 2:
|
|
6849
6885
|
case "end":
|
|
6850
6886
|
return _context4.stop();
|
|
6851
6887
|
}
|
|
@@ -6853,22 +6889,22 @@ var Campaign = /*#__PURE__*/function () {
|
|
|
6853
6889
|
}, _callee4, this);
|
|
6854
6890
|
}));
|
|
6855
6891
|
|
|
6856
|
-
function
|
|
6857
|
-
return
|
|
6892
|
+
function addTargets(_x2) {
|
|
6893
|
+
return _addTargets.apply(this, arguments);
|
|
6858
6894
|
}
|
|
6859
6895
|
|
|
6860
|
-
return
|
|
6896
|
+
return addTargets;
|
|
6861
6897
|
}()
|
|
6862
6898
|
}, {
|
|
6863
|
-
key: "
|
|
6899
|
+
key: "removeTargets",
|
|
6864
6900
|
value: function () {
|
|
6865
|
-
var
|
|
6901
|
+
var _removeTargets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(targets) {
|
|
6866
6902
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
6867
6903
|
while (1) {
|
|
6868
6904
|
switch (_context5.prev = _context5.next) {
|
|
6869
6905
|
case 0:
|
|
6870
|
-
this.
|
|
6871
|
-
return _context5.abrupt("return", this.client.
|
|
6906
|
+
this.verifySegmentId();
|
|
6907
|
+
return _context5.abrupt("return", this.client.removeSegmentTargets(this.id, targets));
|
|
6872
6908
|
|
|
6873
6909
|
case 2:
|
|
6874
6910
|
case "end":
|
|
@@ -6878,22 +6914,22 @@ var Campaign = /*#__PURE__*/function () {
|
|
|
6878
6914
|
}, _callee5, this);
|
|
6879
6915
|
}));
|
|
6880
6916
|
|
|
6881
|
-
function
|
|
6882
|
-
return
|
|
6917
|
+
function removeTargets(_x3) {
|
|
6918
|
+
return _removeTargets.apply(this, arguments);
|
|
6883
6919
|
}
|
|
6884
6920
|
|
|
6885
|
-
return
|
|
6921
|
+
return removeTargets;
|
|
6886
6922
|
}()
|
|
6887
6923
|
}, {
|
|
6888
|
-
key: "
|
|
6924
|
+
key: "delete",
|
|
6889
6925
|
value: function () {
|
|
6890
|
-
var
|
|
6926
|
+
var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
6891
6927
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
6892
6928
|
while (1) {
|
|
6893
6929
|
switch (_context6.prev = _context6.next) {
|
|
6894
6930
|
case 0:
|
|
6895
|
-
this.
|
|
6896
|
-
return _context6.abrupt("return", this.client.
|
|
6931
|
+
this.verifySegmentId();
|
|
6932
|
+
return _context6.abrupt("return", this.client.deleteSegment(this.id));
|
|
6897
6933
|
|
|
6898
6934
|
case 2:
|
|
6899
6935
|
case "end":
|
|
@@ -6903,200 +6939,11 @@ var Campaign = /*#__PURE__*/function () {
|
|
|
6903
6939
|
}, _callee6, this);
|
|
6904
6940
|
}));
|
|
6905
6941
|
|
|
6906
|
-
function
|
|
6907
|
-
return
|
|
6942
|
+
function _delete() {
|
|
6943
|
+
return _delete2.apply(this, arguments);
|
|
6908
6944
|
}
|
|
6909
6945
|
|
|
6910
|
-
return
|
|
6911
|
-
}()
|
|
6912
|
-
}]);
|
|
6913
|
-
|
|
6914
|
-
return Campaign;
|
|
6915
|
-
}();
|
|
6916
|
-
|
|
6917
|
-
var Segment = /*#__PURE__*/function () {
|
|
6918
|
-
function Segment(client, type, id, data) {
|
|
6919
|
-
_classCallCheck(this, Segment);
|
|
6920
|
-
|
|
6921
|
-
_defineProperty(this, "type", void 0);
|
|
6922
|
-
|
|
6923
|
-
_defineProperty(this, "id", void 0);
|
|
6924
|
-
|
|
6925
|
-
_defineProperty(this, "client", void 0);
|
|
6926
|
-
|
|
6927
|
-
_defineProperty(this, "data", void 0);
|
|
6928
|
-
|
|
6929
|
-
this.client = client;
|
|
6930
|
-
this.type = type;
|
|
6931
|
-
this.id = id;
|
|
6932
|
-
this.data = data;
|
|
6933
|
-
}
|
|
6934
|
-
|
|
6935
|
-
_createClass(Segment, [{
|
|
6936
|
-
key: "create",
|
|
6937
|
-
value: function () {
|
|
6938
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
6939
|
-
var _this$data, _this$data2, _this$data3, _this$data4, _this$data5;
|
|
6940
|
-
|
|
6941
|
-
var body;
|
|
6942
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
6943
|
-
while (1) {
|
|
6944
|
-
switch (_context.prev = _context.next) {
|
|
6945
|
-
case 0:
|
|
6946
|
-
body = {
|
|
6947
|
-
name: (_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.name,
|
|
6948
|
-
filter: (_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2.filter,
|
|
6949
|
-
description: (_this$data3 = this.data) === null || _this$data3 === void 0 ? void 0 : _this$data3.description,
|
|
6950
|
-
all_sender_channels: (_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : _this$data4.all_sender_channels,
|
|
6951
|
-
all_users: (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5.all_users
|
|
6952
|
-
};
|
|
6953
|
-
return _context.abrupt("return", this.client.createSegment(this.type, this.id, body));
|
|
6954
|
-
|
|
6955
|
-
case 2:
|
|
6956
|
-
case "end":
|
|
6957
|
-
return _context.stop();
|
|
6958
|
-
}
|
|
6959
|
-
}
|
|
6960
|
-
}, _callee, this);
|
|
6961
|
-
}));
|
|
6962
|
-
|
|
6963
|
-
function create() {
|
|
6964
|
-
return _create.apply(this, arguments);
|
|
6965
|
-
}
|
|
6966
|
-
|
|
6967
|
-
return create;
|
|
6968
|
-
}()
|
|
6969
|
-
}, {
|
|
6970
|
-
key: "verifySegmentId",
|
|
6971
|
-
value: function verifySegmentId() {
|
|
6972
|
-
if (!this.id) {
|
|
6973
|
-
throw new Error('Segment id is missing. Either create the segment using segment.create() or set the id during instantiation - const segment = client.segment(id)');
|
|
6974
|
-
}
|
|
6975
|
-
}
|
|
6976
|
-
}, {
|
|
6977
|
-
key: "get",
|
|
6978
|
-
value: function () {
|
|
6979
|
-
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
6980
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
6981
|
-
while (1) {
|
|
6982
|
-
switch (_context2.prev = _context2.next) {
|
|
6983
|
-
case 0:
|
|
6984
|
-
this.verifySegmentId();
|
|
6985
|
-
return _context2.abrupt("return", this.client.getSegment(this.id));
|
|
6986
|
-
|
|
6987
|
-
case 2:
|
|
6988
|
-
case "end":
|
|
6989
|
-
return _context2.stop();
|
|
6990
|
-
}
|
|
6991
|
-
}
|
|
6992
|
-
}, _callee2, this);
|
|
6993
|
-
}));
|
|
6994
|
-
|
|
6995
|
-
function get() {
|
|
6996
|
-
return _get.apply(this, arguments);
|
|
6997
|
-
}
|
|
6998
|
-
|
|
6999
|
-
return get;
|
|
7000
|
-
}()
|
|
7001
|
-
}, {
|
|
7002
|
-
key: "update",
|
|
7003
|
-
value: function () {
|
|
7004
|
-
var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
|
|
7005
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
7006
|
-
while (1) {
|
|
7007
|
-
switch (_context3.prev = _context3.next) {
|
|
7008
|
-
case 0:
|
|
7009
|
-
this.verifySegmentId();
|
|
7010
|
-
return _context3.abrupt("return", this.client.updateSegment(this.id, data));
|
|
7011
|
-
|
|
7012
|
-
case 2:
|
|
7013
|
-
case "end":
|
|
7014
|
-
return _context3.stop();
|
|
7015
|
-
}
|
|
7016
|
-
}
|
|
7017
|
-
}, _callee3, this);
|
|
7018
|
-
}));
|
|
7019
|
-
|
|
7020
|
-
function update(_x) {
|
|
7021
|
-
return _update.apply(this, arguments);
|
|
7022
|
-
}
|
|
7023
|
-
|
|
7024
|
-
return update;
|
|
7025
|
-
}()
|
|
7026
|
-
}, {
|
|
7027
|
-
key: "addTargets",
|
|
7028
|
-
value: function () {
|
|
7029
|
-
var _addTargets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(targets) {
|
|
7030
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
7031
|
-
while (1) {
|
|
7032
|
-
switch (_context4.prev = _context4.next) {
|
|
7033
|
-
case 0:
|
|
7034
|
-
this.verifySegmentId();
|
|
7035
|
-
return _context4.abrupt("return", this.client.addSegmentTargets(this.id, targets));
|
|
7036
|
-
|
|
7037
|
-
case 2:
|
|
7038
|
-
case "end":
|
|
7039
|
-
return _context4.stop();
|
|
7040
|
-
}
|
|
7041
|
-
}
|
|
7042
|
-
}, _callee4, this);
|
|
7043
|
-
}));
|
|
7044
|
-
|
|
7045
|
-
function addTargets(_x2) {
|
|
7046
|
-
return _addTargets.apply(this, arguments);
|
|
7047
|
-
}
|
|
7048
|
-
|
|
7049
|
-
return addTargets;
|
|
7050
|
-
}()
|
|
7051
|
-
}, {
|
|
7052
|
-
key: "removeTargets",
|
|
7053
|
-
value: function () {
|
|
7054
|
-
var _removeTargets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(targets) {
|
|
7055
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
7056
|
-
while (1) {
|
|
7057
|
-
switch (_context5.prev = _context5.next) {
|
|
7058
|
-
case 0:
|
|
7059
|
-
this.verifySegmentId();
|
|
7060
|
-
return _context5.abrupt("return", this.client.removeSegmentTargets(this.id, targets));
|
|
7061
|
-
|
|
7062
|
-
case 2:
|
|
7063
|
-
case "end":
|
|
7064
|
-
return _context5.stop();
|
|
7065
|
-
}
|
|
7066
|
-
}
|
|
7067
|
-
}, _callee5, this);
|
|
7068
|
-
}));
|
|
7069
|
-
|
|
7070
|
-
function removeTargets(_x3) {
|
|
7071
|
-
return _removeTargets.apply(this, arguments);
|
|
7072
|
-
}
|
|
7073
|
-
|
|
7074
|
-
return removeTargets;
|
|
7075
|
-
}()
|
|
7076
|
-
}, {
|
|
7077
|
-
key: "delete",
|
|
7078
|
-
value: function () {
|
|
7079
|
-
var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
7080
|
-
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
7081
|
-
while (1) {
|
|
7082
|
-
switch (_context6.prev = _context6.next) {
|
|
7083
|
-
case 0:
|
|
7084
|
-
this.verifySegmentId();
|
|
7085
|
-
return _context6.abrupt("return", this.client.deleteSegment(this.id));
|
|
7086
|
-
|
|
7087
|
-
case 2:
|
|
7088
|
-
case "end":
|
|
7089
|
-
return _context6.stop();
|
|
7090
|
-
}
|
|
7091
|
-
}
|
|
7092
|
-
}, _callee6, this);
|
|
7093
|
-
}));
|
|
7094
|
-
|
|
7095
|
-
function _delete() {
|
|
7096
|
-
return _delete2.apply(this, arguments);
|
|
7097
|
-
}
|
|
7098
|
-
|
|
7099
|
-
return _delete;
|
|
6946
|
+
return _delete;
|
|
7100
6947
|
}()
|
|
7101
6948
|
}, {
|
|
7102
6949
|
key: "targetExists",
|
|
@@ -7256,9 +7103,9 @@ var VotingVisibility;
|
|
|
7256
7103
|
VotingVisibility["public"] = "public";
|
|
7257
7104
|
})(VotingVisibility || (VotingVisibility = {}));
|
|
7258
7105
|
|
|
7259
|
-
function ownKeys$
|
|
7106
|
+
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
7260
7107
|
|
|
7261
|
-
function _objectSpread$
|
|
7108
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
7262
7109
|
|
|
7263
7110
|
function isPatch(value) {
|
|
7264
7111
|
return typeof value === 'function';
|
|
@@ -7288,7 +7135,7 @@ var StateStore = function StateStore(value) {
|
|
|
7288
7135
|
|
|
7289
7136
|
_defineProperty(this, "partialNext", function (partial) {
|
|
7290
7137
|
return _this.next(function (current) {
|
|
7291
|
-
return _objectSpread$
|
|
7138
|
+
return _objectSpread$5(_objectSpread$5({}, current), partial);
|
|
7292
7139
|
});
|
|
7293
7140
|
});
|
|
7294
7141
|
|
|
@@ -7311,12 +7158,21 @@ var StateStore = function StateStore(value) {
|
|
|
7311
7158
|
var selectedValues;
|
|
7312
7159
|
|
|
7313
7160
|
var wrappedHandler = function wrappedHandler(nextValue) {
|
|
7314
|
-
var _selectedValues$some, _selectedValues;
|
|
7315
|
-
|
|
7316
7161
|
var newlySelectedValues = selector(nextValue);
|
|
7317
|
-
var hasUpdatedValues =
|
|
7318
|
-
|
|
7319
|
-
|
|
7162
|
+
var hasUpdatedValues = !selectedValues;
|
|
7163
|
+
|
|
7164
|
+
if (Array.isArray(newlySelectedValues) && StateStore.logCount > 0) {
|
|
7165
|
+
console.warn('[StreamChat]: The API of our StateStore has changed. Instead of returning an array in the selector, please return a named object of properties.');
|
|
7166
|
+
StateStore.logCount--;
|
|
7167
|
+
}
|
|
7168
|
+
|
|
7169
|
+
for (var key in selectedValues) {
|
|
7170
|
+
// @ts-ignore TODO: remove array support (Readonly<unknown[]>)
|
|
7171
|
+
if (selectedValues[key] === newlySelectedValues[key]) continue;
|
|
7172
|
+
hasUpdatedValues = true;
|
|
7173
|
+
break;
|
|
7174
|
+
}
|
|
7175
|
+
|
|
7320
7176
|
if (!hasUpdatedValues) return;
|
|
7321
7177
|
var oldSelectedValues = selectedValues;
|
|
7322
7178
|
selectedValues = newlySelectedValues;
|
|
@@ -7327,11 +7183,13 @@ var StateStore = function StateStore(value) {
|
|
|
7327
7183
|
});
|
|
7328
7184
|
};
|
|
7329
7185
|
|
|
7330
|
-
|
|
7186
|
+
_defineProperty(StateStore, "logCount", 5);
|
|
7331
7187
|
|
|
7332
|
-
|
|
7188
|
+
var _excluded$2 = ["limit", "sort"];
|
|
7333
7189
|
|
|
7334
|
-
function
|
|
7190
|
+
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
7191
|
+
|
|
7192
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
7335
7193
|
var DEFAULT_PAGE_LIMIT = 50;
|
|
7336
7194
|
var DEFAULT_SORT = [{
|
|
7337
7195
|
created_at: -1
|
|
@@ -7475,12 +7333,13 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7475
7333
|
|
|
7476
7334
|
_defineProperty(this, "subscribeMarkActiveThreadRead", function () {
|
|
7477
7335
|
return _this.state.subscribeWithSelector(function (nextValue) {
|
|
7478
|
-
return
|
|
7336
|
+
return {
|
|
7337
|
+
active: nextValue.active,
|
|
7338
|
+
unreadMessageCount: ownUnreadCountSelector(_this.client.userID)(nextValue)
|
|
7339
|
+
};
|
|
7479
7340
|
}, function (_ref3) {
|
|
7480
|
-
var
|
|
7481
|
-
|
|
7482
|
-
unreadMessageCount = _ref4[1];
|
|
7483
|
-
|
|
7341
|
+
var active = _ref3.active,
|
|
7342
|
+
unreadMessageCount = _ref3.unreadMessageCount;
|
|
7484
7343
|
if (!active || !unreadMessageCount) return;
|
|
7485
7344
|
|
|
7486
7345
|
_this.throttledMarkAsRead();
|
|
@@ -7489,11 +7348,13 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7489
7348
|
|
|
7490
7349
|
_defineProperty(this, "subscribeReloadActiveStaleThread", function () {
|
|
7491
7350
|
return _this.state.subscribeWithSelector(function (nextValue) {
|
|
7492
|
-
return
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7351
|
+
return {
|
|
7352
|
+
active: nextValue.active,
|
|
7353
|
+
isStateStale: nextValue.isStateStale
|
|
7354
|
+
};
|
|
7355
|
+
}, function (_ref4) {
|
|
7356
|
+
var active = _ref4.active,
|
|
7357
|
+
isStateStale = _ref4.isStateStale;
|
|
7497
7358
|
|
|
7498
7359
|
if (active && isStateStale) {
|
|
7499
7360
|
_this.reload();
|
|
@@ -7557,14 +7418,14 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7557
7418
|
if (userId === ((_event$user2 = event.user) === null || _event$user2 === void 0 ? void 0 : _event$user2.id)) {
|
|
7558
7419
|
// The user who just sent a message to the thread has no unread messages
|
|
7559
7420
|
// in that thread
|
|
7560
|
-
nextUserRead = _objectSpread$
|
|
7421
|
+
nextUserRead = _objectSpread$4(_objectSpread$4({}, nextUserRead), {}, {
|
|
7561
7422
|
lastReadAt: event.created_at ? new Date(event.created_at) : new Date(),
|
|
7562
7423
|
user: event.user,
|
|
7563
7424
|
unreadMessageCount: 0
|
|
7564
7425
|
});
|
|
7565
7426
|
} else if (active && userId === _this.client.userID) ; else {
|
|
7566
7427
|
// Increment unread count for all users except the author of the new message
|
|
7567
|
-
nextUserRead = _objectSpread$
|
|
7428
|
+
nextUserRead = _objectSpread$4(_objectSpread$4({}, nextUserRead), {}, {
|
|
7568
7429
|
unreadMessageCount: userRead.unreadMessageCount + 1
|
|
7569
7430
|
});
|
|
7570
7431
|
}
|
|
@@ -7588,8 +7449,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7588
7449
|
var user = event.user;
|
|
7589
7450
|
|
|
7590
7451
|
_this.state.next(function (current) {
|
|
7591
|
-
return _objectSpread$
|
|
7592
|
-
read: _objectSpread$
|
|
7452
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7453
|
+
read: _objectSpread$4(_objectSpread$4({}, current.read), {}, _defineProperty({}, userId, {
|
|
7593
7454
|
lastReadAt: new Date(createdAt),
|
|
7594
7455
|
user: user,
|
|
7595
7456
|
lastReadMessageId: event.last_read_message_id,
|
|
@@ -7650,10 +7511,10 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7650
7511
|
_this.unsubscribeFunctions.clear();
|
|
7651
7512
|
});
|
|
7652
7513
|
|
|
7653
|
-
_defineProperty(this, "deleteReplyLocally", function (
|
|
7514
|
+
_defineProperty(this, "deleteReplyLocally", function (_ref5) {
|
|
7654
7515
|
var _replies$index, _replies;
|
|
7655
7516
|
|
|
7656
|
-
var message =
|
|
7517
|
+
var message = _ref5.message;
|
|
7657
7518
|
|
|
7658
7519
|
var _this$state$getLatest3 = _this.state.getLatestValue(),
|
|
7659
7520
|
replies = _this$state$getLatest3.replies;
|
|
@@ -7681,10 +7542,10 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7681
7542
|
});
|
|
7682
7543
|
});
|
|
7683
7544
|
|
|
7684
|
-
_defineProperty(this, "upsertReplyLocally", function (
|
|
7685
|
-
var message =
|
|
7686
|
-
|
|
7687
|
-
timestampChanged =
|
|
7545
|
+
_defineProperty(this, "upsertReplyLocally", function (_ref6) {
|
|
7546
|
+
var message = _ref6.message,
|
|
7547
|
+
_ref6$timestampChange = _ref6.timestampChanged,
|
|
7548
|
+
timestampChanged = _ref6$timestampChange === void 0 ? false : _ref6$timestampChange;
|
|
7688
7549
|
|
|
7689
7550
|
if (message.parent_id !== _this.id) {
|
|
7690
7551
|
throw new Error('Reply does not belong to this thread');
|
|
@@ -7700,14 +7561,14 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7700
7561
|
}
|
|
7701
7562
|
|
|
7702
7563
|
_this.state.next(function (current) {
|
|
7703
|
-
return _objectSpread$
|
|
7564
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7704
7565
|
replies: addToMessageList(current.replies, formattedMessage, timestampChanged)
|
|
7705
7566
|
});
|
|
7706
7567
|
});
|
|
7707
7568
|
});
|
|
7708
7569
|
|
|
7709
|
-
_defineProperty(this, "updateParentMessageLocally", function (
|
|
7710
|
-
var message =
|
|
7570
|
+
_defineProperty(this, "updateParentMessageLocally", function (_ref7) {
|
|
7571
|
+
var message = _ref7.message;
|
|
7711
7572
|
|
|
7712
7573
|
if (message.id !== _this.id) {
|
|
7713
7574
|
throw new Error('Message does not belong to this thread');
|
|
@@ -7717,7 +7578,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7717
7578
|
var _message$reply_count;
|
|
7718
7579
|
|
|
7719
7580
|
var formattedMessage = formatMessage(message);
|
|
7720
|
-
return _objectSpread$
|
|
7581
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7721
7582
|
deletedAt: formattedMessage.deleted_at,
|
|
7722
7583
|
parentMessage: formattedMessage,
|
|
7723
7584
|
replyCount: (_message$reply_count = message.reply_count) !== null && _message$reply_count !== void 0 ? _message$reply_count : current.replyCount
|
|
@@ -7740,8 +7601,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7740
7601
|
});
|
|
7741
7602
|
|
|
7742
7603
|
_defineProperty(this, "markAsRead", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
7743
|
-
var
|
|
7744
|
-
|
|
7604
|
+
var _ref9,
|
|
7605
|
+
_ref9$force,
|
|
7745
7606
|
force,
|
|
7746
7607
|
_args2 = arguments;
|
|
7747
7608
|
|
|
@@ -7749,7 +7610,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7749
7610
|
while (1) {
|
|
7750
7611
|
switch (_context2.prev = _context2.next) {
|
|
7751
7612
|
case 0:
|
|
7752
|
-
|
|
7613
|
+
_ref9 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref9$force = _ref9.force, force = _ref9$force === void 0 ? false : _ref9$force;
|
|
7753
7614
|
|
|
7754
7615
|
if (!(_this.ownUnreadCount === 0 && !force)) {
|
|
7755
7616
|
_context2.next = 3;
|
|
@@ -7782,45 +7643,45 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7782
7643
|
}));
|
|
7783
7644
|
|
|
7784
7645
|
_defineProperty(this, "queryReplies", function () {
|
|
7785
|
-
var
|
|
7646
|
+
var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7786
7647
|
|
|
7787
|
-
var
|
|
7788
|
-
limit =
|
|
7789
|
-
|
|
7790
|
-
sort =
|
|
7791
|
-
otherOptions = _objectWithoutProperties(
|
|
7648
|
+
var _ref10$limit = _ref10.limit,
|
|
7649
|
+
limit = _ref10$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref10$limit,
|
|
7650
|
+
_ref10$sort = _ref10.sort,
|
|
7651
|
+
sort = _ref10$sort === void 0 ? DEFAULT_SORT : _ref10$sort,
|
|
7652
|
+
otherOptions = _objectWithoutProperties(_ref10, _excluded$2);
|
|
7792
7653
|
|
|
7793
|
-
return _this.channel.getReplies(_this.id, _objectSpread$
|
|
7654
|
+
return _this.channel.getReplies(_this.id, _objectSpread$4({
|
|
7794
7655
|
limit: limit
|
|
7795
7656
|
}, otherOptions), sort);
|
|
7796
7657
|
});
|
|
7797
7658
|
|
|
7798
7659
|
_defineProperty(this, "loadNextPage", function () {
|
|
7799
|
-
var
|
|
7800
|
-
|
|
7801
|
-
limit =
|
|
7660
|
+
var _ref11 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
7661
|
+
_ref11$limit = _ref11.limit,
|
|
7662
|
+
limit = _ref11$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref11$limit;
|
|
7802
7663
|
|
|
7803
7664
|
return _this.loadPage(limit);
|
|
7804
7665
|
});
|
|
7805
7666
|
|
|
7806
7667
|
_defineProperty(this, "loadPrevPage", function () {
|
|
7807
|
-
var
|
|
7808
|
-
|
|
7809
|
-
limit =
|
|
7668
|
+
var _ref12 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
7669
|
+
_ref12$limit = _ref12.limit,
|
|
7670
|
+
limit = _ref12$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref12$limit;
|
|
7810
7671
|
|
|
7811
7672
|
return _this.loadPage(-limit);
|
|
7812
7673
|
});
|
|
7813
7674
|
|
|
7814
7675
|
_defineProperty(this, "loadPage", /*#__PURE__*/function () {
|
|
7815
|
-
var
|
|
7816
|
-
var _this$state$getLatest4, pagination,
|
|
7676
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(count) {
|
|
7677
|
+
var _this$state$getLatest4, pagination, _ref14, _ref15, loadingKey, cursorKey, insertionMethodKey, queryOptions, limit, _replies$at$id, _replies$at, data, replies, maybeNextCursor;
|
|
7817
7678
|
|
|
7818
7679
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
7819
7680
|
while (1) {
|
|
7820
7681
|
switch (_context3.prev = _context3.next) {
|
|
7821
7682
|
case 0:
|
|
7822
7683
|
_this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
|
|
7823
|
-
|
|
7684
|
+
_ref14 = count > 0 ? ['isLoadingNext', 'nextCursor', 'push'] : ['isLoadingPrev', 'prevCursor', 'unshift'], _ref15 = _slicedToArray(_ref14, 3), loadingKey = _ref15[0], cursorKey = _ref15[1], insertionMethodKey = _ref15[2];
|
|
7824
7685
|
|
|
7825
7686
|
if (!(pagination[loadingKey] || pagination[cursorKey] === null)) {
|
|
7826
7687
|
_context3.next = 4;
|
|
@@ -7834,12 +7695,12 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7834
7695
|
limit = Math.abs(count);
|
|
7835
7696
|
|
|
7836
7697
|
_this.state.partialNext({
|
|
7837
|
-
pagination: _objectSpread$
|
|
7698
|
+
pagination: _objectSpread$4(_objectSpread$4({}, pagination), {}, _defineProperty({}, loadingKey, true))
|
|
7838
7699
|
});
|
|
7839
7700
|
|
|
7840
7701
|
_context3.prev = 7;
|
|
7841
7702
|
_context3.next = 10;
|
|
7842
|
-
return _this.queryReplies(_objectSpread$
|
|
7703
|
+
return _this.queryReplies(_objectSpread$4(_objectSpread$4({}, queryOptions), {}, {
|
|
7843
7704
|
limit: limit
|
|
7844
7705
|
}));
|
|
7845
7706
|
|
|
@@ -7861,9 +7722,9 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7861
7722
|
(_nextReplies = nextReplies)[insertionMethodKey].apply(_nextReplies, _toConsumableArray(replies));
|
|
7862
7723
|
}
|
|
7863
7724
|
|
|
7864
|
-
return _objectSpread$
|
|
7725
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7865
7726
|
replies: nextReplies,
|
|
7866
|
-
pagination: _objectSpread$
|
|
7727
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, cursorKey, data.messages.length < limit ? null : maybeNextCursor), _defineProperty(_objectSpread4, loadingKey, false), _objectSpread4))
|
|
7867
7728
|
});
|
|
7868
7729
|
});
|
|
7869
7730
|
|
|
@@ -7877,8 +7738,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7877
7738
|
_this.client.logger('error', _context3.t0.message);
|
|
7878
7739
|
|
|
7879
7740
|
_this.state.next(function (current) {
|
|
7880
|
-
return _objectSpread$
|
|
7881
|
-
pagination: _objectSpread$
|
|
7741
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7742
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, _defineProperty({}, loadingKey, false))
|
|
7882
7743
|
});
|
|
7883
7744
|
});
|
|
7884
7745
|
|
|
@@ -7891,7 +7752,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7891
7752
|
}));
|
|
7892
7753
|
|
|
7893
7754
|
return function (_x) {
|
|
7894
|
-
return
|
|
7755
|
+
return _ref13.apply(this, arguments);
|
|
7895
7756
|
};
|
|
7896
7757
|
}());
|
|
7897
7758
|
|
|
@@ -7983,9 +7844,9 @@ var ownUnreadCountSelector = function ownUnreadCountSelector(currentUserId) {
|
|
|
7983
7844
|
};
|
|
7984
7845
|
};
|
|
7985
7846
|
|
|
7986
|
-
function ownKeys$
|
|
7847
|
+
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
7987
7848
|
|
|
7988
|
-
function _objectSpread$
|
|
7849
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
7989
7850
|
var MODERATION_ENTITY_TYPES = {
|
|
7990
7851
|
user: 'stream:user',
|
|
7991
7852
|
message: 'stream:chat:v1:message'
|
|
@@ -8102,7 +7963,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8102
7963
|
case 0:
|
|
8103
7964
|
options = _args3.length > 4 && _args3[4] !== undefined ? _args3[4] : {};
|
|
8104
7965
|
_context3.next = 3;
|
|
8105
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/flag', _objectSpread$
|
|
7966
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/flag', _objectSpread$3({
|
|
8106
7967
|
entity_type: entityType,
|
|
8107
7968
|
entity_id: entityId,
|
|
8108
7969
|
entity_creator_id: entityCreatorID,
|
|
@@ -8147,7 +8008,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8147
8008
|
case 0:
|
|
8148
8009
|
options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
8149
8010
|
_context4.next = 3;
|
|
8150
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/mute', _objectSpread$
|
|
8011
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/mute', _objectSpread$3({
|
|
8151
8012
|
target_ids: [targetID]
|
|
8152
8013
|
}, options));
|
|
8153
8014
|
|
|
@@ -8185,7 +8046,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8185
8046
|
switch (_context5.prev = _context5.next) {
|
|
8186
8047
|
case 0:
|
|
8187
8048
|
_context5.next = 2;
|
|
8188
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/unmute', _objectSpread$
|
|
8049
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/unmute', _objectSpread$3({
|
|
8189
8050
|
target_ids: [targetID]
|
|
8190
8051
|
}, options));
|
|
8191
8052
|
|
|
@@ -8227,7 +8088,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8227
8088
|
case 0:
|
|
8228
8089
|
options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
8229
8090
|
_context6.next = 3;
|
|
8230
|
-
return this.client.get(this.client.baseURL + "/api/v2/moderation/user_report", _objectSpread$
|
|
8091
|
+
return this.client.get(this.client.baseURL + "/api/v2/moderation/user_report", _objectSpread$3({
|
|
8231
8092
|
user_id: userID
|
|
8232
8093
|
}, options));
|
|
8233
8094
|
|
|
@@ -8271,7 +8132,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8271
8132
|
sort = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : [];
|
|
8272
8133
|
options = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : {};
|
|
8273
8134
|
_context7.next = 5;
|
|
8274
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/review_queue', _objectSpread$
|
|
8135
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/review_queue', _objectSpread$3({
|
|
8275
8136
|
filter: filterConditions,
|
|
8276
8137
|
sort: normalizeQuerySort(sort)
|
|
8277
8138
|
}, options));
|
|
@@ -8374,7 +8235,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8374
8235
|
case 0:
|
|
8375
8236
|
options = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : {};
|
|
8376
8237
|
_context10.next = 3;
|
|
8377
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/submit_action', _objectSpread$
|
|
8238
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/submit_action', _objectSpread$3({
|
|
8378
8239
|
action_type: actionType,
|
|
8379
8240
|
item_id: itemID
|
|
8380
8241
|
}, options));
|
|
@@ -8401,15 +8262,15 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8401
8262
|
return Moderation;
|
|
8402
8263
|
}();
|
|
8403
8264
|
|
|
8404
|
-
function _createForOfIteratorHelper$
|
|
8265
|
+
function _createForOfIteratorHelper$2(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8405
8266
|
|
|
8406
|
-
function _unsupportedIterableToArray$
|
|
8267
|
+
function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); }
|
|
8407
8268
|
|
|
8408
|
-
function _arrayLikeToArray$
|
|
8269
|
+
function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8409
8270
|
|
|
8410
|
-
function ownKeys$
|
|
8271
|
+
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
8411
8272
|
|
|
8412
|
-
function _objectSpread$
|
|
8273
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8413
8274
|
var DEFAULT_CONNECTION_RECOVERY_THROTTLE_DURATION = 1000;
|
|
8414
8275
|
var MAX_QUERY_THREADS_LIMIT = 25;
|
|
8415
8276
|
var ThreadManager = /*#__PURE__*/function () {
|
|
@@ -8489,15 +8350,15 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
8489
8350
|
|
|
8490
8351
|
_defineProperty(this, "subscribeManageThreadSubscriptions", function () {
|
|
8491
8352
|
return _this.state.subscribeWithSelector(function (nextValue) {
|
|
8492
|
-
return
|
|
8353
|
+
return {
|
|
8354
|
+
threads: nextValue.threads
|
|
8355
|
+
};
|
|
8493
8356
|
}, function (_ref5, prev) {
|
|
8494
|
-
var
|
|
8495
|
-
nextThreads = _ref6[0];
|
|
8357
|
+
var nextThreads = _ref5.threads;
|
|
8496
8358
|
|
|
8497
|
-
var
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
prevThreads = _ref8$ === void 0 ? [] : _ref8$; // Thread instance was removed if there's no thread with the given id at all,
|
|
8359
|
+
var _ref6 = prev !== null && prev !== void 0 ? prev : {},
|
|
8360
|
+
_ref6$threads = _ref6.threads,
|
|
8361
|
+
prevThreads = _ref6$threads === void 0 ? [] : _ref6$threads; // Thread instance was removed if there's no thread with the given id at all,
|
|
8501
8362
|
// or it was replaced with a new instance
|
|
8502
8363
|
|
|
8503
8364
|
|
|
@@ -8515,11 +8376,11 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
8515
8376
|
|
|
8516
8377
|
_defineProperty(this, "subscribeReloadOnActivation", function () {
|
|
8517
8378
|
return _this.state.subscribeWithSelector(function (nextValue) {
|
|
8518
|
-
return
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8379
|
+
return {
|
|
8380
|
+
active: nextValue.active
|
|
8381
|
+
};
|
|
8382
|
+
}, function (_ref7) {
|
|
8383
|
+
var active = _ref7.active;
|
|
8523
8384
|
if (active) _this.reload();
|
|
8524
8385
|
});
|
|
8525
8386
|
});
|
|
@@ -8553,7 +8414,7 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
8553
8414
|
var unsubscribeConnectionDropped = _this.client.on('connection.changed', function (event) {
|
|
8554
8415
|
if (event.online === false) {
|
|
8555
8416
|
_this.state.next(function (current) {
|
|
8556
|
-
return current.lastConnectionDropAt ? current : _objectSpread$
|
|
8417
|
+
return current.lastConnectionDropAt ? current : _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8557
8418
|
lastConnectionDropAt: new Date()
|
|
8558
8419
|
});
|
|
8559
8420
|
});
|
|
@@ -8594,8 +8455,8 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
8594
8455
|
});
|
|
8595
8456
|
|
|
8596
8457
|
_defineProperty(this, "reload", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
8597
|
-
var
|
|
8598
|
-
|
|
8458
|
+
var _ref9,
|
|
8459
|
+
_ref9$force,
|
|
8599
8460
|
force,
|
|
8600
8461
|
_this$state$getLatest3,
|
|
8601
8462
|
threads,
|
|
@@ -8617,7 +8478,7 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
8617
8478
|
while (1) {
|
|
8618
8479
|
switch (_context.prev = _context.next) {
|
|
8619
8480
|
case 0:
|
|
8620
|
-
|
|
8481
|
+
_ref9 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, _ref9$force = _ref9.force, force = _ref9$force === void 0 ? false : _ref9$force;
|
|
8621
8482
|
_this$state$getLatest3 = _this.state.getLatestValue(), threads = _this$state$getLatest3.threads, unseenThreadIds = _this$state$getLatest3.unseenThreadIds, isThreadOrderStale = _this$state$getLatest3.isThreadOrderStale, pagination = _this$state$getLatest3.pagination, ready = _this$state$getLatest3.ready;
|
|
8622
8483
|
|
|
8623
8484
|
if (!pagination.isLoading) {
|
|
@@ -8640,213 +8501,1219 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
8640
8501
|
_context.prev = 7;
|
|
8641
8502
|
|
|
8642
8503
|
_this.state.next(function (current) {
|
|
8643
|
-
return _objectSpread$
|
|
8644
|
-
pagination: _objectSpread$
|
|
8504
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8505
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
8645
8506
|
isLoading: true
|
|
8646
8507
|
})
|
|
8647
8508
|
});
|
|
8648
8509
|
});
|
|
8649
8510
|
|
|
8650
|
-
_context.next = 11;
|
|
8651
|
-
return _this.queryThreads({
|
|
8652
|
-
limit: Math.min(limit, MAX_QUERY_THREADS_LIMIT) || MAX_QUERY_THREADS_LIMIT
|
|
8653
|
-
});
|
|
8511
|
+
_context.next = 11;
|
|
8512
|
+
return _this.queryThreads({
|
|
8513
|
+
limit: Math.min(limit, MAX_QUERY_THREADS_LIMIT) || MAX_QUERY_THREADS_LIMIT
|
|
8514
|
+
});
|
|
8515
|
+
|
|
8516
|
+
case 11:
|
|
8517
|
+
response = _context.sent;
|
|
8518
|
+
currentThreads = _this.threadsById;
|
|
8519
|
+
nextThreads = [];
|
|
8520
|
+
_iterator = _createForOfIteratorHelper$2(response.threads);
|
|
8521
|
+
|
|
8522
|
+
try {
|
|
8523
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
8524
|
+
incomingThread = _step.value;
|
|
8525
|
+
existingThread = currentThreads[incomingThread.id];
|
|
8526
|
+
|
|
8527
|
+
if (existingThread) {
|
|
8528
|
+
// Reuse thread instances if possible
|
|
8529
|
+
nextThreads.push(existingThread);
|
|
8530
|
+
|
|
8531
|
+
if (existingThread.hasStaleState) {
|
|
8532
|
+
existingThread.hydrateState(incomingThread);
|
|
8533
|
+
}
|
|
8534
|
+
} else {
|
|
8535
|
+
nextThreads.push(incomingThread);
|
|
8536
|
+
}
|
|
8537
|
+
}
|
|
8538
|
+
} catch (err) {
|
|
8539
|
+
_iterator.e(err);
|
|
8540
|
+
} finally {
|
|
8541
|
+
_iterator.f();
|
|
8542
|
+
}
|
|
8543
|
+
|
|
8544
|
+
_this.state.next(function (current) {
|
|
8545
|
+
var _response$next;
|
|
8546
|
+
|
|
8547
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8548
|
+
threads: nextThreads,
|
|
8549
|
+
unseenThreadIds: [],
|
|
8550
|
+
isThreadOrderStale: false,
|
|
8551
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
8552
|
+
isLoading: false,
|
|
8553
|
+
nextCursor: (_response$next = response.next) !== null && _response$next !== void 0 ? _response$next : null
|
|
8554
|
+
}),
|
|
8555
|
+
ready: true
|
|
8556
|
+
});
|
|
8557
|
+
});
|
|
8558
|
+
|
|
8559
|
+
_context.next = 23;
|
|
8560
|
+
break;
|
|
8561
|
+
|
|
8562
|
+
case 19:
|
|
8563
|
+
_context.prev = 19;
|
|
8564
|
+
_context.t0 = _context["catch"](7);
|
|
8565
|
+
|
|
8566
|
+
_this.client.logger('error', _context.t0.message);
|
|
8567
|
+
|
|
8568
|
+
_this.state.next(function (current) {
|
|
8569
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8570
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
8571
|
+
isLoading: false
|
|
8572
|
+
})
|
|
8573
|
+
});
|
|
8574
|
+
});
|
|
8575
|
+
|
|
8576
|
+
case 23:
|
|
8577
|
+
case "end":
|
|
8578
|
+
return _context.stop();
|
|
8579
|
+
}
|
|
8580
|
+
}
|
|
8581
|
+
}, _callee, null, [[7, 19]]);
|
|
8582
|
+
})));
|
|
8583
|
+
|
|
8584
|
+
_defineProperty(this, "queryThreads", function () {
|
|
8585
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8586
|
+
return _this.client.queryThreads(_objectSpread$2({
|
|
8587
|
+
limit: 25,
|
|
8588
|
+
participant_limit: 10,
|
|
8589
|
+
reply_limit: 10,
|
|
8590
|
+
watch: true
|
|
8591
|
+
}, options));
|
|
8592
|
+
});
|
|
8593
|
+
|
|
8594
|
+
_defineProperty(this, "loadNextPage", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
8595
|
+
var options,
|
|
8596
|
+
_this$state$getLatest4,
|
|
8597
|
+
pagination,
|
|
8598
|
+
response,
|
|
8599
|
+
_args2 = arguments;
|
|
8600
|
+
|
|
8601
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
8602
|
+
while (1) {
|
|
8603
|
+
switch (_context2.prev = _context2.next) {
|
|
8604
|
+
case 0:
|
|
8605
|
+
options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
8606
|
+
_this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
|
|
8607
|
+
|
|
8608
|
+
if (!(pagination.isLoadingNext || !pagination.nextCursor)) {
|
|
8609
|
+
_context2.next = 4;
|
|
8610
|
+
break;
|
|
8611
|
+
}
|
|
8612
|
+
|
|
8613
|
+
return _context2.abrupt("return");
|
|
8614
|
+
|
|
8615
|
+
case 4:
|
|
8616
|
+
_context2.prev = 4;
|
|
8617
|
+
|
|
8618
|
+
_this.state.partialNext({
|
|
8619
|
+
pagination: _objectSpread$2(_objectSpread$2({}, pagination), {}, {
|
|
8620
|
+
isLoadingNext: true
|
|
8621
|
+
})
|
|
8622
|
+
});
|
|
8623
|
+
|
|
8624
|
+
_context2.next = 8;
|
|
8625
|
+
return _this.queryThreads(_objectSpread$2(_objectSpread$2({}, options), {}, {
|
|
8626
|
+
next: pagination.nextCursor
|
|
8627
|
+
}));
|
|
8628
|
+
|
|
8629
|
+
case 8:
|
|
8630
|
+
response = _context2.sent;
|
|
8631
|
+
|
|
8632
|
+
_this.state.next(function (current) {
|
|
8633
|
+
var _response$next2;
|
|
8634
|
+
|
|
8635
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8636
|
+
threads: response.threads.length ? current.threads.concat(response.threads) : current.threads,
|
|
8637
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
8638
|
+
nextCursor: (_response$next2 = response.next) !== null && _response$next2 !== void 0 ? _response$next2 : null,
|
|
8639
|
+
isLoadingNext: false
|
|
8640
|
+
})
|
|
8641
|
+
});
|
|
8642
|
+
});
|
|
8643
|
+
|
|
8644
|
+
_context2.next = 16;
|
|
8645
|
+
break;
|
|
8646
|
+
|
|
8647
|
+
case 12:
|
|
8648
|
+
_context2.prev = 12;
|
|
8649
|
+
_context2.t0 = _context2["catch"](4);
|
|
8650
|
+
|
|
8651
|
+
_this.client.logger('error', _context2.t0.message);
|
|
8652
|
+
|
|
8653
|
+
_this.state.next(function (current) {
|
|
8654
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8655
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
8656
|
+
isLoadingNext: false
|
|
8657
|
+
})
|
|
8658
|
+
});
|
|
8659
|
+
});
|
|
8660
|
+
|
|
8661
|
+
case 16:
|
|
8662
|
+
case "end":
|
|
8663
|
+
return _context2.stop();
|
|
8664
|
+
}
|
|
8665
|
+
}
|
|
8666
|
+
}, _callee2, null, [[4, 12]]);
|
|
8667
|
+
})));
|
|
8668
|
+
|
|
8669
|
+
this.client = client;
|
|
8670
|
+
this.state = new StateStore({
|
|
8671
|
+
active: false,
|
|
8672
|
+
isThreadOrderStale: false,
|
|
8673
|
+
threads: [],
|
|
8674
|
+
unreadThreadCount: 0,
|
|
8675
|
+
unseenThreadIds: [],
|
|
8676
|
+
lastConnectionDropAt: null,
|
|
8677
|
+
pagination: {
|
|
8678
|
+
isLoading: false,
|
|
8679
|
+
isLoadingNext: false,
|
|
8680
|
+
nextCursor: null
|
|
8681
|
+
},
|
|
8682
|
+
ready: false
|
|
8683
|
+
});
|
|
8684
|
+
this.threadsByIdGetterCache = {
|
|
8685
|
+
threads: [],
|
|
8686
|
+
threadsById: {}
|
|
8687
|
+
};
|
|
8688
|
+
}
|
|
8689
|
+
|
|
8690
|
+
_createClass(ThreadManager, [{
|
|
8691
|
+
key: "threadsById",
|
|
8692
|
+
get: function get() {
|
|
8693
|
+
var _this$state$getLatest5 = this.state.getLatestValue(),
|
|
8694
|
+
threads = _this$state$getLatest5.threads;
|
|
8695
|
+
|
|
8696
|
+
if (threads === this.threadsByIdGetterCache.threads) {
|
|
8697
|
+
return this.threadsByIdGetterCache.threadsById;
|
|
8698
|
+
}
|
|
8699
|
+
|
|
8700
|
+
var threadsById = threads.reduce(function (newThreadsById, thread) {
|
|
8701
|
+
newThreadsById[thread.id] = thread;
|
|
8702
|
+
return newThreadsById;
|
|
8703
|
+
}, {});
|
|
8704
|
+
this.threadsByIdGetterCache.threads = threads;
|
|
8705
|
+
this.threadsByIdGetterCache.threadsById = threadsById;
|
|
8706
|
+
return threadsById;
|
|
8707
|
+
}
|
|
8708
|
+
}]);
|
|
8709
|
+
|
|
8710
|
+
return ThreadManager;
|
|
8711
|
+
}();
|
|
8712
|
+
|
|
8713
|
+
var _excluded$1 = ["own_votes", "id"],
|
|
8714
|
+
_excluded2$1 = ["id"];
|
|
8715
|
+
|
|
8716
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
8717
|
+
|
|
8718
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8719
|
+
|
|
8720
|
+
var isPollUpdatedEvent = function isPollUpdatedEvent(e) {
|
|
8721
|
+
return e.type === 'poll.updated';
|
|
8722
|
+
};
|
|
8723
|
+
|
|
8724
|
+
var isPollClosedEventEvent = function isPollClosedEventEvent(e) {
|
|
8725
|
+
return e.type === 'poll.closed';
|
|
8726
|
+
};
|
|
8727
|
+
|
|
8728
|
+
var isPollVoteCastedEvent = function isPollVoteCastedEvent(e) {
|
|
8729
|
+
return e.type === 'poll.vote_casted';
|
|
8730
|
+
};
|
|
8731
|
+
|
|
8732
|
+
var isPollVoteChangedEvent = function isPollVoteChangedEvent(e) {
|
|
8733
|
+
return e.type === 'poll.vote_changed';
|
|
8734
|
+
};
|
|
8735
|
+
|
|
8736
|
+
var isPollVoteRemovedEvent = function isPollVoteRemovedEvent(e) {
|
|
8737
|
+
return e.type === 'poll.vote_removed';
|
|
8738
|
+
};
|
|
8739
|
+
|
|
8740
|
+
var isVoteAnswer = function isVoteAnswer(vote) {
|
|
8741
|
+
return !!(vote !== null && vote !== void 0 && vote.answer_text);
|
|
8742
|
+
};
|
|
8743
|
+
var Poll = /*#__PURE__*/function () {
|
|
8744
|
+
function Poll(_ref) {
|
|
8745
|
+
var _this = this;
|
|
8746
|
+
|
|
8747
|
+
var client = _ref.client,
|
|
8748
|
+
_poll = _ref.poll;
|
|
8749
|
+
|
|
8750
|
+
_classCallCheck(this, Poll);
|
|
8751
|
+
|
|
8752
|
+
_defineProperty(this, "state", void 0);
|
|
8753
|
+
|
|
8754
|
+
_defineProperty(this, "id", void 0);
|
|
8755
|
+
|
|
8756
|
+
_defineProperty(this, "client", void 0);
|
|
8757
|
+
|
|
8758
|
+
_defineProperty(this, "unsubscribeFunctions", new Set());
|
|
8759
|
+
|
|
8760
|
+
_defineProperty(this, "getInitialStateFromPollResponse", function (poll) {
|
|
8761
|
+
var _own_votes$reduce;
|
|
8762
|
+
|
|
8763
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8764
|
+
var own_votes = poll.own_votes;
|
|
8765
|
+
poll.id;
|
|
8766
|
+
var pollResponseForState = _objectWithoutProperties(poll, _excluded$1);
|
|
8767
|
+
|
|
8768
|
+
var _ref2 = (_own_votes$reduce = own_votes === null || own_votes === void 0 ? void 0 : own_votes.reduce(function (acc, voteOrAnswer) {
|
|
8769
|
+
if (isVoteAnswer(voteOrAnswer)) {
|
|
8770
|
+
acc.ownAnswer = voteOrAnswer;
|
|
8771
|
+
} else {
|
|
8772
|
+
acc.ownVotes.push(voteOrAnswer);
|
|
8773
|
+
}
|
|
8774
|
+
|
|
8775
|
+
return acc;
|
|
8776
|
+
}, {
|
|
8777
|
+
ownVotes: []
|
|
8778
|
+
})) !== null && _own_votes$reduce !== void 0 ? _own_votes$reduce : {
|
|
8779
|
+
ownVotes: []
|
|
8780
|
+
},
|
|
8781
|
+
ownAnswer = _ref2.ownAnswer,
|
|
8782
|
+
ownVotes = _ref2.ownVotes;
|
|
8783
|
+
|
|
8784
|
+
return _objectSpread$1(_objectSpread$1({}, pollResponseForState), {}, {
|
|
8785
|
+
lastActivityAt: new Date(),
|
|
8786
|
+
maxVotedOptionIds: getMaxVotedOptionIds(pollResponseForState.vote_counts_by_option),
|
|
8787
|
+
ownAnswer: ownAnswer,
|
|
8788
|
+
ownVotesByOptionId: getOwnVotesByOptionId(ownVotes)
|
|
8789
|
+
});
|
|
8790
|
+
});
|
|
8791
|
+
|
|
8792
|
+
_defineProperty(this, "reinitializeState", function (poll) {
|
|
8793
|
+
_this.state.partialNext(_this.getInitialStateFromPollResponse(poll));
|
|
8794
|
+
});
|
|
8795
|
+
|
|
8796
|
+
_defineProperty(this, "handlePollUpdated", function (event) {
|
|
8797
|
+
var _event$poll;
|
|
8798
|
+
|
|
8799
|
+
if ((_event$poll = event.poll) !== null && _event$poll !== void 0 && _event$poll.id && event.poll.id !== _this.id) return;
|
|
8800
|
+
if (!isPollUpdatedEvent(event)) return; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8801
|
+
|
|
8802
|
+
var _extractPollData = extractPollData(event.poll),
|
|
8803
|
+
pollData = _objectWithoutProperties(_extractPollData, _excluded2$1); // @ts-ignore
|
|
8804
|
+
|
|
8805
|
+
|
|
8806
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, pollData), {}, {
|
|
8807
|
+
lastActivityAt: new Date(event.created_at)
|
|
8808
|
+
}));
|
|
8809
|
+
});
|
|
8810
|
+
|
|
8811
|
+
_defineProperty(this, "handlePollClosed", function (event) {
|
|
8812
|
+
var _event$poll2;
|
|
8813
|
+
|
|
8814
|
+
if ((_event$poll2 = event.poll) !== null && _event$poll2 !== void 0 && _event$poll2.id && event.poll.id !== _this.id) return;
|
|
8815
|
+
if (!isPollClosedEventEvent(event)) return; // @ts-ignore
|
|
8816
|
+
|
|
8817
|
+
_this.state.partialNext({
|
|
8818
|
+
is_closed: true,
|
|
8819
|
+
lastActivityAt: new Date(event.created_at)
|
|
8820
|
+
});
|
|
8821
|
+
});
|
|
8822
|
+
|
|
8823
|
+
_defineProperty(this, "handleVoteCasted", function (event) {
|
|
8824
|
+
var _event$poll3;
|
|
8825
|
+
|
|
8826
|
+
if ((_event$poll3 = event.poll) !== null && _event$poll3 !== void 0 && _event$poll3.id && event.poll.id !== _this.id) return;
|
|
8827
|
+
if (!isPollVoteCastedEvent(event)) return;
|
|
8828
|
+
var currentState = _this.data;
|
|
8829
|
+
var isOwnVote = event.poll_vote.user_id === _this.client.userID;
|
|
8830
|
+
|
|
8831
|
+
var latestAnswers = _toConsumableArray(currentState.latest_answers);
|
|
8832
|
+
|
|
8833
|
+
var ownAnswer = currentState.ownAnswer;
|
|
8834
|
+
var ownVotesByOptionId = currentState.ownVotesByOptionId;
|
|
8835
|
+
var maxVotedOptionIds = currentState.maxVotedOptionIds;
|
|
8836
|
+
|
|
8837
|
+
if (isOwnVote) {
|
|
8838
|
+
if (isVoteAnswer(event.poll_vote)) {
|
|
8839
|
+
ownAnswer = event.poll_vote;
|
|
8840
|
+
} else if (event.poll_vote.option_id) {
|
|
8841
|
+
ownVotesByOptionId[event.poll_vote.option_id] = event.poll_vote;
|
|
8842
|
+
}
|
|
8843
|
+
}
|
|
8844
|
+
|
|
8845
|
+
if (isVoteAnswer(event.poll_vote)) {
|
|
8846
|
+
latestAnswers = [event.poll_vote].concat(_toConsumableArray(latestAnswers));
|
|
8847
|
+
} else {
|
|
8848
|
+
maxVotedOptionIds = getMaxVotedOptionIds(event.poll.vote_counts_by_option);
|
|
8849
|
+
}
|
|
8850
|
+
|
|
8851
|
+
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
8852
|
+
|
|
8853
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, pollEnrichData), {}, {
|
|
8854
|
+
latest_answers: latestAnswers,
|
|
8855
|
+
lastActivityAt: new Date(event.created_at),
|
|
8856
|
+
ownAnswer: ownAnswer,
|
|
8857
|
+
ownVotesByOptionId: ownVotesByOptionId,
|
|
8858
|
+
maxVotedOptionIds: maxVotedOptionIds
|
|
8859
|
+
}));
|
|
8860
|
+
});
|
|
8861
|
+
|
|
8862
|
+
_defineProperty(this, "handleVoteChanged", function (event) {
|
|
8863
|
+
var _event$poll4;
|
|
8864
|
+
|
|
8865
|
+
// this event is triggered only when event.poll.enforce_unique_vote === true
|
|
8866
|
+
if ((_event$poll4 = event.poll) !== null && _event$poll4 !== void 0 && _event$poll4.id && event.poll.id !== _this.id) return;
|
|
8867
|
+
if (!isPollVoteChangedEvent(event)) return;
|
|
8868
|
+
var currentState = _this.data;
|
|
8869
|
+
var isOwnVote = event.poll_vote.user_id === _this.client.userID;
|
|
8870
|
+
|
|
8871
|
+
var latestAnswers = _toConsumableArray(currentState.latest_answers);
|
|
8872
|
+
|
|
8873
|
+
var ownAnswer = currentState.ownAnswer;
|
|
8874
|
+
var ownVotesByOptionId = currentState.ownVotesByOptionId;
|
|
8875
|
+
var maxVotedOptionIds = currentState.maxVotedOptionIds;
|
|
8876
|
+
|
|
8877
|
+
if (isOwnVote) {
|
|
8878
|
+
if (isVoteAnswer(event.poll_vote)) {
|
|
8879
|
+
latestAnswers = [event.poll_vote].concat(_toConsumableArray(latestAnswers.filter(function (answer) {
|
|
8880
|
+
return answer.id !== event.poll_vote.id;
|
|
8881
|
+
})));
|
|
8882
|
+
ownAnswer = event.poll_vote;
|
|
8883
|
+
} else if (event.poll_vote.option_id) {
|
|
8884
|
+
var _ownAnswer;
|
|
8885
|
+
|
|
8886
|
+
if (event.poll.enforce_unique_votes) {
|
|
8887
|
+
ownVotesByOptionId = _defineProperty({}, event.poll_vote.option_id, event.poll_vote);
|
|
8888
|
+
} else {
|
|
8889
|
+
ownVotesByOptionId = Object.entries(ownVotesByOptionId).reduce(function (acc, _ref3) {
|
|
8890
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
8891
|
+
optionId = _ref4[0],
|
|
8892
|
+
vote = _ref4[1];
|
|
8893
|
+
|
|
8894
|
+
if (optionId !== event.poll_vote.option_id && vote.id === event.poll_vote.id) {
|
|
8895
|
+
return acc;
|
|
8896
|
+
}
|
|
8897
|
+
|
|
8898
|
+
acc[optionId] = vote;
|
|
8899
|
+
return acc;
|
|
8900
|
+
}, {});
|
|
8901
|
+
ownVotesByOptionId[event.poll_vote.option_id] = event.poll_vote;
|
|
8902
|
+
}
|
|
8903
|
+
|
|
8904
|
+
if (((_ownAnswer = ownAnswer) === null || _ownAnswer === void 0 ? void 0 : _ownAnswer.id) === event.poll_vote.id) {
|
|
8905
|
+
ownAnswer = undefined;
|
|
8906
|
+
}
|
|
8907
|
+
|
|
8908
|
+
maxVotedOptionIds = getMaxVotedOptionIds(event.poll.vote_counts_by_option);
|
|
8909
|
+
}
|
|
8910
|
+
} else if (isVoteAnswer(event.poll_vote)) {
|
|
8911
|
+
latestAnswers = [event.poll_vote].concat(_toConsumableArray(latestAnswers));
|
|
8912
|
+
} else {
|
|
8913
|
+
maxVotedOptionIds = getMaxVotedOptionIds(event.poll.vote_counts_by_option);
|
|
8914
|
+
}
|
|
8915
|
+
|
|
8916
|
+
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
8917
|
+
|
|
8918
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, pollEnrichData), {}, {
|
|
8919
|
+
latest_answers: latestAnswers,
|
|
8920
|
+
lastActivityAt: new Date(event.created_at),
|
|
8921
|
+
ownAnswer: ownAnswer,
|
|
8922
|
+
ownVotesByOptionId: ownVotesByOptionId,
|
|
8923
|
+
maxVotedOptionIds: maxVotedOptionIds
|
|
8924
|
+
}));
|
|
8925
|
+
});
|
|
8926
|
+
|
|
8927
|
+
_defineProperty(this, "handleVoteRemoved", function (event) {
|
|
8928
|
+
var _event$poll5;
|
|
8929
|
+
|
|
8930
|
+
if ((_event$poll5 = event.poll) !== null && _event$poll5 !== void 0 && _event$poll5.id && event.poll.id !== _this.id) return;
|
|
8931
|
+
if (!isPollVoteRemovedEvent(event)) return;
|
|
8932
|
+
var currentState = _this.data;
|
|
8933
|
+
var isOwnVote = event.poll_vote.user_id === _this.client.userID;
|
|
8934
|
+
|
|
8935
|
+
var latestAnswers = _toConsumableArray(currentState.latest_answers);
|
|
8936
|
+
|
|
8937
|
+
var ownAnswer = currentState.ownAnswer;
|
|
8938
|
+
|
|
8939
|
+
var ownVotesByOptionId = _objectSpread$1({}, currentState.ownVotesByOptionId);
|
|
8940
|
+
|
|
8941
|
+
var maxVotedOptionIds = currentState.maxVotedOptionIds;
|
|
8942
|
+
|
|
8943
|
+
if (isVoteAnswer(event.poll_vote)) {
|
|
8944
|
+
latestAnswers = latestAnswers.filter(function (answer) {
|
|
8945
|
+
return answer.id !== event.poll_vote.id;
|
|
8946
|
+
});
|
|
8947
|
+
|
|
8948
|
+
if (isOwnVote) {
|
|
8949
|
+
ownAnswer = undefined;
|
|
8950
|
+
}
|
|
8951
|
+
} else {
|
|
8952
|
+
maxVotedOptionIds = getMaxVotedOptionIds(event.poll.vote_counts_by_option);
|
|
8953
|
+
|
|
8954
|
+
if (isOwnVote && event.poll_vote.option_id) {
|
|
8955
|
+
delete ownVotesByOptionId[event.poll_vote.option_id];
|
|
8956
|
+
}
|
|
8957
|
+
}
|
|
8958
|
+
|
|
8959
|
+
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
8960
|
+
|
|
8961
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, pollEnrichData), {}, {
|
|
8962
|
+
latest_answers: latestAnswers,
|
|
8963
|
+
lastActivityAt: new Date(event.created_at),
|
|
8964
|
+
ownAnswer: ownAnswer,
|
|
8965
|
+
ownVotesByOptionId: ownVotesByOptionId,
|
|
8966
|
+
maxVotedOptionIds: maxVotedOptionIds
|
|
8967
|
+
}));
|
|
8968
|
+
});
|
|
8969
|
+
|
|
8970
|
+
_defineProperty(this, "query", /*#__PURE__*/function () {
|
|
8971
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id) {
|
|
8972
|
+
var _yield$_this$client$g, poll;
|
|
8973
|
+
|
|
8974
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
8975
|
+
while (1) {
|
|
8976
|
+
switch (_context.prev = _context.next) {
|
|
8977
|
+
case 0:
|
|
8978
|
+
_context.next = 2;
|
|
8979
|
+
return _this.client.getPoll(id);
|
|
8980
|
+
|
|
8981
|
+
case 2:
|
|
8982
|
+
_yield$_this$client$g = _context.sent;
|
|
8983
|
+
poll = _yield$_this$client$g.poll;
|
|
8984
|
+
|
|
8985
|
+
// @ts-ignore
|
|
8986
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, poll), {}, {
|
|
8987
|
+
lastActivityAt: new Date()
|
|
8988
|
+
}));
|
|
8989
|
+
|
|
8990
|
+
return _context.abrupt("return", poll);
|
|
8991
|
+
|
|
8992
|
+
case 6:
|
|
8993
|
+
case "end":
|
|
8994
|
+
return _context.stop();
|
|
8995
|
+
}
|
|
8996
|
+
}
|
|
8997
|
+
}, _callee);
|
|
8998
|
+
}));
|
|
8999
|
+
|
|
9000
|
+
return function (_x) {
|
|
9001
|
+
return _ref5.apply(this, arguments);
|
|
9002
|
+
};
|
|
9003
|
+
}());
|
|
9004
|
+
|
|
9005
|
+
_defineProperty(this, "update", /*#__PURE__*/function () {
|
|
9006
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
|
|
9007
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
9008
|
+
while (1) {
|
|
9009
|
+
switch (_context2.prev = _context2.next) {
|
|
9010
|
+
case 0:
|
|
9011
|
+
_context2.next = 2;
|
|
9012
|
+
return _this.client.updatePoll(_objectSpread$1(_objectSpread$1({}, data), {}, {
|
|
9013
|
+
id: _this.id
|
|
9014
|
+
}));
|
|
9015
|
+
|
|
9016
|
+
case 2:
|
|
9017
|
+
return _context2.abrupt("return", _context2.sent);
|
|
9018
|
+
|
|
9019
|
+
case 3:
|
|
9020
|
+
case "end":
|
|
9021
|
+
return _context2.stop();
|
|
9022
|
+
}
|
|
9023
|
+
}
|
|
9024
|
+
}, _callee2);
|
|
9025
|
+
}));
|
|
9026
|
+
|
|
9027
|
+
return function (_x2) {
|
|
9028
|
+
return _ref6.apply(this, arguments);
|
|
9029
|
+
};
|
|
9030
|
+
}());
|
|
9031
|
+
|
|
9032
|
+
_defineProperty(this, "partialUpdate", /*#__PURE__*/function () {
|
|
9033
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(partialPollObject) {
|
|
9034
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
9035
|
+
while (1) {
|
|
9036
|
+
switch (_context3.prev = _context3.next) {
|
|
9037
|
+
case 0:
|
|
9038
|
+
_context3.next = 2;
|
|
9039
|
+
return _this.client.partialUpdatePoll(_this.id, partialPollObject);
|
|
9040
|
+
|
|
9041
|
+
case 2:
|
|
9042
|
+
return _context3.abrupt("return", _context3.sent);
|
|
9043
|
+
|
|
9044
|
+
case 3:
|
|
9045
|
+
case "end":
|
|
9046
|
+
return _context3.stop();
|
|
9047
|
+
}
|
|
9048
|
+
}
|
|
9049
|
+
}, _callee3);
|
|
9050
|
+
}));
|
|
9051
|
+
|
|
9052
|
+
return function (_x3) {
|
|
9053
|
+
return _ref7.apply(this, arguments);
|
|
9054
|
+
};
|
|
9055
|
+
}());
|
|
9056
|
+
|
|
9057
|
+
_defineProperty(this, "close", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
9058
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
9059
|
+
while (1) {
|
|
9060
|
+
switch (_context4.prev = _context4.next) {
|
|
9061
|
+
case 0:
|
|
9062
|
+
_context4.next = 2;
|
|
9063
|
+
return _this.client.closePoll(_this.id);
|
|
9064
|
+
|
|
9065
|
+
case 2:
|
|
9066
|
+
return _context4.abrupt("return", _context4.sent);
|
|
9067
|
+
|
|
9068
|
+
case 3:
|
|
9069
|
+
case "end":
|
|
9070
|
+
return _context4.stop();
|
|
9071
|
+
}
|
|
9072
|
+
}
|
|
9073
|
+
}, _callee4);
|
|
9074
|
+
})));
|
|
9075
|
+
|
|
9076
|
+
_defineProperty(this, "delete", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
9077
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
9078
|
+
while (1) {
|
|
9079
|
+
switch (_context5.prev = _context5.next) {
|
|
9080
|
+
case 0:
|
|
9081
|
+
_context5.next = 2;
|
|
9082
|
+
return _this.client.deletePoll(_this.id);
|
|
9083
|
+
|
|
9084
|
+
case 2:
|
|
9085
|
+
return _context5.abrupt("return", _context5.sent);
|
|
9086
|
+
|
|
9087
|
+
case 3:
|
|
9088
|
+
case "end":
|
|
9089
|
+
return _context5.stop();
|
|
9090
|
+
}
|
|
9091
|
+
}
|
|
9092
|
+
}, _callee5);
|
|
9093
|
+
})));
|
|
9094
|
+
|
|
9095
|
+
_defineProperty(this, "createOption", /*#__PURE__*/function () {
|
|
9096
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(option) {
|
|
9097
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
9098
|
+
while (1) {
|
|
9099
|
+
switch (_context6.prev = _context6.next) {
|
|
9100
|
+
case 0:
|
|
9101
|
+
_context6.next = 2;
|
|
9102
|
+
return _this.client.createPollOption(_this.id, option);
|
|
9103
|
+
|
|
9104
|
+
case 2:
|
|
9105
|
+
return _context6.abrupt("return", _context6.sent);
|
|
9106
|
+
|
|
9107
|
+
case 3:
|
|
9108
|
+
case "end":
|
|
9109
|
+
return _context6.stop();
|
|
9110
|
+
}
|
|
9111
|
+
}
|
|
9112
|
+
}, _callee6);
|
|
9113
|
+
}));
|
|
9114
|
+
|
|
9115
|
+
return function (_x4) {
|
|
9116
|
+
return _ref10.apply(this, arguments);
|
|
9117
|
+
};
|
|
9118
|
+
}());
|
|
9119
|
+
|
|
9120
|
+
_defineProperty(this, "updateOption", /*#__PURE__*/function () {
|
|
9121
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(option) {
|
|
9122
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
9123
|
+
while (1) {
|
|
9124
|
+
switch (_context7.prev = _context7.next) {
|
|
9125
|
+
case 0:
|
|
9126
|
+
_context7.next = 2;
|
|
9127
|
+
return _this.client.updatePollOption(_this.id, option);
|
|
9128
|
+
|
|
9129
|
+
case 2:
|
|
9130
|
+
return _context7.abrupt("return", _context7.sent);
|
|
9131
|
+
|
|
9132
|
+
case 3:
|
|
9133
|
+
case "end":
|
|
9134
|
+
return _context7.stop();
|
|
9135
|
+
}
|
|
9136
|
+
}
|
|
9137
|
+
}, _callee7);
|
|
9138
|
+
}));
|
|
9139
|
+
|
|
9140
|
+
return function (_x5) {
|
|
9141
|
+
return _ref11.apply(this, arguments);
|
|
9142
|
+
};
|
|
9143
|
+
}());
|
|
9144
|
+
|
|
9145
|
+
_defineProperty(this, "deleteOption", /*#__PURE__*/function () {
|
|
9146
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(optionId) {
|
|
9147
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
9148
|
+
while (1) {
|
|
9149
|
+
switch (_context8.prev = _context8.next) {
|
|
9150
|
+
case 0:
|
|
9151
|
+
_context8.next = 2;
|
|
9152
|
+
return _this.client.deletePollOption(_this.id, optionId);
|
|
9153
|
+
|
|
9154
|
+
case 2:
|
|
9155
|
+
return _context8.abrupt("return", _context8.sent);
|
|
9156
|
+
|
|
9157
|
+
case 3:
|
|
9158
|
+
case "end":
|
|
9159
|
+
return _context8.stop();
|
|
9160
|
+
}
|
|
9161
|
+
}
|
|
9162
|
+
}, _callee8);
|
|
9163
|
+
}));
|
|
9164
|
+
|
|
9165
|
+
return function (_x6) {
|
|
9166
|
+
return _ref12.apply(this, arguments);
|
|
9167
|
+
};
|
|
9168
|
+
}());
|
|
9169
|
+
|
|
9170
|
+
_defineProperty(this, "castVote", /*#__PURE__*/function () {
|
|
9171
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(optionId, messageId) {
|
|
9172
|
+
var _this$data, max_votes_allowed, ownVotesByOptionId, reachedVoteLimit, _oldestVote2, oldestVote;
|
|
9173
|
+
|
|
9174
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
9175
|
+
while (1) {
|
|
9176
|
+
switch (_context9.prev = _context9.next) {
|
|
9177
|
+
case 0:
|
|
9178
|
+
_this$data = _this.data, max_votes_allowed = _this$data.max_votes_allowed, ownVotesByOptionId = _this$data.ownVotesByOptionId;
|
|
9179
|
+
reachedVoteLimit = max_votes_allowed && max_votes_allowed === Object.keys(ownVotesByOptionId).length;
|
|
9180
|
+
|
|
9181
|
+
if (!reachedVoteLimit) {
|
|
9182
|
+
_context9.next = 8;
|
|
9183
|
+
break;
|
|
9184
|
+
}
|
|
9185
|
+
|
|
9186
|
+
oldestVote = Object.values(ownVotesByOptionId)[0];
|
|
9187
|
+
Object.values(ownVotesByOptionId).slice(1).forEach(function (vote) {
|
|
9188
|
+
var _oldestVote;
|
|
9189
|
+
|
|
9190
|
+
if (!((_oldestVote = oldestVote) !== null && _oldestVote !== void 0 && _oldestVote.created_at) || new Date(vote.created_at) < new Date(oldestVote.created_at)) {
|
|
9191
|
+
oldestVote = vote;
|
|
9192
|
+
}
|
|
9193
|
+
});
|
|
9194
|
+
|
|
9195
|
+
if (!((_oldestVote2 = oldestVote) !== null && _oldestVote2 !== void 0 && _oldestVote2.id)) {
|
|
9196
|
+
_context9.next = 8;
|
|
9197
|
+
break;
|
|
9198
|
+
}
|
|
9199
|
+
|
|
9200
|
+
_context9.next = 8;
|
|
9201
|
+
return _this.removeVote(oldestVote.id, messageId);
|
|
9202
|
+
|
|
9203
|
+
case 8:
|
|
9204
|
+
_context9.next = 10;
|
|
9205
|
+
return _this.client.castPollVote(messageId, _this.id, {
|
|
9206
|
+
option_id: optionId
|
|
9207
|
+
});
|
|
9208
|
+
|
|
9209
|
+
case 10:
|
|
9210
|
+
return _context9.abrupt("return", _context9.sent);
|
|
9211
|
+
|
|
9212
|
+
case 11:
|
|
9213
|
+
case "end":
|
|
9214
|
+
return _context9.stop();
|
|
9215
|
+
}
|
|
9216
|
+
}
|
|
9217
|
+
}, _callee9);
|
|
9218
|
+
}));
|
|
9219
|
+
|
|
9220
|
+
return function (_x7, _x8) {
|
|
9221
|
+
return _ref13.apply(this, arguments);
|
|
9222
|
+
};
|
|
9223
|
+
}());
|
|
9224
|
+
|
|
9225
|
+
_defineProperty(this, "removeVote", /*#__PURE__*/function () {
|
|
9226
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(voteId, messageId) {
|
|
9227
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
9228
|
+
while (1) {
|
|
9229
|
+
switch (_context10.prev = _context10.next) {
|
|
9230
|
+
case 0:
|
|
9231
|
+
_context10.next = 2;
|
|
9232
|
+
return _this.client.removePollVote(messageId, _this.id, voteId);
|
|
9233
|
+
|
|
9234
|
+
case 2:
|
|
9235
|
+
return _context10.abrupt("return", _context10.sent);
|
|
9236
|
+
|
|
9237
|
+
case 3:
|
|
9238
|
+
case "end":
|
|
9239
|
+
return _context10.stop();
|
|
9240
|
+
}
|
|
9241
|
+
}
|
|
9242
|
+
}, _callee10);
|
|
9243
|
+
}));
|
|
9244
|
+
|
|
9245
|
+
return function (_x9, _x10) {
|
|
9246
|
+
return _ref14.apply(this, arguments);
|
|
9247
|
+
};
|
|
9248
|
+
}());
|
|
9249
|
+
|
|
9250
|
+
_defineProperty(this, "addAnswer", /*#__PURE__*/function () {
|
|
9251
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(answerText, messageId) {
|
|
9252
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
9253
|
+
while (1) {
|
|
9254
|
+
switch (_context11.prev = _context11.next) {
|
|
9255
|
+
case 0:
|
|
9256
|
+
_context11.next = 2;
|
|
9257
|
+
return _this.client.addPollAnswer(messageId, _this.id, answerText);
|
|
9258
|
+
|
|
9259
|
+
case 2:
|
|
9260
|
+
return _context11.abrupt("return", _context11.sent);
|
|
9261
|
+
|
|
9262
|
+
case 3:
|
|
9263
|
+
case "end":
|
|
9264
|
+
return _context11.stop();
|
|
9265
|
+
}
|
|
9266
|
+
}
|
|
9267
|
+
}, _callee11);
|
|
9268
|
+
}));
|
|
9269
|
+
|
|
9270
|
+
return function (_x11, _x12) {
|
|
9271
|
+
return _ref15.apply(this, arguments);
|
|
9272
|
+
};
|
|
9273
|
+
}());
|
|
9274
|
+
|
|
9275
|
+
_defineProperty(this, "removeAnswer", /*#__PURE__*/function () {
|
|
9276
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(answerId, messageId) {
|
|
9277
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
9278
|
+
while (1) {
|
|
9279
|
+
switch (_context12.prev = _context12.next) {
|
|
9280
|
+
case 0:
|
|
9281
|
+
_context12.next = 2;
|
|
9282
|
+
return _this.client.removePollVote(messageId, _this.id, answerId);
|
|
9283
|
+
|
|
9284
|
+
case 2:
|
|
9285
|
+
return _context12.abrupt("return", _context12.sent);
|
|
9286
|
+
|
|
9287
|
+
case 3:
|
|
9288
|
+
case "end":
|
|
9289
|
+
return _context12.stop();
|
|
9290
|
+
}
|
|
9291
|
+
}
|
|
9292
|
+
}, _callee12);
|
|
9293
|
+
}));
|
|
9294
|
+
|
|
9295
|
+
return function (_x13, _x14) {
|
|
9296
|
+
return _ref16.apply(this, arguments);
|
|
9297
|
+
};
|
|
9298
|
+
}());
|
|
9299
|
+
|
|
9300
|
+
_defineProperty(this, "queryAnswers", /*#__PURE__*/function () {
|
|
9301
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(params) {
|
|
9302
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
9303
|
+
while (1) {
|
|
9304
|
+
switch (_context13.prev = _context13.next) {
|
|
9305
|
+
case 0:
|
|
9306
|
+
_context13.next = 2;
|
|
9307
|
+
return _this.client.queryPollAnswers(_this.id, params.filter, params.sort, params.options);
|
|
9308
|
+
|
|
9309
|
+
case 2:
|
|
9310
|
+
return _context13.abrupt("return", _context13.sent);
|
|
9311
|
+
|
|
9312
|
+
case 3:
|
|
9313
|
+
case "end":
|
|
9314
|
+
return _context13.stop();
|
|
9315
|
+
}
|
|
9316
|
+
}
|
|
9317
|
+
}, _callee13);
|
|
9318
|
+
}));
|
|
9319
|
+
|
|
9320
|
+
return function (_x15) {
|
|
9321
|
+
return _ref17.apply(this, arguments);
|
|
9322
|
+
};
|
|
9323
|
+
}());
|
|
9324
|
+
|
|
9325
|
+
_defineProperty(this, "queryOptionVotes", /*#__PURE__*/function () {
|
|
9326
|
+
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(params) {
|
|
9327
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
9328
|
+
while (1) {
|
|
9329
|
+
switch (_context14.prev = _context14.next) {
|
|
9330
|
+
case 0:
|
|
9331
|
+
_context14.next = 2;
|
|
9332
|
+
return _this.client.queryPollVotes(_this.id, params.filter, params.sort, params.options);
|
|
9333
|
+
|
|
9334
|
+
case 2:
|
|
9335
|
+
return _context14.abrupt("return", _context14.sent);
|
|
9336
|
+
|
|
9337
|
+
case 3:
|
|
9338
|
+
case "end":
|
|
9339
|
+
return _context14.stop();
|
|
9340
|
+
}
|
|
9341
|
+
}
|
|
9342
|
+
}, _callee14);
|
|
9343
|
+
}));
|
|
9344
|
+
|
|
9345
|
+
return function (_x16) {
|
|
9346
|
+
return _ref18.apply(this, arguments);
|
|
9347
|
+
};
|
|
9348
|
+
}());
|
|
9349
|
+
|
|
9350
|
+
this.client = client;
|
|
9351
|
+
this.id = _poll.id;
|
|
9352
|
+
this.state = new StateStore(this.getInitialStateFromPollResponse(_poll));
|
|
9353
|
+
}
|
|
9354
|
+
|
|
9355
|
+
_createClass(Poll, [{
|
|
9356
|
+
key: "data",
|
|
9357
|
+
get: function get() {
|
|
9358
|
+
return this.state.getLatestValue();
|
|
9359
|
+
}
|
|
9360
|
+
}]);
|
|
9361
|
+
|
|
9362
|
+
return Poll;
|
|
9363
|
+
}();
|
|
9364
|
+
|
|
9365
|
+
function getMaxVotedOptionIds(voteCountsByOption) {
|
|
9366
|
+
var maxVotes = 0;
|
|
9367
|
+
var winningOptions = [];
|
|
9368
|
+
|
|
9369
|
+
for (var _i = 0, _Object$entries = Object.entries(voteCountsByOption !== null && voteCountsByOption !== void 0 ? voteCountsByOption : {}); _i < _Object$entries.length; _i++) {
|
|
9370
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
9371
|
+
id = _Object$entries$_i[0],
|
|
9372
|
+
count = _Object$entries$_i[1];
|
|
9373
|
+
|
|
9374
|
+
if (count > maxVotes) {
|
|
9375
|
+
winningOptions = [id];
|
|
9376
|
+
maxVotes = count;
|
|
9377
|
+
} else if (count === maxVotes) {
|
|
9378
|
+
winningOptions.push(id);
|
|
9379
|
+
}
|
|
9380
|
+
}
|
|
9381
|
+
|
|
9382
|
+
return winningOptions;
|
|
9383
|
+
}
|
|
9384
|
+
|
|
9385
|
+
function getOwnVotesByOptionId(ownVotes) {
|
|
9386
|
+
return !ownVotes ? {} : ownVotes.reduce(function (acc, vote) {
|
|
9387
|
+
if (isVoteAnswer(vote) || !vote.option_id) return acc;
|
|
9388
|
+
acc[vote.option_id] = vote;
|
|
9389
|
+
return acc;
|
|
9390
|
+
}, {});
|
|
9391
|
+
}
|
|
9392
|
+
|
|
9393
|
+
function extractPollData(pollResponse) {
|
|
9394
|
+
return {
|
|
9395
|
+
allow_answers: pollResponse.allow_answers,
|
|
9396
|
+
allow_user_suggested_options: pollResponse.allow_user_suggested_options,
|
|
9397
|
+
description: pollResponse.description,
|
|
9398
|
+
enforce_unique_vote: pollResponse.enforce_unique_vote,
|
|
9399
|
+
id: pollResponse.id,
|
|
9400
|
+
is_closed: pollResponse.is_closed,
|
|
9401
|
+
max_votes_allowed: pollResponse.max_votes_allowed,
|
|
9402
|
+
name: pollResponse.name,
|
|
9403
|
+
options: pollResponse.options,
|
|
9404
|
+
voting_visibility: pollResponse.voting_visibility
|
|
9405
|
+
};
|
|
9406
|
+
}
|
|
9407
|
+
function extractPollEnrichedData(pollResponse) {
|
|
9408
|
+
return {
|
|
9409
|
+
answers_count: pollResponse.answers_count,
|
|
9410
|
+
latest_votes_by_option: pollResponse.latest_votes_by_option,
|
|
9411
|
+
vote_count: pollResponse.vote_count,
|
|
9412
|
+
vote_counts_by_option: pollResponse.vote_counts_by_option
|
|
9413
|
+
};
|
|
9414
|
+
}
|
|
9415
|
+
|
|
9416
|
+
function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
9417
|
+
|
|
9418
|
+
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
|
|
9419
|
+
|
|
9420
|
+
function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
9421
|
+
var PollManager = /*#__PURE__*/function () {
|
|
9422
|
+
// The pollCache contains only polls that have been created and sent as messages
|
|
9423
|
+
// (i.e only polls that are coupled with a message, can be voted on and require a
|
|
9424
|
+
// reactive state). It shall work as a basic look-up table for our SDK to be able
|
|
9425
|
+
// to quickly consume poll state that will be reactive even without the polls being
|
|
9426
|
+
// rendered within the UI.
|
|
9427
|
+
function PollManager(_ref) {
|
|
9428
|
+
var _this = this;
|
|
9429
|
+
|
|
9430
|
+
var client = _ref.client;
|
|
9431
|
+
|
|
9432
|
+
_classCallCheck(this, PollManager);
|
|
9433
|
+
|
|
9434
|
+
_defineProperty(this, "client", void 0);
|
|
9435
|
+
|
|
9436
|
+
_defineProperty(this, "pollCache", new Map());
|
|
9437
|
+
|
|
9438
|
+
_defineProperty(this, "unsubscribeFunctions", new Set());
|
|
9439
|
+
|
|
9440
|
+
_defineProperty(this, "fromState", function (id) {
|
|
9441
|
+
return _this.pollCache.get(id);
|
|
9442
|
+
});
|
|
9443
|
+
|
|
9444
|
+
_defineProperty(this, "registerSubscriptions", function () {
|
|
9445
|
+
if (_this.unsubscribeFunctions.size) {
|
|
9446
|
+
// Already listening for events and changes
|
|
9447
|
+
return;
|
|
9448
|
+
}
|
|
9449
|
+
|
|
9450
|
+
_this.unsubscribeFunctions.add(_this.subscribeMessageNew());
|
|
9451
|
+
|
|
9452
|
+
_this.unsubscribeFunctions.add(_this.subscribePollUpdated());
|
|
9453
|
+
|
|
9454
|
+
_this.unsubscribeFunctions.add(_this.subscribePollClosed());
|
|
9455
|
+
|
|
9456
|
+
_this.unsubscribeFunctions.add(_this.subscribeVoteCasted());
|
|
9457
|
+
|
|
9458
|
+
_this.unsubscribeFunctions.add(_this.subscribeVoteChanged());
|
|
9459
|
+
|
|
9460
|
+
_this.unsubscribeFunctions.add(_this.subscribeVoteRemoved());
|
|
9461
|
+
});
|
|
9462
|
+
|
|
9463
|
+
_defineProperty(this, "unregisterSubscriptions", function () {
|
|
9464
|
+
_this.unsubscribeFunctions.forEach(function (cleanupFunction) {
|
|
9465
|
+
return cleanupFunction();
|
|
9466
|
+
});
|
|
9467
|
+
|
|
9468
|
+
_this.unsubscribeFunctions.clear();
|
|
9469
|
+
});
|
|
9470
|
+
|
|
9471
|
+
_defineProperty(this, "createPoll", /*#__PURE__*/function () {
|
|
9472
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(poll) {
|
|
9473
|
+
var _yield$_this$client$c, createdPoll;
|
|
9474
|
+
|
|
9475
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
9476
|
+
while (1) {
|
|
9477
|
+
switch (_context.prev = _context.next) {
|
|
9478
|
+
case 0:
|
|
9479
|
+
_context.next = 2;
|
|
9480
|
+
return _this.client.createPoll(poll);
|
|
9481
|
+
|
|
9482
|
+
case 2:
|
|
9483
|
+
_yield$_this$client$c = _context.sent;
|
|
9484
|
+
createdPoll = _yield$_this$client$c.poll;
|
|
9485
|
+
return _context.abrupt("return", new Poll({
|
|
9486
|
+
client: _this.client,
|
|
9487
|
+
poll: createdPoll
|
|
9488
|
+
}));
|
|
9489
|
+
|
|
9490
|
+
case 5:
|
|
9491
|
+
case "end":
|
|
9492
|
+
return _context.stop();
|
|
9493
|
+
}
|
|
9494
|
+
}
|
|
9495
|
+
}, _callee);
|
|
9496
|
+
}));
|
|
9497
|
+
|
|
9498
|
+
return function (_x) {
|
|
9499
|
+
return _ref2.apply(this, arguments);
|
|
9500
|
+
};
|
|
9501
|
+
}());
|
|
9502
|
+
|
|
9503
|
+
_defineProperty(this, "getPoll", /*#__PURE__*/function () {
|
|
9504
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id) {
|
|
9505
|
+
var cachedPoll, _yield$_this$client$g, poll;
|
|
9506
|
+
|
|
9507
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
9508
|
+
while (1) {
|
|
9509
|
+
switch (_context2.prev = _context2.next) {
|
|
9510
|
+
case 0:
|
|
9511
|
+
cachedPoll = _this.fromState(id); // optimistically return the cached poll if it exists and update in the background
|
|
9512
|
+
|
|
9513
|
+
if (!cachedPoll) {
|
|
9514
|
+
_context2.next = 4;
|
|
9515
|
+
break;
|
|
9516
|
+
}
|
|
9517
|
+
|
|
9518
|
+
_this.client.getPoll(id).then(function (_ref4) {
|
|
9519
|
+
var poll = _ref4.poll;
|
|
9520
|
+
return _this.setOrOverwriteInCache(poll, true);
|
|
9521
|
+
});
|
|
9522
|
+
|
|
9523
|
+
return _context2.abrupt("return", cachedPoll);
|
|
9524
|
+
|
|
9525
|
+
case 4:
|
|
9526
|
+
_context2.next = 6;
|
|
9527
|
+
return _this.client.getPoll(id);
|
|
9528
|
+
|
|
9529
|
+
case 6:
|
|
9530
|
+
_yield$_this$client$g = _context2.sent;
|
|
9531
|
+
poll = _yield$_this$client$g.poll;
|
|
9532
|
+
|
|
9533
|
+
_this.setOrOverwriteInCache(poll);
|
|
9534
|
+
|
|
9535
|
+
return _context2.abrupt("return", _this.fromState(id));
|
|
9536
|
+
|
|
9537
|
+
case 10:
|
|
9538
|
+
case "end":
|
|
9539
|
+
return _context2.stop();
|
|
9540
|
+
}
|
|
9541
|
+
}
|
|
9542
|
+
}, _callee2);
|
|
9543
|
+
}));
|
|
9544
|
+
|
|
9545
|
+
return function (_x2) {
|
|
9546
|
+
return _ref3.apply(this, arguments);
|
|
9547
|
+
};
|
|
9548
|
+
}());
|
|
9549
|
+
|
|
9550
|
+
_defineProperty(this, "queryPolls", /*#__PURE__*/function () {
|
|
9551
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(filter) {
|
|
9552
|
+
var sort,
|
|
9553
|
+
options,
|
|
9554
|
+
_yield$_this$client$q,
|
|
9555
|
+
polls,
|
|
9556
|
+
next,
|
|
9557
|
+
pollInstances,
|
|
9558
|
+
_args3 = arguments;
|
|
9559
|
+
|
|
9560
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
9561
|
+
while (1) {
|
|
9562
|
+
switch (_context3.prev = _context3.next) {
|
|
9563
|
+
case 0:
|
|
9564
|
+
sort = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : [];
|
|
9565
|
+
options = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
|
|
9566
|
+
_context3.next = 4;
|
|
9567
|
+
return _this.client.queryPolls(filter, sort, options);
|
|
9568
|
+
|
|
9569
|
+
case 4:
|
|
9570
|
+
_yield$_this$client$q = _context3.sent;
|
|
9571
|
+
polls = _yield$_this$client$q.polls;
|
|
9572
|
+
next = _yield$_this$client$q.next;
|
|
9573
|
+
pollInstances = polls.map(function (poll) {
|
|
9574
|
+
_this.setOrOverwriteInCache(poll, true);
|
|
9575
|
+
|
|
9576
|
+
return _this.fromState(poll.id);
|
|
9577
|
+
});
|
|
9578
|
+
return _context3.abrupt("return", {
|
|
9579
|
+
polls: pollInstances,
|
|
9580
|
+
next: next
|
|
9581
|
+
});
|
|
9582
|
+
|
|
9583
|
+
case 9:
|
|
9584
|
+
case "end":
|
|
9585
|
+
return _context3.stop();
|
|
9586
|
+
}
|
|
9587
|
+
}
|
|
9588
|
+
}, _callee3);
|
|
9589
|
+
}));
|
|
9590
|
+
|
|
9591
|
+
return function (_x3) {
|
|
9592
|
+
return _ref5.apply(this, arguments);
|
|
9593
|
+
};
|
|
9594
|
+
}());
|
|
8654
9595
|
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
nextThreads = [];
|
|
8659
|
-
_iterator = _createForOfIteratorHelper$1(response.threads);
|
|
9596
|
+
_defineProperty(this, "hydratePollCache", function (messages, overwriteState) {
|
|
9597
|
+
var _iterator = _createForOfIteratorHelper$1(messages),
|
|
9598
|
+
_step;
|
|
8660
9599
|
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
existingThread = currentThreads[incomingThread.id];
|
|
9600
|
+
try {
|
|
9601
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
9602
|
+
var message = _step.value;
|
|
8665
9603
|
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
9604
|
+
if (!message.poll) {
|
|
9605
|
+
continue;
|
|
9606
|
+
}
|
|
8669
9607
|
|
|
8670
|
-
|
|
8671
|
-
existingThread.hydrateState(incomingThread);
|
|
8672
|
-
}
|
|
8673
|
-
} else {
|
|
8674
|
-
nextThreads.push(incomingThread);
|
|
8675
|
-
}
|
|
8676
|
-
}
|
|
8677
|
-
} catch (err) {
|
|
8678
|
-
_iterator.e(err);
|
|
8679
|
-
} finally {
|
|
8680
|
-
_iterator.f();
|
|
8681
|
-
}
|
|
9608
|
+
var pollResponse = message.poll;
|
|
8682
9609
|
|
|
8683
|
-
|
|
8684
|
-
|
|
9610
|
+
_this.setOrOverwriteInCache(pollResponse, overwriteState);
|
|
9611
|
+
}
|
|
9612
|
+
} catch (err) {
|
|
9613
|
+
_iterator.e(err);
|
|
9614
|
+
} finally {
|
|
9615
|
+
_iterator.f();
|
|
9616
|
+
}
|
|
9617
|
+
});
|
|
8685
9618
|
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
unseenThreadIds: [],
|
|
8689
|
-
isThreadOrderStale: false,
|
|
8690
|
-
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8691
|
-
isLoading: false,
|
|
8692
|
-
nextCursor: (_response$next = response.next) !== null && _response$next !== void 0 ? _response$next : null
|
|
8693
|
-
}),
|
|
8694
|
-
ready: true
|
|
8695
|
-
});
|
|
8696
|
-
});
|
|
9619
|
+
_defineProperty(this, "setOrOverwriteInCache", function (pollResponse, overwriteState) {
|
|
9620
|
+
var pollFromCache = _this.fromState(pollResponse.id);
|
|
8697
9621
|
|
|
8698
|
-
|
|
8699
|
-
|
|
9622
|
+
if (!pollFromCache) {
|
|
9623
|
+
var poll = new Poll({
|
|
9624
|
+
client: _this.client,
|
|
9625
|
+
poll: pollResponse
|
|
9626
|
+
});
|
|
8700
9627
|
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
9628
|
+
_this.pollCache.set(poll.id, poll);
|
|
9629
|
+
} else if (overwriteState) {
|
|
9630
|
+
pollFromCache.reinitializeState(pollResponse);
|
|
9631
|
+
}
|
|
9632
|
+
});
|
|
8704
9633
|
|
|
8705
|
-
|
|
9634
|
+
_defineProperty(this, "subscribePollUpdated", function () {
|
|
9635
|
+
return _this.client.on('poll.updated', function (event) {
|
|
9636
|
+
var _event$poll;
|
|
8706
9637
|
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8710
|
-
isLoading: false
|
|
8711
|
-
})
|
|
8712
|
-
});
|
|
8713
|
-
});
|
|
9638
|
+
if ((_event$poll = event.poll) !== null && _event$poll !== void 0 && _event$poll.id) {
|
|
9639
|
+
var _this$fromState;
|
|
8714
9640
|
|
|
8715
|
-
|
|
8716
|
-
case "end":
|
|
8717
|
-
return _context.stop();
|
|
8718
|
-
}
|
|
9641
|
+
(_this$fromState = _this.fromState(event.poll.id)) === null || _this$fromState === void 0 ? void 0 : _this$fromState.handlePollUpdated(event);
|
|
8719
9642
|
}
|
|
8720
|
-
}
|
|
8721
|
-
})));
|
|
8722
|
-
|
|
8723
|
-
_defineProperty(this, "queryThreads", function () {
|
|
8724
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8725
|
-
return _this.client.queryThreads(_objectSpread$1({
|
|
8726
|
-
limit: 25,
|
|
8727
|
-
participant_limit: 10,
|
|
8728
|
-
reply_limit: 10,
|
|
8729
|
-
watch: true
|
|
8730
|
-
}, options));
|
|
9643
|
+
}).unsubscribe;
|
|
8731
9644
|
});
|
|
8732
9645
|
|
|
8733
|
-
_defineProperty(this, "
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
pagination,
|
|
8737
|
-
response,
|
|
8738
|
-
_args2 = arguments;
|
|
9646
|
+
_defineProperty(this, "subscribePollClosed", function () {
|
|
9647
|
+
return _this.client.on('poll.closed', function (event) {
|
|
9648
|
+
var _event$poll2;
|
|
8739
9649
|
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
switch (_context2.prev = _context2.next) {
|
|
8743
|
-
case 0:
|
|
8744
|
-
options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
8745
|
-
_this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
|
|
9650
|
+
if ((_event$poll2 = event.poll) !== null && _event$poll2 !== void 0 && _event$poll2.id) {
|
|
9651
|
+
var _this$fromState2;
|
|
8746
9652
|
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
9653
|
+
(_this$fromState2 = _this.fromState(event.poll.id)) === null || _this$fromState2 === void 0 ? void 0 : _this$fromState2.handlePollClosed(event);
|
|
9654
|
+
}
|
|
9655
|
+
}).unsubscribe;
|
|
9656
|
+
});
|
|
8751
9657
|
|
|
8752
|
-
|
|
9658
|
+
_defineProperty(this, "subscribeVoteCasted", function () {
|
|
9659
|
+
return _this.client.on('poll.vote_casted', function (event) {
|
|
9660
|
+
var _event$poll3;
|
|
8753
9661
|
|
|
8754
|
-
|
|
8755
|
-
|
|
9662
|
+
if ((_event$poll3 = event.poll) !== null && _event$poll3 !== void 0 && _event$poll3.id) {
|
|
9663
|
+
var _this$fromState3;
|
|
8756
9664
|
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
});
|
|
9665
|
+
(_this$fromState3 = _this.fromState(event.poll.id)) === null || _this$fromState3 === void 0 ? void 0 : _this$fromState3.handleVoteCasted(event);
|
|
9666
|
+
}
|
|
9667
|
+
}).unsubscribe;
|
|
9668
|
+
});
|
|
8762
9669
|
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
}));
|
|
9670
|
+
_defineProperty(this, "subscribeVoteChanged", function () {
|
|
9671
|
+
return _this.client.on('poll.vote_changed', function (event) {
|
|
9672
|
+
var _event$poll4;
|
|
8767
9673
|
|
|
8768
|
-
|
|
8769
|
-
|
|
9674
|
+
if ((_event$poll4 = event.poll) !== null && _event$poll4 !== void 0 && _event$poll4.id) {
|
|
9675
|
+
var _this$fromState4;
|
|
8770
9676
|
|
|
8771
|
-
|
|
8772
|
-
|
|
9677
|
+
(_this$fromState4 = _this.fromState(event.poll.id)) === null || _this$fromState4 === void 0 ? void 0 : _this$fromState4.handleVoteChanged(event);
|
|
9678
|
+
}
|
|
9679
|
+
}).unsubscribe;
|
|
9680
|
+
});
|
|
8773
9681
|
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
nextCursor: (_response$next2 = response.next) !== null && _response$next2 !== void 0 ? _response$next2 : null,
|
|
8778
|
-
isLoadingNext: false
|
|
8779
|
-
})
|
|
8780
|
-
});
|
|
8781
|
-
});
|
|
9682
|
+
_defineProperty(this, "subscribeVoteRemoved", function () {
|
|
9683
|
+
return _this.client.on('poll.vote_removed', function (event) {
|
|
9684
|
+
var _event$poll5;
|
|
8782
9685
|
|
|
8783
|
-
|
|
8784
|
-
|
|
9686
|
+
if ((_event$poll5 = event.poll) !== null && _event$poll5 !== void 0 && _event$poll5.id) {
|
|
9687
|
+
var _this$fromState5;
|
|
8785
9688
|
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
9689
|
+
(_this$fromState5 = _this.fromState(event.poll.id)) === null || _this$fromState5 === void 0 ? void 0 : _this$fromState5.handleVoteRemoved(event);
|
|
9690
|
+
}
|
|
9691
|
+
}).unsubscribe;
|
|
9692
|
+
});
|
|
8789
9693
|
|
|
8790
|
-
|
|
9694
|
+
_defineProperty(this, "subscribeMessageNew", function () {
|
|
9695
|
+
return _this.client.on('message.new', function (event) {
|
|
9696
|
+
var message = event.message;
|
|
8791
9697
|
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8795
|
-
isLoadingNext: false
|
|
8796
|
-
})
|
|
8797
|
-
});
|
|
8798
|
-
});
|
|
9698
|
+
if (message) {
|
|
9699
|
+
var formattedMessage = formatMessage(message);
|
|
8799
9700
|
|
|
8800
|
-
|
|
8801
|
-
case "end":
|
|
8802
|
-
return _context2.stop();
|
|
8803
|
-
}
|
|
9701
|
+
_this.hydratePollCache([formattedMessage]);
|
|
8804
9702
|
}
|
|
8805
|
-
}
|
|
8806
|
-
})
|
|
9703
|
+
}).unsubscribe;
|
|
9704
|
+
});
|
|
8807
9705
|
|
|
8808
9706
|
this.client = client;
|
|
8809
|
-
this.state = new StateStore({
|
|
8810
|
-
active: false,
|
|
8811
|
-
isThreadOrderStale: false,
|
|
8812
|
-
threads: [],
|
|
8813
|
-
unreadThreadCount: 0,
|
|
8814
|
-
unseenThreadIds: [],
|
|
8815
|
-
lastConnectionDropAt: null,
|
|
8816
|
-
pagination: {
|
|
8817
|
-
isLoading: false,
|
|
8818
|
-
isLoadingNext: false,
|
|
8819
|
-
nextCursor: null
|
|
8820
|
-
},
|
|
8821
|
-
ready: false
|
|
8822
|
-
});
|
|
8823
|
-
this.threadsByIdGetterCache = {
|
|
8824
|
-
threads: [],
|
|
8825
|
-
threadsById: {}
|
|
8826
|
-
};
|
|
8827
9707
|
}
|
|
8828
9708
|
|
|
8829
|
-
_createClass(
|
|
8830
|
-
key: "
|
|
9709
|
+
_createClass(PollManager, [{
|
|
9710
|
+
key: "data",
|
|
8831
9711
|
get: function get() {
|
|
8832
|
-
|
|
8833
|
-
threads = _this$state$getLatest5.threads;
|
|
8834
|
-
|
|
8835
|
-
if (threads === this.threadsByIdGetterCache.threads) {
|
|
8836
|
-
return this.threadsByIdGetterCache.threadsById;
|
|
8837
|
-
}
|
|
8838
|
-
|
|
8839
|
-
var threadsById = threads.reduce(function (newThreadsById, thread) {
|
|
8840
|
-
newThreadsById[thread.id] = thread;
|
|
8841
|
-
return newThreadsById;
|
|
8842
|
-
}, {});
|
|
8843
|
-
this.threadsByIdGetterCache.threads = threads;
|
|
8844
|
-
this.threadsByIdGetterCache.threadsById = threadsById;
|
|
8845
|
-
return threadsById;
|
|
9712
|
+
return this.pollCache;
|
|
8846
9713
|
}
|
|
8847
9714
|
}]);
|
|
8848
9715
|
|
|
8849
|
-
return
|
|
9716
|
+
return PollManager;
|
|
8850
9717
|
}();
|
|
8851
9718
|
|
|
8852
9719
|
var _excluded = ["created_at", "updated_at", "last_active", "online"],
|
|
@@ -8879,6 +9746,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8879
9746
|
|
|
8880
9747
|
_defineProperty(this, "threads", void 0);
|
|
8881
9748
|
|
|
9749
|
+
_defineProperty(this, "polls", void 0);
|
|
9750
|
+
|
|
8882
9751
|
_defineProperty(this, "anonymous", void 0);
|
|
8883
9752
|
|
|
8884
9753
|
_defineProperty(this, "persistUserOnConnectionFailure", void 0);
|
|
@@ -9777,6 +10646,9 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9777
10646
|
this.threads = new ThreadManager({
|
|
9778
10647
|
client: this
|
|
9779
10648
|
});
|
|
10649
|
+
this.polls = new PollManager({
|
|
10650
|
+
client: this
|
|
10651
|
+
});
|
|
9780
10652
|
}
|
|
9781
10653
|
/**
|
|
9782
10654
|
* Get a client instance
|
|
@@ -11043,6 +11915,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11043
11915
|
returnedPage: channelState.messages,
|
|
11044
11916
|
logger: this.logger
|
|
11045
11917
|
}));
|
|
11918
|
+
this.polls.hydratePollCache(updatedMessagesSet.messages, true);
|
|
11046
11919
|
}
|
|
11047
11920
|
|
|
11048
11921
|
channels.push(c);
|
|
@@ -13344,7 +14217,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13344
14217
|
}, {
|
|
13345
14218
|
key: "getUserAgent",
|
|
13346
14219
|
value: function getUserAgent() {
|
|
13347
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.
|
|
14220
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.42.0");
|
|
13348
14221
|
}
|
|
13349
14222
|
}, {
|
|
13350
14223
|
key: "setUserAgent",
|
|
@@ -14788,7 +15661,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
14788
15661
|
}()
|
|
14789
15662
|
/**
|
|
14790
15663
|
* Creates a poll
|
|
14791
|
-
* @param
|
|
15664
|
+
* @param poll PollData The poll that will be created
|
|
14792
15665
|
* @param userId string The user id (only serverside)
|
|
14793
15666
|
* @returns {APIResponse & CreatePollAPIResponse} The poll
|
|
14794
15667
|
*/
|
|
@@ -14988,13 +15861,11 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
14988
15861
|
while (1) {
|
|
14989
15862
|
switch (_context103.prev = _context103.next) {
|
|
14990
15863
|
case 0:
|
|
14991
|
-
return _context103.abrupt("return", this.partialUpdatePoll(id,
|
|
15864
|
+
return _context103.abrupt("return", this.partialUpdatePoll(id, {
|
|
14992
15865
|
set: {
|
|
14993
15866
|
is_closed: true
|
|
14994
15867
|
}
|
|
14995
|
-
}, userId
|
|
14996
|
-
user_id: userId
|
|
14997
|
-
} : {})));
|
|
15868
|
+
}, userId));
|
|
14998
15869
|
|
|
14999
15870
|
case 1:
|
|
15000
15871
|
case "end":
|
|
@@ -15370,6 +16241,60 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15370
16241
|
|
|
15371
16242
|
return queryPollVotes;
|
|
15372
16243
|
}()
|
|
16244
|
+
/**
|
|
16245
|
+
* Queries poll answers
|
|
16246
|
+
* @param pollId
|
|
16247
|
+
* @param filter
|
|
16248
|
+
* @param sort
|
|
16249
|
+
* @param options Option object, {limit: 10, offset:0}
|
|
16250
|
+
* @param userId string The user id (only serverside)
|
|
16251
|
+
* @returns {APIResponse & PollAnswersAPIResponse} The poll votes
|
|
16252
|
+
*/
|
|
16253
|
+
|
|
16254
|
+
}, {
|
|
16255
|
+
key: "queryPollAnswers",
|
|
16256
|
+
value: function () {
|
|
16257
|
+
var _queryPollAnswers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee113(pollId) {
|
|
16258
|
+
var filter,
|
|
16259
|
+
sort,
|
|
16260
|
+
options,
|
|
16261
|
+
userId,
|
|
16262
|
+
q,
|
|
16263
|
+
_args113 = arguments;
|
|
16264
|
+
return _regeneratorRuntime.wrap(function _callee113$(_context113) {
|
|
16265
|
+
while (1) {
|
|
16266
|
+
switch (_context113.prev = _context113.next) {
|
|
16267
|
+
case 0:
|
|
16268
|
+
filter = _args113.length > 1 && _args113[1] !== undefined ? _args113[1] : {};
|
|
16269
|
+
sort = _args113.length > 2 && _args113[2] !== undefined ? _args113[2] : [];
|
|
16270
|
+
options = _args113.length > 3 && _args113[3] !== undefined ? _args113[3] : {};
|
|
16271
|
+
userId = _args113.length > 4 ? _args113[4] : undefined;
|
|
16272
|
+
q = userId ? "?user_id=".concat(userId) : '';
|
|
16273
|
+
_context113.next = 7;
|
|
16274
|
+
return this.post(this.baseURL + "/polls/".concat(encodeURIComponent(pollId), "/votes").concat(q), _objectSpread({
|
|
16275
|
+
filter: _objectSpread(_objectSpread({}, filter), {}, {
|
|
16276
|
+
is_answer: true
|
|
16277
|
+
}),
|
|
16278
|
+
sort: normalizeQuerySort(sort)
|
|
16279
|
+
}, options));
|
|
16280
|
+
|
|
16281
|
+
case 7:
|
|
16282
|
+
return _context113.abrupt("return", _context113.sent);
|
|
16283
|
+
|
|
16284
|
+
case 8:
|
|
16285
|
+
case "end":
|
|
16286
|
+
return _context113.stop();
|
|
16287
|
+
}
|
|
16288
|
+
}
|
|
16289
|
+
}, _callee113, this);
|
|
16290
|
+
}));
|
|
16291
|
+
|
|
16292
|
+
function queryPollAnswers(_x174) {
|
|
16293
|
+
return _queryPollAnswers.apply(this, arguments);
|
|
16294
|
+
}
|
|
16295
|
+
|
|
16296
|
+
return queryPollAnswers;
|
|
16297
|
+
}()
|
|
15373
16298
|
/**
|
|
15374
16299
|
* Query message history
|
|
15375
16300
|
* @param filter
|
|
@@ -15381,33 +16306,33 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15381
16306
|
}, {
|
|
15382
16307
|
key: "queryMessageHistory",
|
|
15383
16308
|
value: function () {
|
|
15384
|
-
var _queryMessageHistory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
16309
|
+
var _queryMessageHistory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee114() {
|
|
15385
16310
|
var filter,
|
|
15386
16311
|
sort,
|
|
15387
16312
|
options,
|
|
15388
|
-
|
|
15389
|
-
return _regeneratorRuntime.wrap(function
|
|
16313
|
+
_args114 = arguments;
|
|
16314
|
+
return _regeneratorRuntime.wrap(function _callee114$(_context114) {
|
|
15390
16315
|
while (1) {
|
|
15391
|
-
switch (
|
|
16316
|
+
switch (_context114.prev = _context114.next) {
|
|
15392
16317
|
case 0:
|
|
15393
|
-
filter =
|
|
15394
|
-
sort =
|
|
15395
|
-
options =
|
|
15396
|
-
|
|
16318
|
+
filter = _args114.length > 0 && _args114[0] !== undefined ? _args114[0] : {};
|
|
16319
|
+
sort = _args114.length > 1 && _args114[1] !== undefined ? _args114[1] : [];
|
|
16320
|
+
options = _args114.length > 2 && _args114[2] !== undefined ? _args114[2] : {};
|
|
16321
|
+
_context114.next = 5;
|
|
15397
16322
|
return this.post(this.baseURL + '/messages/history', _objectSpread({
|
|
15398
16323
|
filter: filter,
|
|
15399
16324
|
sort: normalizeQuerySort(sort)
|
|
15400
16325
|
}, options));
|
|
15401
16326
|
|
|
15402
16327
|
case 5:
|
|
15403
|
-
return
|
|
16328
|
+
return _context114.abrupt("return", _context114.sent);
|
|
15404
16329
|
|
|
15405
16330
|
case 6:
|
|
15406
16331
|
case "end":
|
|
15407
|
-
return
|
|
16332
|
+
return _context114.stop();
|
|
15408
16333
|
}
|
|
15409
16334
|
}
|
|
15410
|
-
},
|
|
16335
|
+
}, _callee114, this);
|
|
15411
16336
|
}));
|
|
15412
16337
|
|
|
15413
16338
|
function queryMessageHistory() {
|
|
@@ -15428,32 +16353,32 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15428
16353
|
}, {
|
|
15429
16354
|
key: "updateFlags",
|
|
15430
16355
|
value: function () {
|
|
15431
|
-
var _updateFlags = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
16356
|
+
var _updateFlags = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee115(message_ids, reviewed_by) {
|
|
15432
16357
|
var options,
|
|
15433
|
-
|
|
15434
|
-
return _regeneratorRuntime.wrap(function
|
|
16358
|
+
_args115 = arguments;
|
|
16359
|
+
return _regeneratorRuntime.wrap(function _callee115$(_context115) {
|
|
15435
16360
|
while (1) {
|
|
15436
|
-
switch (
|
|
16361
|
+
switch (_context115.prev = _context115.next) {
|
|
15437
16362
|
case 0:
|
|
15438
|
-
options =
|
|
15439
|
-
|
|
16363
|
+
options = _args115.length > 2 && _args115[2] !== undefined ? _args115[2] : {};
|
|
16364
|
+
_context115.next = 3;
|
|
15440
16365
|
return this.post(this.baseURL + '/automod/v1/moderation/update_flags', _objectSpread({
|
|
15441
16366
|
message_ids: message_ids,
|
|
15442
16367
|
reviewed_by: reviewed_by
|
|
15443
16368
|
}, options));
|
|
15444
16369
|
|
|
15445
16370
|
case 3:
|
|
15446
|
-
return
|
|
16371
|
+
return _context115.abrupt("return", _context115.sent);
|
|
15447
16372
|
|
|
15448
16373
|
case 4:
|
|
15449
16374
|
case "end":
|
|
15450
|
-
return
|
|
16375
|
+
return _context115.stop();
|
|
15451
16376
|
}
|
|
15452
16377
|
}
|
|
15453
|
-
},
|
|
16378
|
+
}, _callee115, this);
|
|
15454
16379
|
}));
|
|
15455
16380
|
|
|
15456
|
-
function updateFlags(
|
|
16381
|
+
function updateFlags(_x175, _x176) {
|
|
15457
16382
|
return _updateFlags.apply(this, arguments);
|
|
15458
16383
|
}
|
|
15459
16384
|
|
|
@@ -15611,5 +16536,5 @@ var BuiltinPermissions = {
|
|
|
15611
16536
|
UseFrozenChannel: 'Send messages and reactions to frozen channels'
|
|
15612
16537
|
};
|
|
15613
16538
|
|
|
15614
|
-
export { Allow, AllowAll, AnyResource, AnyRole, BuiltinPermissions, BuiltinRoles, Campaign, Channel, ChannelState, CheckSignature, ClientState, Deny, DenyAll, DevToken, EVENT_MAP, ErrorFromResponse, InsightMetrics, JWTServerToken, JWTUserToken, MODERATION_ENTITY_TYPES, MaxPriority, MinPriority, Moderation, Permission, Segment, StableWSConnection, StateStore, StreamChat, Thread, ThreadManager, TokenManager, UserFromToken, VotingVisibility, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, formatMessage, isOwnUser, logChatPromiseExecution, postInsights };
|
|
16539
|
+
export { Allow, AllowAll, AnyResource, AnyRole, BuiltinPermissions, BuiltinRoles, Campaign, Channel, ChannelState, CheckSignature, ClientState, Deny, DenyAll, DevToken, EVENT_MAP, ErrorFromResponse, InsightMetrics, JWTServerToken, JWTUserToken, MODERATION_ENTITY_TYPES, MaxPriority, MinPriority, Moderation, Permission, Poll, PollManager, Segment, StableWSConnection, StateStore, StreamChat, Thread, ThreadManager, TokenManager, UserFromToken, VotingVisibility, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, extractPollData, extractPollEnrichedData, formatMessage, isOwnUser, isVoteAnswer, logChatPromiseExecution, postInsights };
|
|
15615
16540
|
//# sourceMappingURL=index.es.js.map
|