stream-chat 8.41.1 → 8.43.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 +2167 -886
- 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 +2170 -884
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +2167 -886
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2170 -884
- package/dist/index.js.map +1 -1
- package/dist/types/channel.d.ts +63 -3
- 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/moderation.d.ts +30 -1
- package/dist/types/moderation.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/types.d.ts +59 -23
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/channel.ts +93 -27
- package/src/channel_state.ts +0 -92
- package/src/client.ts +112 -70
- package/src/index.ts +8 -6
- package/src/moderation.ts +64 -0
- package/src/poll.ts +414 -0
- package/src/poll_manager.ts +162 -0
- package/src/types.ts +93 -39
package/dist/index.js
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var base64Js = require('base64-js');
|
|
6
|
-
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
|
-
var _typeof = require('@babel/runtime/helpers/typeof');
|
|
8
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
9
|
-
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
10
6
|
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
11
7
|
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
12
8
|
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
13
9
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
14
10
|
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
11
|
+
var _extends = require('@babel/runtime/helpers/extends');
|
|
12
|
+
var _typeof = require('@babel/runtime/helpers/typeof');
|
|
13
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
14
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
15
15
|
var axios = require('axios');
|
|
16
16
|
var https = require('https');
|
|
17
17
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
@@ -27,15 +27,15 @@ var _wrapNativeSuper = require('@babel/runtime/helpers/wrapNativeSuper');
|
|
|
27
27
|
|
|
28
28
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
29
29
|
|
|
30
|
-
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
31
|
-
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
|
32
|
-
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
33
|
-
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
34
30
|
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
|
|
35
31
|
var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
|
|
36
32
|
var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
|
|
37
33
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
38
34
|
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
|
|
35
|
+
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
36
|
+
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
|
37
|
+
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
38
|
+
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
39
39
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
40
40
|
var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
|
|
41
41
|
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
@@ -122,15 +122,220 @@ var decodeBase64 = function decodeBase64(s) {
|
|
|
122
122
|
return r;
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
var Campaign = /*#__PURE__*/function () {
|
|
126
|
+
function Campaign(client, id, data) {
|
|
127
|
+
_classCallCheck__default['default'](this, Campaign);
|
|
126
128
|
|
|
127
|
-
|
|
129
|
+
_defineProperty__default['default'](this, "id", void 0);
|
|
128
130
|
|
|
129
|
-
|
|
131
|
+
_defineProperty__default['default'](this, "data", void 0);
|
|
130
132
|
|
|
131
|
-
|
|
133
|
+
_defineProperty__default['default'](this, "client", void 0);
|
|
132
134
|
|
|
133
|
-
|
|
135
|
+
this.client = client;
|
|
136
|
+
this.id = id;
|
|
137
|
+
this.data = data;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
_createClass__default['default'](Campaign, [{
|
|
141
|
+
key: "create",
|
|
142
|
+
value: function () {
|
|
143
|
+
var _create = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
|
144
|
+
var _this$data, _this$data2, _this$data3, _this$data4, _this$data5, _this$data6, _this$data7, _this$data8;
|
|
145
|
+
|
|
146
|
+
var body, result;
|
|
147
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
148
|
+
while (1) {
|
|
149
|
+
switch (_context.prev = _context.next) {
|
|
150
|
+
case 0:
|
|
151
|
+
body = {
|
|
152
|
+
id: this.id,
|
|
153
|
+
message_template: (_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.message_template,
|
|
154
|
+
segment_ids: (_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2.segment_ids,
|
|
155
|
+
sender_id: (_this$data3 = this.data) === null || _this$data3 === void 0 ? void 0 : _this$data3.sender_id,
|
|
156
|
+
channel_template: (_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : _this$data4.channel_template,
|
|
157
|
+
create_channels: (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5.create_channels,
|
|
158
|
+
description: (_this$data6 = this.data) === null || _this$data6 === void 0 ? void 0 : _this$data6.description,
|
|
159
|
+
name: (_this$data7 = this.data) === null || _this$data7 === void 0 ? void 0 : _this$data7.name,
|
|
160
|
+
user_ids: (_this$data8 = this.data) === null || _this$data8 === void 0 ? void 0 : _this$data8.user_ids
|
|
161
|
+
};
|
|
162
|
+
_context.next = 3;
|
|
163
|
+
return this.client.createCampaign(body);
|
|
164
|
+
|
|
165
|
+
case 3:
|
|
166
|
+
result = _context.sent;
|
|
167
|
+
this.id = result.campaign.id;
|
|
168
|
+
this.data = result.campaign;
|
|
169
|
+
return _context.abrupt("return", result);
|
|
170
|
+
|
|
171
|
+
case 7:
|
|
172
|
+
case "end":
|
|
173
|
+
return _context.stop();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}, _callee, this);
|
|
177
|
+
}));
|
|
178
|
+
|
|
179
|
+
function create() {
|
|
180
|
+
return _create.apply(this, arguments);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return create;
|
|
184
|
+
}()
|
|
185
|
+
}, {
|
|
186
|
+
key: "verifyCampaignId",
|
|
187
|
+
value: function verifyCampaignId() {
|
|
188
|
+
if (!this.id) {
|
|
189
|
+
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)');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}, {
|
|
193
|
+
key: "start",
|
|
194
|
+
value: function () {
|
|
195
|
+
var _start = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2(options) {
|
|
196
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
197
|
+
while (1) {
|
|
198
|
+
switch (_context2.prev = _context2.next) {
|
|
199
|
+
case 0:
|
|
200
|
+
this.verifyCampaignId();
|
|
201
|
+
_context2.next = 3;
|
|
202
|
+
return this.client.startCampaign(this.id, options);
|
|
203
|
+
|
|
204
|
+
case 3:
|
|
205
|
+
return _context2.abrupt("return", _context2.sent);
|
|
206
|
+
|
|
207
|
+
case 4:
|
|
208
|
+
case "end":
|
|
209
|
+
return _context2.stop();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}, _callee2, this);
|
|
213
|
+
}));
|
|
214
|
+
|
|
215
|
+
function start(_x) {
|
|
216
|
+
return _start.apply(this, arguments);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return start;
|
|
220
|
+
}()
|
|
221
|
+
}, {
|
|
222
|
+
key: "update",
|
|
223
|
+
value: function () {
|
|
224
|
+
var _update = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(data) {
|
|
225
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
226
|
+
while (1) {
|
|
227
|
+
switch (_context3.prev = _context3.next) {
|
|
228
|
+
case 0:
|
|
229
|
+
this.verifyCampaignId();
|
|
230
|
+
return _context3.abrupt("return", this.client.updateCampaign(this.id, data));
|
|
231
|
+
|
|
232
|
+
case 2:
|
|
233
|
+
case "end":
|
|
234
|
+
return _context3.stop();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}, _callee3, this);
|
|
238
|
+
}));
|
|
239
|
+
|
|
240
|
+
function update(_x2) {
|
|
241
|
+
return _update.apply(this, arguments);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return update;
|
|
245
|
+
}()
|
|
246
|
+
}, {
|
|
247
|
+
key: "delete",
|
|
248
|
+
value: function () {
|
|
249
|
+
var _delete2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4() {
|
|
250
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
251
|
+
while (1) {
|
|
252
|
+
switch (_context4.prev = _context4.next) {
|
|
253
|
+
case 0:
|
|
254
|
+
this.verifyCampaignId();
|
|
255
|
+
_context4.next = 3;
|
|
256
|
+
return this.client.deleteCampaign(this.id);
|
|
257
|
+
|
|
258
|
+
case 3:
|
|
259
|
+
return _context4.abrupt("return", _context4.sent);
|
|
260
|
+
|
|
261
|
+
case 4:
|
|
262
|
+
case "end":
|
|
263
|
+
return _context4.stop();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}, _callee4, this);
|
|
267
|
+
}));
|
|
268
|
+
|
|
269
|
+
function _delete() {
|
|
270
|
+
return _delete2.apply(this, arguments);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return _delete;
|
|
274
|
+
}()
|
|
275
|
+
}, {
|
|
276
|
+
key: "stop",
|
|
277
|
+
value: function () {
|
|
278
|
+
var _stop = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5() {
|
|
279
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
280
|
+
while (1) {
|
|
281
|
+
switch (_context5.prev = _context5.next) {
|
|
282
|
+
case 0:
|
|
283
|
+
this.verifyCampaignId();
|
|
284
|
+
return _context5.abrupt("return", this.client.stopCampaign(this.id));
|
|
285
|
+
|
|
286
|
+
case 2:
|
|
287
|
+
case "end":
|
|
288
|
+
return _context5.stop();
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}, _callee5, this);
|
|
292
|
+
}));
|
|
293
|
+
|
|
294
|
+
function stop() {
|
|
295
|
+
return _stop.apply(this, arguments);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return stop;
|
|
299
|
+
}()
|
|
300
|
+
}, {
|
|
301
|
+
key: "get",
|
|
302
|
+
value: function () {
|
|
303
|
+
var _get = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
|
|
304
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
|
305
|
+
while (1) {
|
|
306
|
+
switch (_context6.prev = _context6.next) {
|
|
307
|
+
case 0:
|
|
308
|
+
this.verifyCampaignId();
|
|
309
|
+
return _context6.abrupt("return", this.client.getCampaign(this.id));
|
|
310
|
+
|
|
311
|
+
case 2:
|
|
312
|
+
case "end":
|
|
313
|
+
return _context6.stop();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}, _callee6, this);
|
|
317
|
+
}));
|
|
318
|
+
|
|
319
|
+
function get() {
|
|
320
|
+
return _get.apply(this, arguments);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return get;
|
|
324
|
+
}()
|
|
325
|
+
}]);
|
|
326
|
+
|
|
327
|
+
return Campaign;
|
|
328
|
+
}();
|
|
329
|
+
|
|
330
|
+
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; }
|
|
331
|
+
|
|
332
|
+
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__default['default'](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; }
|
|
333
|
+
|
|
334
|
+
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; } } }; }
|
|
335
|
+
|
|
336
|
+
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); }
|
|
337
|
+
|
|
338
|
+
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; }
|
|
134
339
|
|
|
135
340
|
/**
|
|
136
341
|
* logChatPromiseExecution - utility function for logging the execution of a promise..
|
|
@@ -215,7 +420,7 @@ function normalizeQuerySort(sort) {
|
|
|
215
420
|
var sortFields = [];
|
|
216
421
|
var sortArr = Array.isArray(sort) ? sort : [sort];
|
|
217
422
|
|
|
218
|
-
var _iterator = _createForOfIteratorHelper$
|
|
423
|
+
var _iterator = _createForOfIteratorHelper$5(sortArr),
|
|
219
424
|
_step;
|
|
220
425
|
|
|
221
426
|
try {
|
|
@@ -385,7 +590,7 @@ var axiosParamsSerializer = function axiosParamsSerializer(params) {
|
|
|
385
590
|
*/
|
|
386
591
|
|
|
387
592
|
function formatMessage(message) {
|
|
388
|
-
return _objectSpread$
|
|
593
|
+
return _objectSpread$c(_objectSpread$c({}, message), {}, {
|
|
389
594
|
/**
|
|
390
595
|
* @deprecated please use `html`
|
|
391
596
|
*/
|
|
@@ -590,7 +795,7 @@ var messagePaginationCreatedAtAround = function messagePaginationCreatedAtAround
|
|
|
590
795
|
returnedPage = _ref3.returnedPage,
|
|
591
796
|
messagePaginationOptions = _ref3.messagePaginationOptions;
|
|
592
797
|
|
|
593
|
-
var newPagination = _objectSpread$
|
|
798
|
+
var newPagination = _objectSpread$c({}, parentSet.pagination);
|
|
594
799
|
|
|
595
800
|
if (!(messagePaginationOptions !== null && messagePaginationOptions !== void 0 && messagePaginationOptions.created_at_around)) return newPagination;
|
|
596
801
|
var hasPrev;
|
|
@@ -655,7 +860,7 @@ var messagePaginationIdAround = function messagePaginationIdAround(_ref5) {
|
|
|
655
860
|
returnedPage = _ref5.returnedPage,
|
|
656
861
|
messagePaginationOptions = _ref5.messagePaginationOptions;
|
|
657
862
|
|
|
658
|
-
var newPagination = _objectSpread$
|
|
863
|
+
var newPagination = _objectSpread$c({}, parentSet.pagination);
|
|
659
864
|
|
|
660
865
|
var _ref6 = messagePaginationOptions || {},
|
|
661
866
|
id_around = _ref6.id_around;
|
|
@@ -713,7 +918,7 @@ var messagePaginationLinear = function messagePaginationLinear(_ref8) {
|
|
|
713
918
|
returnedPage = _ref8.returnedPage,
|
|
714
919
|
messagePaginationOptions = _ref8.messagePaginationOptions;
|
|
715
920
|
|
|
716
|
-
var newPagination = _objectSpread$
|
|
921
|
+
var newPagination = _objectSpread$c({}, parentSet.pagination);
|
|
717
922
|
|
|
718
923
|
var hasPrev;
|
|
719
924
|
var hasNext;
|
|
@@ -767,9 +972,9 @@ var DEFAULT_MESSAGE_SET_PAGINATION = {
|
|
|
767
972
|
hasPrev: true
|
|
768
973
|
};
|
|
769
974
|
|
|
770
|
-
function ownKeys$
|
|
975
|
+
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; }
|
|
771
976
|
|
|
772
|
-
function _objectSpread$
|
|
977
|
+
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__default['default'](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; }
|
|
773
978
|
|
|
774
979
|
/**
|
|
775
980
|
* ChannelState - A container class for the channel state.
|
|
@@ -842,142 +1047,31 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
842
1047
|
};
|
|
843
1048
|
});
|
|
844
1049
|
|
|
845
|
-
_defineProperty__default['default'](this, "
|
|
846
|
-
var
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
if (!message) return;
|
|
851
|
-
if (message.poll_id !== pollVote.poll_id) return;
|
|
852
|
-
|
|
853
|
-
var updatedPoll = _objectSpread$a({}, poll);
|
|
1050
|
+
_defineProperty__default['default'](this, "updateUserMessages", function (user) {
|
|
1051
|
+
var _updateUserMessages = function _updateUserMessages(messages, user) {
|
|
1052
|
+
for (var i = 0; i < messages.length; i++) {
|
|
1053
|
+
var _m$user;
|
|
854
1054
|
|
|
855
|
-
|
|
1055
|
+
var m = messages[i];
|
|
856
1056
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
});
|
|
863
|
-
} else if (pollVote.answer_text) {
|
|
864
|
-
// remove all previous votes where option_id is empty
|
|
865
|
-
ownVotes = ownVotes.filter(function (vote) {
|
|
866
|
-
return vote.answer_text;
|
|
867
|
-
});
|
|
1057
|
+
if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
|
|
1058
|
+
messages[i] = _objectSpread$b(_objectSpread$b({}, m), {}, {
|
|
1059
|
+
user: user
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
868
1062
|
}
|
|
1063
|
+
};
|
|
869
1064
|
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
updatedPoll.own_votes = ownVotes;
|
|
874
|
-
|
|
875
|
-
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
876
|
-
poll: updatedPoll
|
|
1065
|
+
_this.messageSets.forEach(function (set) {
|
|
1066
|
+
return _updateUserMessages(set.messages, user);
|
|
877
1067
|
});
|
|
878
1068
|
|
|
879
|
-
|
|
880
|
-
|
|
1069
|
+
for (var parentId in _this.threads) {
|
|
1070
|
+
_updateUserMessages(_this.threads[parentId], user);
|
|
1071
|
+
}
|
|
881
1072
|
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
var message = _this.findMessage(messageId);
|
|
886
|
-
|
|
887
|
-
if (!message) return;
|
|
888
|
-
if (message.poll_id !== pollVote.poll_id) return;
|
|
889
|
-
|
|
890
|
-
var updatedPoll = _objectSpread$a({}, poll);
|
|
891
|
-
|
|
892
|
-
var ownVotes = _toConsumableArray__default['default'](((_message$poll2 = message.poll) === null || _message$poll2 === void 0 ? void 0 : _message$poll2.own_votes) || []);
|
|
893
|
-
|
|
894
|
-
if (pollVote.user_id === _this._channel.getClient().userID) {
|
|
895
|
-
ownVotes.push(pollVote);
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
updatedPoll.own_votes = ownVotes;
|
|
899
|
-
|
|
900
|
-
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
901
|
-
poll: updatedPoll
|
|
902
|
-
});
|
|
903
|
-
|
|
904
|
-
_this.addMessageSorted(newMessage, false, false);
|
|
905
|
-
});
|
|
906
|
-
|
|
907
|
-
_defineProperty__default['default'](this, "removePollVote", function (pollVote, poll, messageId) {
|
|
908
|
-
var _message$poll3;
|
|
909
|
-
|
|
910
|
-
var message = _this.findMessage(messageId);
|
|
911
|
-
|
|
912
|
-
if (!message) return;
|
|
913
|
-
if (message.poll_id !== pollVote.poll_id) return;
|
|
914
|
-
|
|
915
|
-
var updatedPoll = _objectSpread$a({}, poll);
|
|
916
|
-
|
|
917
|
-
var ownVotes = _toConsumableArray__default['default'](((_message$poll3 = message.poll) === null || _message$poll3 === void 0 ? void 0 : _message$poll3.own_votes) || []);
|
|
918
|
-
|
|
919
|
-
if (pollVote.user_id === _this._channel.getClient().userID) {
|
|
920
|
-
var index = ownVotes.findIndex(function (vote) {
|
|
921
|
-
return vote.option_id === pollVote.option_id;
|
|
922
|
-
});
|
|
923
|
-
|
|
924
|
-
if (index > -1) {
|
|
925
|
-
ownVotes.splice(index, 1);
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
updatedPoll.own_votes = ownVotes;
|
|
930
|
-
|
|
931
|
-
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
932
|
-
poll: updatedPoll
|
|
933
|
-
});
|
|
934
|
-
|
|
935
|
-
_this.addMessageSorted(newMessage, false, false);
|
|
936
|
-
});
|
|
937
|
-
|
|
938
|
-
_defineProperty__default['default'](this, "updatePoll", function (poll, messageId) {
|
|
939
|
-
var _message$poll4;
|
|
940
|
-
|
|
941
|
-
var message = _this.findMessage(messageId);
|
|
942
|
-
|
|
943
|
-
if (!message) return;
|
|
944
|
-
|
|
945
|
-
var updatedPoll = _objectSpread$a(_objectSpread$a({}, poll), {}, {
|
|
946
|
-
own_votes: _toConsumableArray__default['default'](((_message$poll4 = message.poll) === null || _message$poll4 === void 0 ? void 0 : _message$poll4.own_votes) || [])
|
|
947
|
-
});
|
|
948
|
-
|
|
949
|
-
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
950
|
-
poll: updatedPoll
|
|
951
|
-
});
|
|
952
|
-
|
|
953
|
-
_this.addMessageSorted(newMessage, false, false);
|
|
954
|
-
});
|
|
955
|
-
|
|
956
|
-
_defineProperty__default['default'](this, "updateUserMessages", function (user) {
|
|
957
|
-
var _updateUserMessages = function _updateUserMessages(messages, user) {
|
|
958
|
-
for (var i = 0; i < messages.length; i++) {
|
|
959
|
-
var _m$user;
|
|
960
|
-
|
|
961
|
-
var m = messages[i];
|
|
962
|
-
|
|
963
|
-
if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
|
|
964
|
-
messages[i] = _objectSpread$a(_objectSpread$a({}, m), {}, {
|
|
965
|
-
user: user
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
};
|
|
970
|
-
|
|
971
|
-
_this.messageSets.forEach(function (set) {
|
|
972
|
-
return _updateUserMessages(set.messages, user);
|
|
973
|
-
});
|
|
974
|
-
|
|
975
|
-
for (var parentId in _this.threads) {
|
|
976
|
-
_updateUserMessages(_this.threads[parentId], user);
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
_updateUserMessages(_this.pinnedMessages, user);
|
|
980
|
-
});
|
|
1073
|
+
_updateUserMessages(_this.pinnedMessages, user);
|
|
1074
|
+
});
|
|
981
1075
|
|
|
982
1076
|
_defineProperty__default['default'](this, "deleteUserMessages", function (user) {
|
|
983
1077
|
var hardDelete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -1016,7 +1110,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1016
1110
|
user: m.user
|
|
1017
1111
|
};
|
|
1018
1112
|
} else {
|
|
1019
|
-
messages[i] = _objectSpread$
|
|
1113
|
+
messages[i] = _objectSpread$b(_objectSpread$b({}, m), {}, {
|
|
1020
1114
|
type: 'deleted',
|
|
1021
1115
|
deleted_at: user.deleted_at ? new Date(user.deleted_at) : null
|
|
1022
1116
|
});
|
|
@@ -1334,7 +1428,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1334
1428
|
var parseMessage = function parseMessage(m) {
|
|
1335
1429
|
var _m$pinned_at, _m$updated_at;
|
|
1336
1430
|
|
|
1337
|
-
return _objectSpread$
|
|
1431
|
+
return _objectSpread$b(_objectSpread$b({}, m), {}, {
|
|
1338
1432
|
created_at: m.created_at.toISOString(),
|
|
1339
1433
|
pinned_at: (_m$pinned_at = m.pinned_at) === null || _m$pinned_at === void 0 ? void 0 : _m$pinned_at.toISOString(),
|
|
1340
1434
|
updated_at: (_m$updated_at = m.updated_at) === null || _m$updated_at === void 0 ? void 0 : _m$updated_at.toISOString()
|
|
@@ -1344,8 +1438,8 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1344
1438
|
var update = function update(messages) {
|
|
1345
1439
|
var updatedMessages = messages.reduce(function (acc, msg) {
|
|
1346
1440
|
if (msg.quoted_message_id === message.id) {
|
|
1347
|
-
acc.push(_objectSpread$
|
|
1348
|
-
quoted_message: remove ? _objectSpread$
|
|
1441
|
+
acc.push(_objectSpread$b(_objectSpread$b({}, parseMessage(msg)), {}, {
|
|
1442
|
+
quoted_message: remove ? _objectSpread$b(_objectSpread$b({}, message), {}, {
|
|
1349
1443
|
attachments: []
|
|
1350
1444
|
}) : message
|
|
1351
1445
|
}));
|
|
@@ -1828,15 +1922,15 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1828
1922
|
return ChannelState;
|
|
1829
1923
|
}();
|
|
1830
1924
|
|
|
1831
|
-
function _createForOfIteratorHelper$
|
|
1925
|
+
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; } } }; }
|
|
1832
1926
|
|
|
1833
|
-
function _unsupportedIterableToArray$
|
|
1927
|
+
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); }
|
|
1834
1928
|
|
|
1835
|
-
function _arrayLikeToArray$
|
|
1929
|
+
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; }
|
|
1836
1930
|
|
|
1837
|
-
function ownKeys$
|
|
1931
|
+
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; }
|
|
1838
1932
|
|
|
1839
|
-
function _objectSpread$
|
|
1933
|
+
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__default['default'](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; }
|
|
1840
1934
|
/**
|
|
1841
1935
|
* Channel - The Channel class manages it's own state.
|
|
1842
1936
|
*/
|
|
@@ -1909,7 +2003,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1909
2003
|
while (1) {
|
|
1910
2004
|
switch (_context.prev = _context.next) {
|
|
1911
2005
|
case 0:
|
|
1912
|
-
defaultOptions = _objectSpread$
|
|
2006
|
+
defaultOptions = _objectSpread$a(_objectSpread$a({}, options), {}, {
|
|
1913
2007
|
watch: false,
|
|
1914
2008
|
state: false,
|
|
1915
2009
|
presence: false
|
|
@@ -1981,7 +2075,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1981
2075
|
|
|
1982
2076
|
this.data = data; // this._data is used for the requests...
|
|
1983
2077
|
|
|
1984
|
-
this._data = _objectSpread$
|
|
2078
|
+
this._data = _objectSpread$a({}, data);
|
|
1985
2079
|
this.cid = "".concat(type, ":").concat(id);
|
|
1986
2080
|
this.listeners = {}; // perhaps the state variable should be private
|
|
1987
2081
|
|
|
@@ -2043,7 +2137,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2043
2137
|
switch (_context2.prev = _context2.next) {
|
|
2044
2138
|
case 0:
|
|
2045
2139
|
_context2.next = 2;
|
|
2046
|
-
return this.getClient().post(this._channelURL() + '/message', _objectSpread$
|
|
2140
|
+
return this.getClient().post(this._channelURL() + '/message', _objectSpread$a({
|
|
2047
2141
|
message: message
|
|
2048
2142
|
}, options));
|
|
2049
2143
|
|
|
@@ -2159,7 +2253,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2159
2253
|
|
|
2160
2254
|
case 3:
|
|
2161
2255
|
// Return a list of channels
|
|
2162
|
-
payload = _objectSpread$
|
|
2256
|
+
payload = _objectSpread$a(_objectSpread$a({
|
|
2163
2257
|
filter_conditions: {
|
|
2164
2258
|
cid: this.cid
|
|
2165
2259
|
}
|
|
@@ -2256,7 +2350,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2256
2350
|
|
|
2257
2351
|
_context5.next = 6;
|
|
2258
2352
|
return this.getClient().get(this.getClient().baseURL + '/members', {
|
|
2259
|
-
payload: _objectSpread$
|
|
2353
|
+
payload: _objectSpread$a({
|
|
2260
2354
|
type: type,
|
|
2261
2355
|
id: id,
|
|
2262
2356
|
members: members,
|
|
@@ -2362,7 +2456,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2362
2456
|
|
|
2363
2457
|
case 4:
|
|
2364
2458
|
_context7.next = 6;
|
|
2365
|
-
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(messageID), "/reaction"), _objectSpread$
|
|
2459
|
+
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(messageID), "/reaction"), _objectSpread$a({
|
|
2366
2460
|
reaction: reaction
|
|
2367
2461
|
}, options));
|
|
2368
2462
|
|
|
@@ -2443,7 +2537,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2443
2537
|
delete channelData[key];
|
|
2444
2538
|
});
|
|
2445
2539
|
_context8.next = 7;
|
|
2446
|
-
return this._update(_objectSpread$
|
|
2540
|
+
return this._update(_objectSpread$a({
|
|
2447
2541
|
message: updateMessage,
|
|
2448
2542
|
data: channelData
|
|
2449
2543
|
}, options));
|
|
@@ -2615,7 +2709,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2615
2709
|
case 0:
|
|
2616
2710
|
options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
2617
2711
|
_context12.next = 3;
|
|
2618
|
-
return this.getClient().delete(this._channelURL(), _objectSpread$
|
|
2712
|
+
return this.getClient().delete(this._channelURL(), _objectSpread$a({}, options));
|
|
2619
2713
|
|
|
2620
2714
|
case 3:
|
|
2621
2715
|
return _context12.abrupt("return", _context12.sent);
|
|
@@ -2691,7 +2785,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2691
2785
|
case 0:
|
|
2692
2786
|
options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
2693
2787
|
_context14.next = 3;
|
|
2694
|
-
return this._update(_objectSpread$
|
|
2788
|
+
return this._update(_objectSpread$a({
|
|
2695
2789
|
accept_invite: true
|
|
2696
2790
|
}, options));
|
|
2697
2791
|
|
|
@@ -2732,7 +2826,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2732
2826
|
case 0:
|
|
2733
2827
|
options = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
|
|
2734
2828
|
_context15.next = 3;
|
|
2735
|
-
return this._update(_objectSpread$
|
|
2829
|
+
return this._update(_objectSpread$a({
|
|
2736
2830
|
reject_invite: true
|
|
2737
2831
|
}, options));
|
|
2738
2832
|
|
|
@@ -2774,7 +2868,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2774
2868
|
case 0:
|
|
2775
2869
|
options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
|
|
2776
2870
|
_context16.next = 3;
|
|
2777
|
-
return this._update(_objectSpread$
|
|
2871
|
+
return this._update(_objectSpread$a({
|
|
2778
2872
|
add_members: members,
|
|
2779
2873
|
message: message
|
|
2780
2874
|
}, options));
|
|
@@ -2817,7 +2911,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2817
2911
|
case 0:
|
|
2818
2912
|
options = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
|
|
2819
2913
|
_context17.next = 3;
|
|
2820
|
-
return this._update(_objectSpread$
|
|
2914
|
+
return this._update(_objectSpread$a({
|
|
2821
2915
|
add_moderators: members,
|
|
2822
2916
|
message: message
|
|
2823
2917
|
}, options));
|
|
@@ -2860,7 +2954,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2860
2954
|
case 0:
|
|
2861
2955
|
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
2862
2956
|
_context18.next = 3;
|
|
2863
|
-
return this._update(_objectSpread$
|
|
2957
|
+
return this._update(_objectSpread$a({
|
|
2864
2958
|
assign_roles: roles,
|
|
2865
2959
|
message: message
|
|
2866
2960
|
}, options));
|
|
@@ -2903,7 +2997,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2903
2997
|
case 0:
|
|
2904
2998
|
options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
|
2905
2999
|
_context19.next = 3;
|
|
2906
|
-
return this._update(_objectSpread$
|
|
3000
|
+
return this._update(_objectSpread$a({
|
|
2907
3001
|
invites: members,
|
|
2908
3002
|
message: message
|
|
2909
3003
|
}, options));
|
|
@@ -2946,7 +3040,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2946
3040
|
case 0:
|
|
2947
3041
|
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
|
2948
3042
|
_context20.next = 3;
|
|
2949
|
-
return this._update(_objectSpread$
|
|
3043
|
+
return this._update(_objectSpread$a({
|
|
2950
3044
|
remove_members: members,
|
|
2951
3045
|
message: message
|
|
2952
3046
|
}, options));
|
|
@@ -2989,7 +3083,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2989
3083
|
case 0:
|
|
2990
3084
|
options = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : {};
|
|
2991
3085
|
_context21.next = 3;
|
|
2992
|
-
return this._update(_objectSpread$
|
|
3086
|
+
return this._update(_objectSpread$a({
|
|
2993
3087
|
demote_moderators: members,
|
|
2994
3088
|
message: message
|
|
2995
3089
|
}, options));
|
|
@@ -3074,7 +3168,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3074
3168
|
case 0:
|
|
3075
3169
|
opts = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
|
|
3076
3170
|
_context23.next = 3;
|
|
3077
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$
|
|
3171
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$a({
|
|
3078
3172
|
channel_cid: this.cid
|
|
3079
3173
|
}, opts));
|
|
3080
3174
|
|
|
@@ -3116,7 +3210,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3116
3210
|
case 0:
|
|
3117
3211
|
opts = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {};
|
|
3118
3212
|
_context24.next = 3;
|
|
3119
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$
|
|
3213
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$a({
|
|
3120
3214
|
channel_cid: this.cid
|
|
3121
3215
|
}, opts));
|
|
3122
3216
|
|
|
@@ -3137,6 +3231,258 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3137
3231
|
|
|
3138
3232
|
return unmute;
|
|
3139
3233
|
}()
|
|
3234
|
+
/**
|
|
3235
|
+
* archive - archives the current channel
|
|
3236
|
+
* @param {{ user_id?: string }} opts user_id if called server side
|
|
3237
|
+
* @return {Promise<ChannelMemberResponse<StreamChatGenerics>>} The server response
|
|
3238
|
+
*
|
|
3239
|
+
* example:
|
|
3240
|
+
* await channel.archives();
|
|
3241
|
+
*
|
|
3242
|
+
* example server side:
|
|
3243
|
+
* await channel.archive({user_id: userId});
|
|
3244
|
+
*
|
|
3245
|
+
*/
|
|
3246
|
+
|
|
3247
|
+
}, {
|
|
3248
|
+
key: "archive",
|
|
3249
|
+
value: function () {
|
|
3250
|
+
var _archive = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee25() {
|
|
3251
|
+
var opts,
|
|
3252
|
+
cli,
|
|
3253
|
+
uid,
|
|
3254
|
+
resp,
|
|
3255
|
+
_args25 = arguments;
|
|
3256
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee25$(_context25) {
|
|
3257
|
+
while (1) {
|
|
3258
|
+
switch (_context25.prev = _context25.next) {
|
|
3259
|
+
case 0:
|
|
3260
|
+
opts = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {};
|
|
3261
|
+
cli = this.getClient();
|
|
3262
|
+
uid = opts.user_id || cli.userID;
|
|
3263
|
+
|
|
3264
|
+
if (uid) {
|
|
3265
|
+
_context25.next = 5;
|
|
3266
|
+
break;
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3269
|
+
throw Error('A user_id is required for archiving a channel');
|
|
3270
|
+
|
|
3271
|
+
case 5:
|
|
3272
|
+
_context25.next = 7;
|
|
3273
|
+
return this.partialUpdateMember(uid, {
|
|
3274
|
+
set: {
|
|
3275
|
+
archived: true
|
|
3276
|
+
}
|
|
3277
|
+
});
|
|
3278
|
+
|
|
3279
|
+
case 7:
|
|
3280
|
+
resp = _context25.sent;
|
|
3281
|
+
return _context25.abrupt("return", resp.channel_member);
|
|
3282
|
+
|
|
3283
|
+
case 9:
|
|
3284
|
+
case "end":
|
|
3285
|
+
return _context25.stop();
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
}, _callee25, this);
|
|
3289
|
+
}));
|
|
3290
|
+
|
|
3291
|
+
function archive() {
|
|
3292
|
+
return _archive.apply(this, arguments);
|
|
3293
|
+
}
|
|
3294
|
+
|
|
3295
|
+
return archive;
|
|
3296
|
+
}()
|
|
3297
|
+
/**
|
|
3298
|
+
* unarchive - unarchives the current channel
|
|
3299
|
+
* @param {{ user_id?: string }} opts user_id if called server side
|
|
3300
|
+
* @return {Promise<ChannelMemberResponse<StreamChatGenerics>>} The server response
|
|
3301
|
+
*
|
|
3302
|
+
* example:
|
|
3303
|
+
* await channel.unarchive();
|
|
3304
|
+
*
|
|
3305
|
+
* example server side:
|
|
3306
|
+
* await channel.unarchive({user_id: userId});
|
|
3307
|
+
*
|
|
3308
|
+
*/
|
|
3309
|
+
|
|
3310
|
+
}, {
|
|
3311
|
+
key: "unarchive",
|
|
3312
|
+
value: function () {
|
|
3313
|
+
var _unarchive = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee26() {
|
|
3314
|
+
var opts,
|
|
3315
|
+
cli,
|
|
3316
|
+
uid,
|
|
3317
|
+
resp,
|
|
3318
|
+
_args26 = arguments;
|
|
3319
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee26$(_context26) {
|
|
3320
|
+
while (1) {
|
|
3321
|
+
switch (_context26.prev = _context26.next) {
|
|
3322
|
+
case 0:
|
|
3323
|
+
opts = _args26.length > 0 && _args26[0] !== undefined ? _args26[0] : {};
|
|
3324
|
+
cli = this.getClient();
|
|
3325
|
+
uid = opts.user_id || cli.userID;
|
|
3326
|
+
|
|
3327
|
+
if (uid) {
|
|
3328
|
+
_context26.next = 5;
|
|
3329
|
+
break;
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
throw Error('A user_id is required for unarchiving a channel');
|
|
3333
|
+
|
|
3334
|
+
case 5:
|
|
3335
|
+
_context26.next = 7;
|
|
3336
|
+
return this.partialUpdateMember(uid, {
|
|
3337
|
+
set: {
|
|
3338
|
+
archived: false
|
|
3339
|
+
}
|
|
3340
|
+
});
|
|
3341
|
+
|
|
3342
|
+
case 7:
|
|
3343
|
+
resp = _context26.sent;
|
|
3344
|
+
return _context26.abrupt("return", resp.channel_member);
|
|
3345
|
+
|
|
3346
|
+
case 9:
|
|
3347
|
+
case "end":
|
|
3348
|
+
return _context26.stop();
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
}, _callee26, this);
|
|
3352
|
+
}));
|
|
3353
|
+
|
|
3354
|
+
function unarchive() {
|
|
3355
|
+
return _unarchive.apply(this, arguments);
|
|
3356
|
+
}
|
|
3357
|
+
|
|
3358
|
+
return unarchive;
|
|
3359
|
+
}()
|
|
3360
|
+
/**
|
|
3361
|
+
* pin - pins the current channel
|
|
3362
|
+
* @param {{ user_id?: string }} opts user_id if called server side
|
|
3363
|
+
* @return {Promise<ChannelMemberResponse<StreamChatGenerics>>} The server response
|
|
3364
|
+
*
|
|
3365
|
+
* example:
|
|
3366
|
+
* await channel.pin();
|
|
3367
|
+
*
|
|
3368
|
+
* example server side:
|
|
3369
|
+
* await channel.pin({user_id: userId});
|
|
3370
|
+
*
|
|
3371
|
+
*/
|
|
3372
|
+
|
|
3373
|
+
}, {
|
|
3374
|
+
key: "pin",
|
|
3375
|
+
value: function () {
|
|
3376
|
+
var _pin = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee27() {
|
|
3377
|
+
var opts,
|
|
3378
|
+
cli,
|
|
3379
|
+
uid,
|
|
3380
|
+
resp,
|
|
3381
|
+
_args27 = arguments;
|
|
3382
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee27$(_context27) {
|
|
3383
|
+
while (1) {
|
|
3384
|
+
switch (_context27.prev = _context27.next) {
|
|
3385
|
+
case 0:
|
|
3386
|
+
opts = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : {};
|
|
3387
|
+
cli = this.getClient();
|
|
3388
|
+
uid = opts.user_id || cli.userID;
|
|
3389
|
+
|
|
3390
|
+
if (uid) {
|
|
3391
|
+
_context27.next = 5;
|
|
3392
|
+
break;
|
|
3393
|
+
}
|
|
3394
|
+
|
|
3395
|
+
throw Error('A user_id is required for pinning a channel');
|
|
3396
|
+
|
|
3397
|
+
case 5:
|
|
3398
|
+
_context27.next = 7;
|
|
3399
|
+
return this.partialUpdateMember(uid, {
|
|
3400
|
+
set: {
|
|
3401
|
+
pinned: true
|
|
3402
|
+
}
|
|
3403
|
+
});
|
|
3404
|
+
|
|
3405
|
+
case 7:
|
|
3406
|
+
resp = _context27.sent;
|
|
3407
|
+
return _context27.abrupt("return", resp.channel_member);
|
|
3408
|
+
|
|
3409
|
+
case 9:
|
|
3410
|
+
case "end":
|
|
3411
|
+
return _context27.stop();
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
}, _callee27, this);
|
|
3415
|
+
}));
|
|
3416
|
+
|
|
3417
|
+
function pin() {
|
|
3418
|
+
return _pin.apply(this, arguments);
|
|
3419
|
+
}
|
|
3420
|
+
|
|
3421
|
+
return pin;
|
|
3422
|
+
}()
|
|
3423
|
+
/**
|
|
3424
|
+
* unpin - unpins the current channel
|
|
3425
|
+
* @param {{ user_id?: string }} opts user_id if called server side
|
|
3426
|
+
* @return {Promise<ChannelMemberResponse<StreamChatGenerics>>} The server response
|
|
3427
|
+
*
|
|
3428
|
+
* example:
|
|
3429
|
+
* await channel.unpin();
|
|
3430
|
+
*
|
|
3431
|
+
* example server side:
|
|
3432
|
+
* await channel.unpin({user_id: userId});
|
|
3433
|
+
*
|
|
3434
|
+
*/
|
|
3435
|
+
|
|
3436
|
+
}, {
|
|
3437
|
+
key: "unpin",
|
|
3438
|
+
value: function () {
|
|
3439
|
+
var _unpin = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee28() {
|
|
3440
|
+
var opts,
|
|
3441
|
+
cli,
|
|
3442
|
+
uid,
|
|
3443
|
+
resp,
|
|
3444
|
+
_args28 = arguments;
|
|
3445
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee28$(_context28) {
|
|
3446
|
+
while (1) {
|
|
3447
|
+
switch (_context28.prev = _context28.next) {
|
|
3448
|
+
case 0:
|
|
3449
|
+
opts = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {};
|
|
3450
|
+
cli = this.getClient();
|
|
3451
|
+
uid = opts.user_id || cli.userID;
|
|
3452
|
+
|
|
3453
|
+
if (uid) {
|
|
3454
|
+
_context28.next = 5;
|
|
3455
|
+
break;
|
|
3456
|
+
}
|
|
3457
|
+
|
|
3458
|
+
throw Error('A user_id is required for unpinning a channel');
|
|
3459
|
+
|
|
3460
|
+
case 5:
|
|
3461
|
+
_context28.next = 7;
|
|
3462
|
+
return this.partialUpdateMember(uid, {
|
|
3463
|
+
set: {
|
|
3464
|
+
pinned: false
|
|
3465
|
+
}
|
|
3466
|
+
});
|
|
3467
|
+
|
|
3468
|
+
case 7:
|
|
3469
|
+
resp = _context28.sent;
|
|
3470
|
+
return _context28.abrupt("return", resp.channel_member);
|
|
3471
|
+
|
|
3472
|
+
case 9:
|
|
3473
|
+
case "end":
|
|
3474
|
+
return _context28.stop();
|
|
3475
|
+
}
|
|
3476
|
+
}
|
|
3477
|
+
}, _callee28, this);
|
|
3478
|
+
}));
|
|
3479
|
+
|
|
3480
|
+
function unpin() {
|
|
3481
|
+
return _unpin.apply(this, arguments);
|
|
3482
|
+
}
|
|
3483
|
+
|
|
3484
|
+
return unpin;
|
|
3485
|
+
}()
|
|
3140
3486
|
/**
|
|
3141
3487
|
* muteStatus - returns the mute status for the current channel
|
|
3142
3488
|
* @return {{ muted: boolean; createdAt: Date | null; expiresAt: Date | null }} { muted: true | false, createdAt: Date | null, expiresAt: Date | null}
|
|
@@ -3175,18 +3521,18 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3175
3521
|
}, {
|
|
3176
3522
|
key: "keystroke",
|
|
3177
3523
|
value: function () {
|
|
3178
|
-
var _keystroke = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
3524
|
+
var _keystroke = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee29(parent_id, options) {
|
|
3179
3525
|
var now, diff;
|
|
3180
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
3526
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee29$(_context29) {
|
|
3181
3527
|
while (1) {
|
|
3182
|
-
switch (
|
|
3528
|
+
switch (_context29.prev = _context29.next) {
|
|
3183
3529
|
case 0:
|
|
3184
3530
|
if (this._isTypingIndicatorsEnabled()) {
|
|
3185
|
-
|
|
3531
|
+
_context29.next = 2;
|
|
3186
3532
|
break;
|
|
3187
3533
|
}
|
|
3188
3534
|
|
|
3189
|
-
return
|
|
3535
|
+
return _context29.abrupt("return");
|
|
3190
3536
|
|
|
3191
3537
|
case 2:
|
|
3192
3538
|
now = new Date();
|
|
@@ -3195,23 +3541,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3195
3541
|
this.isTyping = true; // send a typing.start every 2 seconds
|
|
3196
3542
|
|
|
3197
3543
|
if (!(diff === null || diff > 2000)) {
|
|
3198
|
-
|
|
3544
|
+
_context29.next = 10;
|
|
3199
3545
|
break;
|
|
3200
3546
|
}
|
|
3201
3547
|
|
|
3202
3548
|
this.lastTypingEvent = new Date();
|
|
3203
|
-
|
|
3204
|
-
return this.sendEvent(_objectSpread$
|
|
3549
|
+
_context29.next = 10;
|
|
3550
|
+
return this.sendEvent(_objectSpread$a({
|
|
3205
3551
|
type: 'typing.start',
|
|
3206
3552
|
parent_id: parent_id
|
|
3207
3553
|
}, options || {}));
|
|
3208
3554
|
|
|
3209
3555
|
case 10:
|
|
3210
3556
|
case "end":
|
|
3211
|
-
return
|
|
3557
|
+
return _context29.stop();
|
|
3212
3558
|
}
|
|
3213
3559
|
}
|
|
3214
|
-
},
|
|
3560
|
+
}, _callee29, this);
|
|
3215
3561
|
}));
|
|
3216
3562
|
|
|
3217
3563
|
function keystroke(_x27, _x28) {
|
|
@@ -3229,33 +3575,33 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3229
3575
|
}, {
|
|
3230
3576
|
key: "stopTyping",
|
|
3231
3577
|
value: function () {
|
|
3232
|
-
var _stopTyping = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
3233
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
3578
|
+
var _stopTyping = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee30(parent_id, options) {
|
|
3579
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee30$(_context30) {
|
|
3234
3580
|
while (1) {
|
|
3235
|
-
switch (
|
|
3581
|
+
switch (_context30.prev = _context30.next) {
|
|
3236
3582
|
case 0:
|
|
3237
3583
|
if (this._isTypingIndicatorsEnabled()) {
|
|
3238
|
-
|
|
3584
|
+
_context30.next = 2;
|
|
3239
3585
|
break;
|
|
3240
3586
|
}
|
|
3241
3587
|
|
|
3242
|
-
return
|
|
3588
|
+
return _context30.abrupt("return");
|
|
3243
3589
|
|
|
3244
3590
|
case 2:
|
|
3245
3591
|
this.lastTypingEvent = null;
|
|
3246
3592
|
this.isTyping = false;
|
|
3247
|
-
|
|
3248
|
-
return this.sendEvent(_objectSpread$
|
|
3593
|
+
_context30.next = 6;
|
|
3594
|
+
return this.sendEvent(_objectSpread$a({
|
|
3249
3595
|
type: 'typing.stop',
|
|
3250
3596
|
parent_id: parent_id
|
|
3251
3597
|
}, options || {}));
|
|
3252
3598
|
|
|
3253
3599
|
case 6:
|
|
3254
3600
|
case "end":
|
|
3255
|
-
return
|
|
3601
|
+
return _context30.stop();
|
|
3256
3602
|
}
|
|
3257
3603
|
}
|
|
3258
|
-
},
|
|
3604
|
+
}, _callee30, this);
|
|
3259
3605
|
}));
|
|
3260
3606
|
|
|
3261
3607
|
function stopTyping(_x29, _x30) {
|
|
@@ -3310,39 +3656,39 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3310
3656
|
}, {
|
|
3311
3657
|
key: "markRead",
|
|
3312
3658
|
value: function () {
|
|
3313
|
-
var _markRead = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
3659
|
+
var _markRead = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee31() {
|
|
3314
3660
|
var _this$getConfig2;
|
|
3315
3661
|
|
|
3316
3662
|
var data,
|
|
3317
|
-
|
|
3318
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
3663
|
+
_args31 = arguments;
|
|
3664
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee31$(_context31) {
|
|
3319
3665
|
while (1) {
|
|
3320
|
-
switch (
|
|
3666
|
+
switch (_context31.prev = _context31.next) {
|
|
3321
3667
|
case 0:
|
|
3322
|
-
data =
|
|
3668
|
+
data = _args31.length > 0 && _args31[0] !== undefined ? _args31[0] : {};
|
|
3323
3669
|
|
|
3324
3670
|
this._checkInitialized();
|
|
3325
3671
|
|
|
3326
3672
|
if (!(!((_this$getConfig2 = this.getConfig()) !== null && _this$getConfig2 !== void 0 && _this$getConfig2.read_events) && !this.getClient()._isUsingServerAuth())) {
|
|
3327
|
-
|
|
3673
|
+
_context31.next = 4;
|
|
3328
3674
|
break;
|
|
3329
3675
|
}
|
|
3330
3676
|
|
|
3331
|
-
return
|
|
3677
|
+
return _context31.abrupt("return", Promise.resolve(null));
|
|
3332
3678
|
|
|
3333
3679
|
case 4:
|
|
3334
|
-
|
|
3335
|
-
return this.getClient().post(this._channelURL() + '/read', _objectSpread$
|
|
3680
|
+
_context31.next = 6;
|
|
3681
|
+
return this.getClient().post(this._channelURL() + '/read', _objectSpread$a({}, data));
|
|
3336
3682
|
|
|
3337
3683
|
case 6:
|
|
3338
|
-
return
|
|
3684
|
+
return _context31.abrupt("return", _context31.sent);
|
|
3339
3685
|
|
|
3340
3686
|
case 7:
|
|
3341
3687
|
case "end":
|
|
3342
|
-
return
|
|
3688
|
+
return _context31.stop();
|
|
3343
3689
|
}
|
|
3344
3690
|
}
|
|
3345
|
-
},
|
|
3691
|
+
}, _callee31, this);
|
|
3346
3692
|
}));
|
|
3347
3693
|
|
|
3348
3694
|
function markRead() {
|
|
@@ -3361,35 +3707,35 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3361
3707
|
}, {
|
|
3362
3708
|
key: "markUnread",
|
|
3363
3709
|
value: function () {
|
|
3364
|
-
var _markUnread = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
3710
|
+
var _markUnread = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee32(data) {
|
|
3365
3711
|
var _this$getConfig3;
|
|
3366
3712
|
|
|
3367
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
3713
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee32$(_context32) {
|
|
3368
3714
|
while (1) {
|
|
3369
|
-
switch (
|
|
3715
|
+
switch (_context32.prev = _context32.next) {
|
|
3370
3716
|
case 0:
|
|
3371
3717
|
this._checkInitialized();
|
|
3372
3718
|
|
|
3373
3719
|
if (!(!((_this$getConfig3 = this.getConfig()) !== null && _this$getConfig3 !== void 0 && _this$getConfig3.read_events) && !this.getClient()._isUsingServerAuth())) {
|
|
3374
|
-
|
|
3720
|
+
_context32.next = 3;
|
|
3375
3721
|
break;
|
|
3376
3722
|
}
|
|
3377
3723
|
|
|
3378
|
-
return
|
|
3724
|
+
return _context32.abrupt("return", Promise.resolve(null));
|
|
3379
3725
|
|
|
3380
3726
|
case 3:
|
|
3381
|
-
|
|
3382
|
-
return this.getClient().post(this._channelURL() + '/unread', _objectSpread$
|
|
3727
|
+
_context32.next = 5;
|
|
3728
|
+
return this.getClient().post(this._channelURL() + '/unread', _objectSpread$a({}, data));
|
|
3383
3729
|
|
|
3384
3730
|
case 5:
|
|
3385
|
-
return
|
|
3731
|
+
return _context32.abrupt("return", _context32.sent);
|
|
3386
3732
|
|
|
3387
3733
|
case 6:
|
|
3388
3734
|
case "end":
|
|
3389
|
-
return
|
|
3735
|
+
return _context32.stop();
|
|
3390
3736
|
}
|
|
3391
3737
|
}
|
|
3392
|
-
},
|
|
3738
|
+
}, _callee32, this);
|
|
3393
3739
|
}));
|
|
3394
3740
|
|
|
3395
3741
|
function markUnread(_x31) {
|
|
@@ -3427,11 +3773,11 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3427
3773
|
}, {
|
|
3428
3774
|
key: "watch",
|
|
3429
3775
|
value: function () {
|
|
3430
|
-
var _watch = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
3776
|
+
var _watch = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee33(options) {
|
|
3431
3777
|
var defaultOptions, combined, state;
|
|
3432
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
3778
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee33$(_context33) {
|
|
3433
3779
|
while (1) {
|
|
3434
|
-
switch (
|
|
3780
|
+
switch (_context33.prev = _context33.next) {
|
|
3435
3781
|
case 0:
|
|
3436
3782
|
defaultOptions = {
|
|
3437
3783
|
state: true,
|
|
@@ -3439,7 +3785,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3439
3785
|
presence: false
|
|
3440
3786
|
}; // Make sure we wait for the connect promise if there is a pending one
|
|
3441
3787
|
|
|
3442
|
-
|
|
3788
|
+
_context33.next = 3;
|
|
3443
3789
|
return this.getClient().wsPromise;
|
|
3444
3790
|
|
|
3445
3791
|
case 3:
|
|
@@ -3447,12 +3793,12 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3447
3793
|
defaultOptions.watch = false;
|
|
3448
3794
|
}
|
|
3449
3795
|
|
|
3450
|
-
combined = _objectSpread$
|
|
3451
|
-
|
|
3796
|
+
combined = _objectSpread$a(_objectSpread$a({}, defaultOptions), options);
|
|
3797
|
+
_context33.next = 7;
|
|
3452
3798
|
return this.query(combined, 'latest');
|
|
3453
3799
|
|
|
3454
3800
|
case 7:
|
|
3455
|
-
state =
|
|
3801
|
+
state = _context33.sent;
|
|
3456
3802
|
this.initialized = true;
|
|
3457
3803
|
this.data = state.channel;
|
|
3458
3804
|
|
|
@@ -3461,14 +3807,14 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3461
3807
|
channel: this
|
|
3462
3808
|
});
|
|
3463
3809
|
|
|
3464
|
-
return
|
|
3810
|
+
return _context33.abrupt("return", state);
|
|
3465
3811
|
|
|
3466
3812
|
case 12:
|
|
3467
3813
|
case "end":
|
|
3468
|
-
return
|
|
3814
|
+
return _context33.stop();
|
|
3469
3815
|
}
|
|
3470
3816
|
}
|
|
3471
|
-
},
|
|
3817
|
+
}, _callee33, this);
|
|
3472
3818
|
}));
|
|
3473
3819
|
|
|
3474
3820
|
function watch(_x32) {
|
|
@@ -3486,31 +3832,31 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3486
3832
|
}, {
|
|
3487
3833
|
key: "stopWatching",
|
|
3488
3834
|
value: function () {
|
|
3489
|
-
var _stopWatching = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
3835
|
+
var _stopWatching = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee34() {
|
|
3490
3836
|
var response;
|
|
3491
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
3837
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee34$(_context34) {
|
|
3492
3838
|
while (1) {
|
|
3493
|
-
switch (
|
|
3839
|
+
switch (_context34.prev = _context34.next) {
|
|
3494
3840
|
case 0:
|
|
3495
|
-
|
|
3841
|
+
_context34.next = 2;
|
|
3496
3842
|
return this.getClient().post(this._channelURL() + '/stop-watching', {});
|
|
3497
3843
|
|
|
3498
3844
|
case 2:
|
|
3499
|
-
response =
|
|
3845
|
+
response = _context34.sent;
|
|
3500
3846
|
|
|
3501
3847
|
this._client.logger('info', "channel:watch() - stopped watching channel ".concat(this.cid), {
|
|
3502
3848
|
tags: ['channel'],
|
|
3503
3849
|
channel: this
|
|
3504
3850
|
});
|
|
3505
3851
|
|
|
3506
|
-
return
|
|
3852
|
+
return _context34.abrupt("return", response);
|
|
3507
3853
|
|
|
3508
3854
|
case 5:
|
|
3509
3855
|
case "end":
|
|
3510
|
-
return
|
|
3856
|
+
return _context34.stop();
|
|
3511
3857
|
}
|
|
3512
3858
|
}
|
|
3513
|
-
},
|
|
3859
|
+
}, _callee34, this);
|
|
3514
3860
|
}));
|
|
3515
3861
|
|
|
3516
3862
|
function stopWatching() {
|
|
@@ -3533,34 +3879,34 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3533
3879
|
}, {
|
|
3534
3880
|
key: "getReplies",
|
|
3535
3881
|
value: function () {
|
|
3536
|
-
var _getReplies = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
3882
|
+
var _getReplies = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee35(parent_id, options, sort) {
|
|
3537
3883
|
var normalizedSort, data;
|
|
3538
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
3884
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee35$(_context35) {
|
|
3539
3885
|
while (1) {
|
|
3540
|
-
switch (
|
|
3886
|
+
switch (_context35.prev = _context35.next) {
|
|
3541
3887
|
case 0:
|
|
3542
3888
|
normalizedSort = sort ? normalizeQuerySort(sort) : undefined;
|
|
3543
|
-
|
|
3544
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(parent_id), "/replies"), _objectSpread$
|
|
3889
|
+
_context35.next = 3;
|
|
3890
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(parent_id), "/replies"), _objectSpread$a({
|
|
3545
3891
|
sort: normalizedSort
|
|
3546
3892
|
}, options));
|
|
3547
3893
|
|
|
3548
3894
|
case 3:
|
|
3549
|
-
data =
|
|
3895
|
+
data = _context35.sent;
|
|
3550
3896
|
|
|
3551
3897
|
// add any messages to our thread state
|
|
3552
3898
|
if (data.messages) {
|
|
3553
3899
|
this.state.addMessagesSorted(data.messages);
|
|
3554
3900
|
}
|
|
3555
3901
|
|
|
3556
|
-
return
|
|
3902
|
+
return _context35.abrupt("return", data);
|
|
3557
3903
|
|
|
3558
3904
|
case 6:
|
|
3559
3905
|
case "end":
|
|
3560
|
-
return
|
|
3906
|
+
return _context35.stop();
|
|
3561
3907
|
}
|
|
3562
3908
|
}
|
|
3563
|
-
},
|
|
3909
|
+
}, _callee35, this);
|
|
3564
3910
|
}));
|
|
3565
3911
|
|
|
3566
3912
|
function getReplies(_x33, _x34, _x35) {
|
|
@@ -3581,30 +3927,30 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3581
3927
|
}, {
|
|
3582
3928
|
key: "getPinnedMessages",
|
|
3583
3929
|
value: function () {
|
|
3584
|
-
var _getPinnedMessages = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
3930
|
+
var _getPinnedMessages = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee36(options) {
|
|
3585
3931
|
var sort,
|
|
3586
|
-
|
|
3587
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
3932
|
+
_args36 = arguments;
|
|
3933
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee36$(_context36) {
|
|
3588
3934
|
while (1) {
|
|
3589
|
-
switch (
|
|
3935
|
+
switch (_context36.prev = _context36.next) {
|
|
3590
3936
|
case 0:
|
|
3591
|
-
sort =
|
|
3592
|
-
|
|
3937
|
+
sort = _args36.length > 1 && _args36[1] !== undefined ? _args36[1] : [];
|
|
3938
|
+
_context36.next = 3;
|
|
3593
3939
|
return this.getClient().get(this._channelURL() + '/pinned_messages', {
|
|
3594
|
-
payload: _objectSpread$
|
|
3940
|
+
payload: _objectSpread$a(_objectSpread$a({}, options), {}, {
|
|
3595
3941
|
sort: normalizeQuerySort(sort)
|
|
3596
3942
|
})
|
|
3597
3943
|
});
|
|
3598
3944
|
|
|
3599
3945
|
case 3:
|
|
3600
|
-
return
|
|
3946
|
+
return _context36.abrupt("return", _context36.sent);
|
|
3601
3947
|
|
|
3602
3948
|
case 4:
|
|
3603
3949
|
case "end":
|
|
3604
|
-
return
|
|
3950
|
+
return _context36.stop();
|
|
3605
3951
|
}
|
|
3606
3952
|
}
|
|
3607
|
-
},
|
|
3953
|
+
}, _callee36, this);
|
|
3608
3954
|
}));
|
|
3609
3955
|
|
|
3610
3956
|
function getPinnedMessages(_x36) {
|
|
@@ -3625,7 +3971,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3625
3971
|
}, {
|
|
3626
3972
|
key: "getReactions",
|
|
3627
3973
|
value: function getReactions(message_id, options) {
|
|
3628
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(message_id), "/reactions"), _objectSpread$
|
|
3974
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(message_id), "/reactions"), _objectSpread$a({}, options));
|
|
3629
3975
|
}
|
|
3630
3976
|
/**
|
|
3631
3977
|
* getMessagesById - Retrieves a list of messages by ID
|
|
@@ -3743,7 +4089,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3743
4089
|
* @return {Promise<QueryChannelAPIResponse<StreamChatGenerics>>} Returns a query response
|
|
3744
4090
|
*/
|
|
3745
4091
|
function () {
|
|
3746
|
-
var _query = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
4092
|
+
var _query = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee37(options) {
|
|
3747
4093
|
var _options$messages$lim, _options$messages, _this$data6, _this$data7;
|
|
3748
4094
|
|
|
3749
4095
|
var messageSetToAddToIfDoesNotExist,
|
|
@@ -3754,14 +4100,14 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3754
4100
|
_this$_initializeStat,
|
|
3755
4101
|
messageSet,
|
|
3756
4102
|
areCapabilitiesChanged,
|
|
3757
|
-
|
|
4103
|
+
_args37 = arguments;
|
|
3758
4104
|
|
|
3759
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
4105
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee37$(_context37) {
|
|
3760
4106
|
while (1) {
|
|
3761
|
-
switch (
|
|
4107
|
+
switch (_context37.prev = _context37.next) {
|
|
3762
4108
|
case 0:
|
|
3763
|
-
messageSetToAddToIfDoesNotExist =
|
|
3764
|
-
|
|
4109
|
+
messageSetToAddToIfDoesNotExist = _args37.length > 1 && _args37[1] !== undefined ? _args37[1] : 'current';
|
|
4110
|
+
_context37.next = 3;
|
|
3765
4111
|
return this.getClient().wsPromise;
|
|
3766
4112
|
|
|
3767
4113
|
case 3:
|
|
@@ -3771,14 +4117,14 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3771
4117
|
queryURL += "/".concat(encodeURIComponent(this.id));
|
|
3772
4118
|
}
|
|
3773
4119
|
|
|
3774
|
-
|
|
3775
|
-
return this.getClient().post(queryURL + '/query', _objectSpread$
|
|
4120
|
+
_context37.next = 7;
|
|
4121
|
+
return this.getClient().post(queryURL + '/query', _objectSpread$a({
|
|
3776
4122
|
data: this._data,
|
|
3777
4123
|
state: true
|
|
3778
4124
|
}, options));
|
|
3779
4125
|
|
|
3780
4126
|
case 7:
|
|
3781
|
-
state =
|
|
4127
|
+
state = _context37.sent;
|
|
3782
4128
|
|
|
3783
4129
|
// update the channel id if it was missing
|
|
3784
4130
|
if (!this.id) {
|
|
@@ -3807,13 +4153,14 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3807
4153
|
|
|
3808
4154
|
|
|
3809
4155
|
_this$_initializeStat = this._initializeState(state, messageSetToAddToIfDoesNotExist), messageSet = _this$_initializeStat.messageSet;
|
|
3810
|
-
messageSet.pagination = _objectSpread$
|
|
4156
|
+
messageSet.pagination = _objectSpread$a(_objectSpread$a({}, messageSet.pagination), messageSetPagination({
|
|
3811
4157
|
parentSet: messageSet,
|
|
3812
4158
|
messagePaginationOptions: options === null || options === void 0 ? void 0 : options.messages,
|
|
3813
4159
|
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,
|
|
3814
4160
|
returnedPage: state.messages,
|
|
3815
4161
|
logger: this.getClient().logger
|
|
3816
4162
|
}));
|
|
4163
|
+
this.getClient().polls.hydratePollCache(messageSet.messages, true);
|
|
3817
4164
|
areCapabilitiesChanged = _toConsumableArray__default['default'](state.channel.own_capabilities || []).sort().join() !== _toConsumableArray__default['default'](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();
|
|
3818
4165
|
this.data = state.channel;
|
|
3819
4166
|
this.offlineMode = false;
|
|
@@ -3833,14 +4180,14 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3833
4180
|
isLatestMessageSet: messageSet.isLatest
|
|
3834
4181
|
}
|
|
3835
4182
|
});
|
|
3836
|
-
return
|
|
4183
|
+
return _context37.abrupt("return", state);
|
|
3837
4184
|
|
|
3838
|
-
case
|
|
4185
|
+
case 19:
|
|
3839
4186
|
case "end":
|
|
3840
|
-
return
|
|
4187
|
+
return _context37.stop();
|
|
3841
4188
|
}
|
|
3842
4189
|
}
|
|
3843
|
-
},
|
|
4190
|
+
}, _callee37, this);
|
|
3844
4191
|
}));
|
|
3845
4192
|
|
|
3846
4193
|
function query(_x37) {
|
|
@@ -3860,28 +4207,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3860
4207
|
}, {
|
|
3861
4208
|
key: "banUser",
|
|
3862
4209
|
value: function () {
|
|
3863
|
-
var _banUser = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
3864
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
4210
|
+
var _banUser = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee38(targetUserID, options) {
|
|
4211
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee38$(_context38) {
|
|
3865
4212
|
while (1) {
|
|
3866
|
-
switch (
|
|
4213
|
+
switch (_context38.prev = _context38.next) {
|
|
3867
4214
|
case 0:
|
|
3868
4215
|
this._checkInitialized();
|
|
3869
4216
|
|
|
3870
|
-
|
|
3871
|
-
return this.getClient().banUser(targetUserID, _objectSpread$
|
|
4217
|
+
_context38.next = 3;
|
|
4218
|
+
return this.getClient().banUser(targetUserID, _objectSpread$a(_objectSpread$a({}, options), {}, {
|
|
3872
4219
|
type: this.type,
|
|
3873
4220
|
id: this.id
|
|
3874
4221
|
}));
|
|
3875
4222
|
|
|
3876
4223
|
case 3:
|
|
3877
|
-
return
|
|
4224
|
+
return _context38.abrupt("return", _context38.sent);
|
|
3878
4225
|
|
|
3879
4226
|
case 4:
|
|
3880
4227
|
case "end":
|
|
3881
|
-
return
|
|
4228
|
+
return _context38.stop();
|
|
3882
4229
|
}
|
|
3883
4230
|
}
|
|
3884
|
-
},
|
|
4231
|
+
}, _callee38, this);
|
|
3885
4232
|
}));
|
|
3886
4233
|
|
|
3887
4234
|
function banUser(_x38, _x39) {
|
|
@@ -3902,34 +4249,34 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3902
4249
|
}, {
|
|
3903
4250
|
key: "hide",
|
|
3904
4251
|
value: function () {
|
|
3905
|
-
var _hide = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
4252
|
+
var _hide = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee39() {
|
|
3906
4253
|
var userId,
|
|
3907
4254
|
clearHistory,
|
|
3908
|
-
|
|
3909
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
4255
|
+
_args39 = arguments;
|
|
4256
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee39$(_context39) {
|
|
3910
4257
|
while (1) {
|
|
3911
|
-
switch (
|
|
4258
|
+
switch (_context39.prev = _context39.next) {
|
|
3912
4259
|
case 0:
|
|
3913
|
-
userId =
|
|
3914
|
-
clearHistory =
|
|
4260
|
+
userId = _args39.length > 0 && _args39[0] !== undefined ? _args39[0] : null;
|
|
4261
|
+
clearHistory = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : false;
|
|
3915
4262
|
|
|
3916
4263
|
this._checkInitialized();
|
|
3917
4264
|
|
|
3918
|
-
|
|
4265
|
+
_context39.next = 5;
|
|
3919
4266
|
return this.getClient().post("".concat(this._channelURL(), "/hide"), {
|
|
3920
4267
|
user_id: userId,
|
|
3921
4268
|
clear_history: clearHistory
|
|
3922
4269
|
});
|
|
3923
4270
|
|
|
3924
4271
|
case 5:
|
|
3925
|
-
return
|
|
4272
|
+
return _context39.abrupt("return", _context39.sent);
|
|
3926
4273
|
|
|
3927
4274
|
case 6:
|
|
3928
4275
|
case "end":
|
|
3929
|
-
return
|
|
4276
|
+
return _context39.stop();
|
|
3930
4277
|
}
|
|
3931
4278
|
}
|
|
3932
|
-
},
|
|
4279
|
+
}, _callee39, this);
|
|
3933
4280
|
}));
|
|
3934
4281
|
|
|
3935
4282
|
function hide() {
|
|
@@ -3948,31 +4295,31 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3948
4295
|
}, {
|
|
3949
4296
|
key: "show",
|
|
3950
4297
|
value: function () {
|
|
3951
|
-
var _show = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
4298
|
+
var _show = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee40() {
|
|
3952
4299
|
var userId,
|
|
3953
|
-
|
|
3954
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
4300
|
+
_args40 = arguments;
|
|
4301
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee40$(_context40) {
|
|
3955
4302
|
while (1) {
|
|
3956
|
-
switch (
|
|
4303
|
+
switch (_context40.prev = _context40.next) {
|
|
3957
4304
|
case 0:
|
|
3958
|
-
userId =
|
|
4305
|
+
userId = _args40.length > 0 && _args40[0] !== undefined ? _args40[0] : null;
|
|
3959
4306
|
|
|
3960
4307
|
this._checkInitialized();
|
|
3961
4308
|
|
|
3962
|
-
|
|
4309
|
+
_context40.next = 4;
|
|
3963
4310
|
return this.getClient().post("".concat(this._channelURL(), "/show"), {
|
|
3964
4311
|
user_id: userId
|
|
3965
4312
|
});
|
|
3966
4313
|
|
|
3967
4314
|
case 4:
|
|
3968
|
-
return
|
|
4315
|
+
return _context40.abrupt("return", _context40.sent);
|
|
3969
4316
|
|
|
3970
4317
|
case 5:
|
|
3971
4318
|
case "end":
|
|
3972
|
-
return
|
|
4319
|
+
return _context40.stop();
|
|
3973
4320
|
}
|
|
3974
4321
|
}
|
|
3975
|
-
},
|
|
4322
|
+
}, _callee40, this);
|
|
3976
4323
|
}));
|
|
3977
4324
|
|
|
3978
4325
|
function show() {
|
|
@@ -3991,28 +4338,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3991
4338
|
}, {
|
|
3992
4339
|
key: "unbanUser",
|
|
3993
4340
|
value: function () {
|
|
3994
|
-
var _unbanUser = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
3995
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
4341
|
+
var _unbanUser = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee41(targetUserID) {
|
|
4342
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee41$(_context41) {
|
|
3996
4343
|
while (1) {
|
|
3997
|
-
switch (
|
|
4344
|
+
switch (_context41.prev = _context41.next) {
|
|
3998
4345
|
case 0:
|
|
3999
4346
|
this._checkInitialized();
|
|
4000
4347
|
|
|
4001
|
-
|
|
4348
|
+
_context41.next = 3;
|
|
4002
4349
|
return this.getClient().unbanUser(targetUserID, {
|
|
4003
4350
|
type: this.type,
|
|
4004
4351
|
id: this.id
|
|
4005
4352
|
});
|
|
4006
4353
|
|
|
4007
4354
|
case 3:
|
|
4008
|
-
return
|
|
4355
|
+
return _context41.abrupt("return", _context41.sent);
|
|
4009
4356
|
|
|
4010
4357
|
case 4:
|
|
4011
4358
|
case "end":
|
|
4012
|
-
return
|
|
4359
|
+
return _context41.stop();
|
|
4013
4360
|
}
|
|
4014
4361
|
}
|
|
4015
|
-
},
|
|
4362
|
+
}, _callee41, this);
|
|
4016
4363
|
}));
|
|
4017
4364
|
|
|
4018
4365
|
function unbanUser(_x40) {
|
|
@@ -4032,28 +4379,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4032
4379
|
}, {
|
|
4033
4380
|
key: "shadowBan",
|
|
4034
4381
|
value: function () {
|
|
4035
|
-
var _shadowBan = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
4036
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
4382
|
+
var _shadowBan = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee42(targetUserID, options) {
|
|
4383
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee42$(_context42) {
|
|
4037
4384
|
while (1) {
|
|
4038
|
-
switch (
|
|
4385
|
+
switch (_context42.prev = _context42.next) {
|
|
4039
4386
|
case 0:
|
|
4040
4387
|
this._checkInitialized();
|
|
4041
4388
|
|
|
4042
|
-
|
|
4043
|
-
return this.getClient().shadowBan(targetUserID, _objectSpread$
|
|
4389
|
+
_context42.next = 3;
|
|
4390
|
+
return this.getClient().shadowBan(targetUserID, _objectSpread$a(_objectSpread$a({}, options), {}, {
|
|
4044
4391
|
type: this.type,
|
|
4045
4392
|
id: this.id
|
|
4046
4393
|
}));
|
|
4047
4394
|
|
|
4048
4395
|
case 3:
|
|
4049
|
-
return
|
|
4396
|
+
return _context42.abrupt("return", _context42.sent);
|
|
4050
4397
|
|
|
4051
4398
|
case 4:
|
|
4052
4399
|
case "end":
|
|
4053
|
-
return
|
|
4400
|
+
return _context42.stop();
|
|
4054
4401
|
}
|
|
4055
4402
|
}
|
|
4056
|
-
},
|
|
4403
|
+
}, _callee42, this);
|
|
4057
4404
|
}));
|
|
4058
4405
|
|
|
4059
4406
|
function shadowBan(_x41, _x42) {
|
|
@@ -4072,28 +4419,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4072
4419
|
}, {
|
|
4073
4420
|
key: "removeShadowBan",
|
|
4074
4421
|
value: function () {
|
|
4075
|
-
var _removeShadowBan = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
4076
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
4422
|
+
var _removeShadowBan = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee43(targetUserID) {
|
|
4423
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee43$(_context43) {
|
|
4077
4424
|
while (1) {
|
|
4078
|
-
switch (
|
|
4425
|
+
switch (_context43.prev = _context43.next) {
|
|
4079
4426
|
case 0:
|
|
4080
4427
|
this._checkInitialized();
|
|
4081
4428
|
|
|
4082
|
-
|
|
4429
|
+
_context43.next = 3;
|
|
4083
4430
|
return this.getClient().removeShadowBan(targetUserID, {
|
|
4084
4431
|
type: this.type,
|
|
4085
4432
|
id: this.id
|
|
4086
4433
|
});
|
|
4087
4434
|
|
|
4088
4435
|
case 3:
|
|
4089
|
-
return
|
|
4436
|
+
return _context43.abrupt("return", _context43.sent);
|
|
4090
4437
|
|
|
4091
4438
|
case 4:
|
|
4092
4439
|
case "end":
|
|
4093
|
-
return
|
|
4440
|
+
return _context43.stop();
|
|
4094
4441
|
}
|
|
4095
4442
|
}
|
|
4096
|
-
},
|
|
4443
|
+
}, _callee43, this);
|
|
4097
4444
|
}));
|
|
4098
4445
|
|
|
4099
4446
|
function removeShadowBan(_x43) {
|
|
@@ -4112,23 +4459,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4112
4459
|
}, {
|
|
4113
4460
|
key: "createCall",
|
|
4114
4461
|
value: function () {
|
|
4115
|
-
var _createCall = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
4116
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
4462
|
+
var _createCall = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee44(options) {
|
|
4463
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee44$(_context44) {
|
|
4117
4464
|
while (1) {
|
|
4118
|
-
switch (
|
|
4465
|
+
switch (_context44.prev = _context44.next) {
|
|
4119
4466
|
case 0:
|
|
4120
|
-
|
|
4467
|
+
_context44.next = 2;
|
|
4121
4468
|
return this.getClient().post(this._channelURL() + '/call', options);
|
|
4122
4469
|
|
|
4123
4470
|
case 2:
|
|
4124
|
-
return
|
|
4471
|
+
return _context44.abrupt("return", _context44.sent);
|
|
4125
4472
|
|
|
4126
4473
|
case 3:
|
|
4127
4474
|
case "end":
|
|
4128
|
-
return
|
|
4475
|
+
return _context44.stop();
|
|
4129
4476
|
}
|
|
4130
4477
|
}
|
|
4131
|
-
},
|
|
4478
|
+
}, _callee44, this);
|
|
4132
4479
|
}));
|
|
4133
4480
|
|
|
4134
4481
|
function createCall(_x44) {
|
|
@@ -4147,23 +4494,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4147
4494
|
}, {
|
|
4148
4495
|
key: "vote",
|
|
4149
4496
|
value: function () {
|
|
4150
|
-
var _vote2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
4151
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
4497
|
+
var _vote2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee45(messageId, pollId, _vote) {
|
|
4498
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee45$(_context45) {
|
|
4152
4499
|
while (1) {
|
|
4153
|
-
switch (
|
|
4500
|
+
switch (_context45.prev = _context45.next) {
|
|
4154
4501
|
case 0:
|
|
4155
|
-
|
|
4502
|
+
_context45.next = 2;
|
|
4156
4503
|
return this.getClient().castPollVote(messageId, pollId, _vote);
|
|
4157
4504
|
|
|
4158
4505
|
case 2:
|
|
4159
|
-
return
|
|
4506
|
+
return _context45.abrupt("return", _context45.sent);
|
|
4160
4507
|
|
|
4161
4508
|
case 3:
|
|
4162
4509
|
case "end":
|
|
4163
|
-
return
|
|
4510
|
+
return _context45.stop();
|
|
4164
4511
|
}
|
|
4165
4512
|
}
|
|
4166
|
-
},
|
|
4513
|
+
}, _callee45, this);
|
|
4167
4514
|
}));
|
|
4168
4515
|
|
|
4169
4516
|
function vote(_x45, _x46, _x47) {
|
|
@@ -4175,23 +4522,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4175
4522
|
}, {
|
|
4176
4523
|
key: "removeVote",
|
|
4177
4524
|
value: function () {
|
|
4178
|
-
var _removeVote = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
4179
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
4525
|
+
var _removeVote = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee46(messageId, pollId, voteId) {
|
|
4526
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee46$(_context46) {
|
|
4180
4527
|
while (1) {
|
|
4181
|
-
switch (
|
|
4528
|
+
switch (_context46.prev = _context46.next) {
|
|
4182
4529
|
case 0:
|
|
4183
|
-
|
|
4530
|
+
_context46.next = 2;
|
|
4184
4531
|
return this.getClient().removePollVote(messageId, pollId, voteId);
|
|
4185
4532
|
|
|
4186
4533
|
case 2:
|
|
4187
|
-
return
|
|
4534
|
+
return _context46.abrupt("return", _context46.sent);
|
|
4188
4535
|
|
|
4189
4536
|
case 3:
|
|
4190
4537
|
case "end":
|
|
4191
|
-
return
|
|
4538
|
+
return _context46.stop();
|
|
4192
4539
|
}
|
|
4193
4540
|
}
|
|
4194
|
-
},
|
|
4541
|
+
}, _callee46, this);
|
|
4195
4542
|
}));
|
|
4196
4543
|
|
|
4197
4544
|
function removeVote(_x48, _x49, _x50) {
|
|
@@ -4494,7 +4841,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4494
4841
|
});
|
|
4495
4842
|
}
|
|
4496
4843
|
|
|
4497
|
-
channel.data = _objectSpread$
|
|
4844
|
+
channel.data = _objectSpread$a(_objectSpread$a({}, event.channel), {}, {
|
|
4498
4845
|
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,
|
|
4499
4846
|
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
|
|
4500
4847
|
});
|
|
@@ -4502,49 +4849,6 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4502
4849
|
|
|
4503
4850
|
break;
|
|
4504
4851
|
|
|
4505
|
-
case 'poll.updated':
|
|
4506
|
-
if (event.poll) {
|
|
4507
|
-
var _event$message;
|
|
4508
|
-
|
|
4509
|
-
channelState.updatePoll(event.poll, ((_event$message = event.message) === null || _event$message === void 0 ? void 0 : _event$message.id) || '');
|
|
4510
|
-
}
|
|
4511
|
-
|
|
4512
|
-
break;
|
|
4513
|
-
|
|
4514
|
-
case 'poll.vote_casted':
|
|
4515
|
-
if (event.poll_vote && event.poll) {
|
|
4516
|
-
var _event$message2;
|
|
4517
|
-
|
|
4518
|
-
channelState.addPollVote(event.poll_vote, event.poll, ((_event$message2 = event.message) === null || _event$message2 === void 0 ? void 0 : _event$message2.id) || '');
|
|
4519
|
-
}
|
|
4520
|
-
|
|
4521
|
-
break;
|
|
4522
|
-
|
|
4523
|
-
case 'poll.vote_changed':
|
|
4524
|
-
if (event.poll_vote && event.poll) {
|
|
4525
|
-
var _event$message3;
|
|
4526
|
-
|
|
4527
|
-
channelState.updatePollVote(event.poll_vote, event.poll, ((_event$message3 = event.message) === null || _event$message3 === void 0 ? void 0 : _event$message3.id) || '');
|
|
4528
|
-
}
|
|
4529
|
-
|
|
4530
|
-
break;
|
|
4531
|
-
|
|
4532
|
-
case 'poll.vote_removed':
|
|
4533
|
-
if (event.poll_vote && event.poll) {
|
|
4534
|
-
var _event$message4;
|
|
4535
|
-
|
|
4536
|
-
channelState.removePollVote(event.poll_vote, event.poll, ((_event$message4 = event.message) === null || _event$message4 === void 0 ? void 0 : _event$message4.id) || '');
|
|
4537
|
-
}
|
|
4538
|
-
|
|
4539
|
-
break;
|
|
4540
|
-
|
|
4541
|
-
case 'poll.closed':
|
|
4542
|
-
if (event.message) {
|
|
4543
|
-
channelState.addMessageSorted(event.message, false, false);
|
|
4544
|
-
}
|
|
4545
|
-
|
|
4546
|
-
break;
|
|
4547
|
-
|
|
4548
4852
|
case 'reaction.new':
|
|
4549
4853
|
if (event.message && event.reaction) {
|
|
4550
4854
|
event.message = channelState.addReaction(event.reaction, event.message);
|
|
@@ -4568,7 +4872,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4568
4872
|
break;
|
|
4569
4873
|
|
|
4570
4874
|
case 'channel.hidden':
|
|
4571
|
-
channel.data = _objectSpread$
|
|
4875
|
+
channel.data = _objectSpread$a(_objectSpread$a({}, channel.data), {}, {
|
|
4572
4876
|
hidden: true
|
|
4573
4877
|
});
|
|
4574
4878
|
|
|
@@ -4579,26 +4883,26 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4579
4883
|
break;
|
|
4580
4884
|
|
|
4581
4885
|
case 'channel.visible':
|
|
4582
|
-
channel.data = _objectSpread$
|
|
4886
|
+
channel.data = _objectSpread$a(_objectSpread$a({}, channel.data), {}, {
|
|
4583
4887
|
hidden: false
|
|
4584
4888
|
});
|
|
4585
4889
|
break;
|
|
4586
4890
|
|
|
4587
4891
|
case 'user.banned':
|
|
4588
4892
|
if (!((_event$user11 = event.user) !== null && _event$user11 !== void 0 && _event$user11.id)) break;
|
|
4589
|
-
channelState.members[event.user.id] = _objectSpread$
|
|
4893
|
+
channelState.members[event.user.id] = _objectSpread$a(_objectSpread$a({}, channelState.members[event.user.id] || {}), {}, {
|
|
4590
4894
|
shadow_banned: !!event.shadow,
|
|
4591
4895
|
banned: !event.shadow,
|
|
4592
|
-
user: _objectSpread$
|
|
4896
|
+
user: _objectSpread$a(_objectSpread$a({}, ((_channelState$members = channelState.members[event.user.id]) === null || _channelState$members === void 0 ? void 0 : _channelState$members.user) || {}), event.user)
|
|
4593
4897
|
});
|
|
4594
4898
|
break;
|
|
4595
4899
|
|
|
4596
4900
|
case 'user.unbanned':
|
|
4597
4901
|
if (!((_event$user12 = event.user) !== null && _event$user12 !== void 0 && _event$user12.id)) break;
|
|
4598
|
-
channelState.members[event.user.id] = _objectSpread$
|
|
4902
|
+
channelState.members[event.user.id] = _objectSpread$a(_objectSpread$a({}, channelState.members[event.user.id] || {}), {}, {
|
|
4599
4903
|
shadow_banned: false,
|
|
4600
4904
|
banned: false,
|
|
4601
|
-
user: _objectSpread$
|
|
4905
|
+
user: _objectSpread$a(_objectSpread$a({}, ((_channelState$members2 = channelState.members[event.user.id]) === null || _channelState$members2 === void 0 ? void 0 : _channelState$members2.user) || {}), event.user)
|
|
4602
4906
|
});
|
|
4603
4907
|
break;
|
|
4604
4908
|
} // any event can send over the online count
|
|
@@ -4628,7 +4932,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4628
4932
|
|
|
4629
4933
|
|
|
4630
4934
|
if (state.members) {
|
|
4631
|
-
var _iterator = _createForOfIteratorHelper$
|
|
4935
|
+
var _iterator = _createForOfIteratorHelper$4(state.members),
|
|
4632
4936
|
_step;
|
|
4633
4937
|
|
|
4634
4938
|
try {
|
|
@@ -4672,7 +4976,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4672
4976
|
|
|
4673
4977
|
|
|
4674
4978
|
if (state.watchers) {
|
|
4675
|
-
var _iterator2 = _createForOfIteratorHelper$
|
|
4979
|
+
var _iterator2 = _createForOfIteratorHelper$4(state.watchers),
|
|
4676
4980
|
_step2;
|
|
4677
4981
|
|
|
4678
4982
|
try {
|
|
@@ -4708,7 +5012,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4708
5012
|
|
|
4709
5013
|
|
|
4710
5014
|
if (state.read) {
|
|
4711
|
-
var _iterator3 = _createForOfIteratorHelper$
|
|
5015
|
+
var _iterator3 = _createForOfIteratorHelper$4(state.read),
|
|
4712
5016
|
_step3;
|
|
4713
5017
|
|
|
4714
5018
|
try {
|
|
@@ -4782,11 +5086,11 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4782
5086
|
return Channel;
|
|
4783
5087
|
}();
|
|
4784
5088
|
|
|
4785
|
-
function _createForOfIteratorHelper$
|
|
5089
|
+
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; } } }; }
|
|
4786
5090
|
|
|
4787
|
-
function _unsupportedIterableToArray$
|
|
5091
|
+
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); }
|
|
4788
5092
|
|
|
4789
|
-
function _arrayLikeToArray$
|
|
5093
|
+
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; }
|
|
4790
5094
|
|
|
4791
5095
|
/**
|
|
4792
5096
|
* ClientState - A container class for the client state.
|
|
@@ -4809,7 +5113,7 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
4809
5113
|
_createClass__default['default'](ClientState, [{
|
|
4810
5114
|
key: "updateUsers",
|
|
4811
5115
|
value: function updateUsers(users) {
|
|
4812
|
-
var _iterator = _createForOfIteratorHelper$
|
|
5116
|
+
var _iterator = _createForOfIteratorHelper$3(users),
|
|
4813
5117
|
_step;
|
|
4814
5118
|
|
|
4815
5119
|
try {
|
|
@@ -4857,9 +5161,9 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
4857
5161
|
return ClientState;
|
|
4858
5162
|
}();
|
|
4859
5163
|
|
|
4860
|
-
function ownKeys$
|
|
5164
|
+
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; }
|
|
4861
5165
|
|
|
4862
|
-
function _objectSpread$
|
|
5166
|
+
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__default['default'](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; }
|
|
4863
5167
|
var InsightMetrics = function InsightMetrics() {
|
|
4864
5168
|
_classCallCheck__default['default'](this, InsightMetrics);
|
|
4865
5169
|
|
|
@@ -4938,7 +5242,7 @@ var postInsights = /*#__PURE__*/function () {
|
|
|
4938
5242
|
};
|
|
4939
5243
|
}();
|
|
4940
5244
|
function buildWsFatalInsight(connection, event) {
|
|
4941
|
-
return _objectSpread$
|
|
5245
|
+
return _objectSpread$9(_objectSpread$9({}, event), buildWsBaseInsight(connection));
|
|
4942
5246
|
}
|
|
4943
5247
|
|
|
4944
5248
|
function buildWsBaseInsight(connection) {
|
|
@@ -4971,9 +5275,9 @@ function buildWsSuccessAfterFailureInsight(connection) {
|
|
|
4971
5275
|
return buildWsBaseInsight(connection);
|
|
4972
5276
|
}
|
|
4973
5277
|
|
|
4974
|
-
function ownKeys$
|
|
5278
|
+
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; }
|
|
4975
5279
|
|
|
4976
|
-
function _objectSpread$
|
|
5280
|
+
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__default['default'](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; }
|
|
4977
5281
|
|
|
4978
5282
|
// Type guards to check WebSocket error type
|
|
4979
5283
|
var isCloseEvent = function isCloseEvent(res) {
|
|
@@ -5337,7 +5641,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
5337
5641
|
value: function _log(msg) {
|
|
5338
5642
|
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5339
5643
|
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5340
|
-
this.client.logger(level, 'connection:' + msg, _objectSpread$
|
|
5644
|
+
this.client.logger(level, 'connection:' + msg, _objectSpread$8({
|
|
5341
5645
|
tags: ['connection']
|
|
5342
5646
|
}, extra));
|
|
5343
5647
|
}
|
|
@@ -5928,9 +6232,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
5928
6232
|
return StableWSConnection;
|
|
5929
6233
|
}();
|
|
5930
6234
|
|
|
5931
|
-
function ownKeys$
|
|
6235
|
+
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; }
|
|
5932
6236
|
|
|
5933
|
-
function _objectSpread$
|
|
6237
|
+
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__default['default'](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; }
|
|
5934
6238
|
|
|
5935
6239
|
/**
|
|
5936
6240
|
* Creates the JWT token that can be used for a UserSession
|
|
@@ -5951,7 +6255,7 @@ function JWTUserToken(apiSecret, userId) {
|
|
|
5951
6255
|
throw new TypeError('userId should be a string');
|
|
5952
6256
|
}
|
|
5953
6257
|
|
|
5954
|
-
var payload = _objectSpread$
|
|
6258
|
+
var payload = _objectSpread$7({
|
|
5955
6259
|
user_id: userId
|
|
5956
6260
|
}, extraData); // make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
5957
6261
|
|
|
@@ -6361,9 +6665,9 @@ function isErrorResponse(res) {
|
|
|
6361
6665
|
return !res.status || res.status < 200 || 300 <= res.status;
|
|
6362
6666
|
}
|
|
6363
6667
|
|
|
6364
|
-
function ownKeys$
|
|
6668
|
+
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; }
|
|
6365
6669
|
|
|
6366
|
-
function _objectSpread$
|
|
6670
|
+
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__default['default'](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; }
|
|
6367
6671
|
var ConnectionState;
|
|
6368
6672
|
|
|
6369
6673
|
(function (ConnectionState) {
|
|
@@ -6426,7 +6730,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
6426
6730
|
_context.next = 4;
|
|
6427
6731
|
return _this.client.doAxiosRequest('get', _this.client.baseURL.replace(':3030', ':8900') + '/longpoll', // replace port if present for testing with local API
|
|
6428
6732
|
undefined, {
|
|
6429
|
-
config: _objectSpread$
|
|
6733
|
+
config: _objectSpread$6(_objectSpread$6({}, config), {}, {
|
|
6430
6734
|
cancelToken: (_this$cancelToken2 = _this.cancelToken) === null || _this$cancelToken2 === void 0 ? void 0 : _this$cancelToken2.token
|
|
6431
6735
|
}),
|
|
6432
6736
|
params: params
|
|
@@ -6704,7 +7008,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
6704
7008
|
value: function _log(msg) {
|
|
6705
7009
|
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6706
7010
|
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
6707
|
-
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$
|
|
7011
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$6({
|
|
6708
7012
|
tags: ['connection_fallback', 'connection']
|
|
6709
7013
|
}, extra));
|
|
6710
7014
|
}
|
|
@@ -6737,53 +7041,45 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
6737
7041
|
return WSConnectionFallback;
|
|
6738
7042
|
}();
|
|
6739
7043
|
|
|
6740
|
-
var
|
|
6741
|
-
function
|
|
6742
|
-
_classCallCheck__default['default'](this,
|
|
7044
|
+
var Segment = /*#__PURE__*/function () {
|
|
7045
|
+
function Segment(client, type, id, data) {
|
|
7046
|
+
_classCallCheck__default['default'](this, Segment);
|
|
6743
7047
|
|
|
6744
|
-
_defineProperty__default['default'](this, "
|
|
7048
|
+
_defineProperty__default['default'](this, "type", void 0);
|
|
6745
7049
|
|
|
6746
|
-
_defineProperty__default['default'](this, "
|
|
7050
|
+
_defineProperty__default['default'](this, "id", void 0);
|
|
6747
7051
|
|
|
6748
7052
|
_defineProperty__default['default'](this, "client", void 0);
|
|
6749
7053
|
|
|
7054
|
+
_defineProperty__default['default'](this, "data", void 0);
|
|
7055
|
+
|
|
6750
7056
|
this.client = client;
|
|
7057
|
+
this.type = type;
|
|
6751
7058
|
this.id = id;
|
|
6752
7059
|
this.data = data;
|
|
6753
7060
|
}
|
|
6754
7061
|
|
|
6755
|
-
_createClass__default['default'](
|
|
7062
|
+
_createClass__default['default'](Segment, [{
|
|
6756
7063
|
key: "create",
|
|
6757
7064
|
value: function () {
|
|
6758
7065
|
var _create = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
|
6759
|
-
var _this$data, _this$data2, _this$data3, _this$data4, _this$data5
|
|
7066
|
+
var _this$data, _this$data2, _this$data3, _this$data4, _this$data5;
|
|
6760
7067
|
|
|
6761
|
-
var body
|
|
7068
|
+
var body;
|
|
6762
7069
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
6763
7070
|
while (1) {
|
|
6764
7071
|
switch (_context.prev = _context.next) {
|
|
6765
7072
|
case 0:
|
|
6766
7073
|
body = {
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
create_channels: (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5.create_channels,
|
|
6773
|
-
description: (_this$data6 = this.data) === null || _this$data6 === void 0 ? void 0 : _this$data6.description,
|
|
6774
|
-
name: (_this$data7 = this.data) === null || _this$data7 === void 0 ? void 0 : _this$data7.name,
|
|
6775
|
-
user_ids: (_this$data8 = this.data) === null || _this$data8 === void 0 ? void 0 : _this$data8.user_ids
|
|
7074
|
+
name: (_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.name,
|
|
7075
|
+
filter: (_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2.filter,
|
|
7076
|
+
description: (_this$data3 = this.data) === null || _this$data3 === void 0 ? void 0 : _this$data3.description,
|
|
7077
|
+
all_sender_channels: (_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : _this$data4.all_sender_channels,
|
|
7078
|
+
all_users: (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5.all_users
|
|
6776
7079
|
};
|
|
6777
|
-
_context.
|
|
6778
|
-
return this.client.createCampaign(body);
|
|
6779
|
-
|
|
6780
|
-
case 3:
|
|
6781
|
-
result = _context.sent;
|
|
6782
|
-
this.id = result.campaign.id;
|
|
6783
|
-
this.data = result.campaign;
|
|
6784
|
-
return _context.abrupt("return", result);
|
|
7080
|
+
return _context.abrupt("return", this.client.createSegment(this.type, this.id, body));
|
|
6785
7081
|
|
|
6786
|
-
case
|
|
7082
|
+
case 2:
|
|
6787
7083
|
case "end":
|
|
6788
7084
|
return _context.stop();
|
|
6789
7085
|
}
|
|
@@ -6798,211 +7094,14 @@ var Campaign = /*#__PURE__*/function () {
|
|
|
6798
7094
|
return create;
|
|
6799
7095
|
}()
|
|
6800
7096
|
}, {
|
|
6801
|
-
key: "
|
|
6802
|
-
value: function
|
|
7097
|
+
key: "verifySegmentId",
|
|
7098
|
+
value: function verifySegmentId() {
|
|
6803
7099
|
if (!this.id) {
|
|
6804
|
-
throw new Error('
|
|
7100
|
+
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)');
|
|
6805
7101
|
}
|
|
6806
7102
|
}
|
|
6807
7103
|
}, {
|
|
6808
|
-
key: "
|
|
6809
|
-
value: function () {
|
|
6810
|
-
var _start = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2(options) {
|
|
6811
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
6812
|
-
while (1) {
|
|
6813
|
-
switch (_context2.prev = _context2.next) {
|
|
6814
|
-
case 0:
|
|
6815
|
-
this.verifyCampaignId();
|
|
6816
|
-
_context2.next = 3;
|
|
6817
|
-
return this.client.startCampaign(this.id, options);
|
|
6818
|
-
|
|
6819
|
-
case 3:
|
|
6820
|
-
return _context2.abrupt("return", _context2.sent);
|
|
6821
|
-
|
|
6822
|
-
case 4:
|
|
6823
|
-
case "end":
|
|
6824
|
-
return _context2.stop();
|
|
6825
|
-
}
|
|
6826
|
-
}
|
|
6827
|
-
}, _callee2, this);
|
|
6828
|
-
}));
|
|
6829
|
-
|
|
6830
|
-
function start(_x) {
|
|
6831
|
-
return _start.apply(this, arguments);
|
|
6832
|
-
}
|
|
6833
|
-
|
|
6834
|
-
return start;
|
|
6835
|
-
}()
|
|
6836
|
-
}, {
|
|
6837
|
-
key: "update",
|
|
6838
|
-
value: function () {
|
|
6839
|
-
var _update = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(data) {
|
|
6840
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
6841
|
-
while (1) {
|
|
6842
|
-
switch (_context3.prev = _context3.next) {
|
|
6843
|
-
case 0:
|
|
6844
|
-
this.verifyCampaignId();
|
|
6845
|
-
return _context3.abrupt("return", this.client.updateCampaign(this.id, data));
|
|
6846
|
-
|
|
6847
|
-
case 2:
|
|
6848
|
-
case "end":
|
|
6849
|
-
return _context3.stop();
|
|
6850
|
-
}
|
|
6851
|
-
}
|
|
6852
|
-
}, _callee3, this);
|
|
6853
|
-
}));
|
|
6854
|
-
|
|
6855
|
-
function update(_x2) {
|
|
6856
|
-
return _update.apply(this, arguments);
|
|
6857
|
-
}
|
|
6858
|
-
|
|
6859
|
-
return update;
|
|
6860
|
-
}()
|
|
6861
|
-
}, {
|
|
6862
|
-
key: "delete",
|
|
6863
|
-
value: function () {
|
|
6864
|
-
var _delete2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4() {
|
|
6865
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
6866
|
-
while (1) {
|
|
6867
|
-
switch (_context4.prev = _context4.next) {
|
|
6868
|
-
case 0:
|
|
6869
|
-
this.verifyCampaignId();
|
|
6870
|
-
_context4.next = 3;
|
|
6871
|
-
return this.client.deleteCampaign(this.id);
|
|
6872
|
-
|
|
6873
|
-
case 3:
|
|
6874
|
-
return _context4.abrupt("return", _context4.sent);
|
|
6875
|
-
|
|
6876
|
-
case 4:
|
|
6877
|
-
case "end":
|
|
6878
|
-
return _context4.stop();
|
|
6879
|
-
}
|
|
6880
|
-
}
|
|
6881
|
-
}, _callee4, this);
|
|
6882
|
-
}));
|
|
6883
|
-
|
|
6884
|
-
function _delete() {
|
|
6885
|
-
return _delete2.apply(this, arguments);
|
|
6886
|
-
}
|
|
6887
|
-
|
|
6888
|
-
return _delete;
|
|
6889
|
-
}()
|
|
6890
|
-
}, {
|
|
6891
|
-
key: "stop",
|
|
6892
|
-
value: function () {
|
|
6893
|
-
var _stop = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5() {
|
|
6894
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
6895
|
-
while (1) {
|
|
6896
|
-
switch (_context5.prev = _context5.next) {
|
|
6897
|
-
case 0:
|
|
6898
|
-
this.verifyCampaignId();
|
|
6899
|
-
return _context5.abrupt("return", this.client.stopCampaign(this.id));
|
|
6900
|
-
|
|
6901
|
-
case 2:
|
|
6902
|
-
case "end":
|
|
6903
|
-
return _context5.stop();
|
|
6904
|
-
}
|
|
6905
|
-
}
|
|
6906
|
-
}, _callee5, this);
|
|
6907
|
-
}));
|
|
6908
|
-
|
|
6909
|
-
function stop() {
|
|
6910
|
-
return _stop.apply(this, arguments);
|
|
6911
|
-
}
|
|
6912
|
-
|
|
6913
|
-
return stop;
|
|
6914
|
-
}()
|
|
6915
|
-
}, {
|
|
6916
|
-
key: "get",
|
|
6917
|
-
value: function () {
|
|
6918
|
-
var _get = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
|
|
6919
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
|
6920
|
-
while (1) {
|
|
6921
|
-
switch (_context6.prev = _context6.next) {
|
|
6922
|
-
case 0:
|
|
6923
|
-
this.verifyCampaignId();
|
|
6924
|
-
return _context6.abrupt("return", this.client.getCampaign(this.id));
|
|
6925
|
-
|
|
6926
|
-
case 2:
|
|
6927
|
-
case "end":
|
|
6928
|
-
return _context6.stop();
|
|
6929
|
-
}
|
|
6930
|
-
}
|
|
6931
|
-
}, _callee6, this);
|
|
6932
|
-
}));
|
|
6933
|
-
|
|
6934
|
-
function get() {
|
|
6935
|
-
return _get.apply(this, arguments);
|
|
6936
|
-
}
|
|
6937
|
-
|
|
6938
|
-
return get;
|
|
6939
|
-
}()
|
|
6940
|
-
}]);
|
|
6941
|
-
|
|
6942
|
-
return Campaign;
|
|
6943
|
-
}();
|
|
6944
|
-
|
|
6945
|
-
var Segment = /*#__PURE__*/function () {
|
|
6946
|
-
function Segment(client, type, id, data) {
|
|
6947
|
-
_classCallCheck__default['default'](this, Segment);
|
|
6948
|
-
|
|
6949
|
-
_defineProperty__default['default'](this, "type", void 0);
|
|
6950
|
-
|
|
6951
|
-
_defineProperty__default['default'](this, "id", void 0);
|
|
6952
|
-
|
|
6953
|
-
_defineProperty__default['default'](this, "client", void 0);
|
|
6954
|
-
|
|
6955
|
-
_defineProperty__default['default'](this, "data", void 0);
|
|
6956
|
-
|
|
6957
|
-
this.client = client;
|
|
6958
|
-
this.type = type;
|
|
6959
|
-
this.id = id;
|
|
6960
|
-
this.data = data;
|
|
6961
|
-
}
|
|
6962
|
-
|
|
6963
|
-
_createClass__default['default'](Segment, [{
|
|
6964
|
-
key: "create",
|
|
6965
|
-
value: function () {
|
|
6966
|
-
var _create = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
|
6967
|
-
var _this$data, _this$data2, _this$data3, _this$data4, _this$data5;
|
|
6968
|
-
|
|
6969
|
-
var body;
|
|
6970
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
6971
|
-
while (1) {
|
|
6972
|
-
switch (_context.prev = _context.next) {
|
|
6973
|
-
case 0:
|
|
6974
|
-
body = {
|
|
6975
|
-
name: (_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.name,
|
|
6976
|
-
filter: (_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2.filter,
|
|
6977
|
-
description: (_this$data3 = this.data) === null || _this$data3 === void 0 ? void 0 : _this$data3.description,
|
|
6978
|
-
all_sender_channels: (_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : _this$data4.all_sender_channels,
|
|
6979
|
-
all_users: (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5.all_users
|
|
6980
|
-
};
|
|
6981
|
-
return _context.abrupt("return", this.client.createSegment(this.type, this.id, body));
|
|
6982
|
-
|
|
6983
|
-
case 2:
|
|
6984
|
-
case "end":
|
|
6985
|
-
return _context.stop();
|
|
6986
|
-
}
|
|
6987
|
-
}
|
|
6988
|
-
}, _callee, this);
|
|
6989
|
-
}));
|
|
6990
|
-
|
|
6991
|
-
function create() {
|
|
6992
|
-
return _create.apply(this, arguments);
|
|
6993
|
-
}
|
|
6994
|
-
|
|
6995
|
-
return create;
|
|
6996
|
-
}()
|
|
6997
|
-
}, {
|
|
6998
|
-
key: "verifySegmentId",
|
|
6999
|
-
value: function verifySegmentId() {
|
|
7000
|
-
if (!this.id) {
|
|
7001
|
-
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)');
|
|
7002
|
-
}
|
|
7003
|
-
}
|
|
7004
|
-
}, {
|
|
7005
|
-
key: "get",
|
|
7104
|
+
key: "get",
|
|
7006
7105
|
value: function () {
|
|
7007
7106
|
var _get = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
7008
7107
|
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
@@ -7284,9 +7383,9 @@ exports.VotingVisibility = void 0;
|
|
|
7284
7383
|
VotingVisibility["public"] = "public";
|
|
7285
7384
|
})(exports.VotingVisibility || (exports.VotingVisibility = {}));
|
|
7286
7385
|
|
|
7287
|
-
function ownKeys$
|
|
7386
|
+
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; }
|
|
7288
7387
|
|
|
7289
|
-
function _objectSpread$
|
|
7388
|
+
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__default['default'](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; }
|
|
7290
7389
|
|
|
7291
7390
|
function isPatch(value) {
|
|
7292
7391
|
return typeof value === 'function';
|
|
@@ -7316,7 +7415,7 @@ var StateStore = function StateStore(value) {
|
|
|
7316
7415
|
|
|
7317
7416
|
_defineProperty__default['default'](this, "partialNext", function (partial) {
|
|
7318
7417
|
return _this.next(function (current) {
|
|
7319
|
-
return _objectSpread$
|
|
7418
|
+
return _objectSpread$5(_objectSpread$5({}, current), partial);
|
|
7320
7419
|
});
|
|
7321
7420
|
});
|
|
7322
7421
|
|
|
@@ -7366,11 +7465,11 @@ var StateStore = function StateStore(value) {
|
|
|
7366
7465
|
|
|
7367
7466
|
_defineProperty__default['default'](StateStore, "logCount", 5);
|
|
7368
7467
|
|
|
7369
|
-
var _excluded$
|
|
7468
|
+
var _excluded$2 = ["limit", "sort"];
|
|
7370
7469
|
|
|
7371
|
-
function ownKeys$
|
|
7470
|
+
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; }
|
|
7372
7471
|
|
|
7373
|
-
function _objectSpread$
|
|
7472
|
+
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__default['default'](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; }
|
|
7374
7473
|
var DEFAULT_PAGE_LIMIT = 50;
|
|
7375
7474
|
var DEFAULT_SORT = [{
|
|
7376
7475
|
created_at: -1
|
|
@@ -7599,14 +7698,14 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7599
7698
|
if (userId === ((_event$user2 = event.user) === null || _event$user2 === void 0 ? void 0 : _event$user2.id)) {
|
|
7600
7699
|
// The user who just sent a message to the thread has no unread messages
|
|
7601
7700
|
// in that thread
|
|
7602
|
-
nextUserRead = _objectSpread$
|
|
7701
|
+
nextUserRead = _objectSpread$4(_objectSpread$4({}, nextUserRead), {}, {
|
|
7603
7702
|
lastReadAt: event.created_at ? new Date(event.created_at) : new Date(),
|
|
7604
7703
|
user: event.user,
|
|
7605
7704
|
unreadMessageCount: 0
|
|
7606
7705
|
});
|
|
7607
7706
|
} else if (active && userId === _this.client.userID) ; else {
|
|
7608
7707
|
// Increment unread count for all users except the author of the new message
|
|
7609
|
-
nextUserRead = _objectSpread$
|
|
7708
|
+
nextUserRead = _objectSpread$4(_objectSpread$4({}, nextUserRead), {}, {
|
|
7610
7709
|
unreadMessageCount: userRead.unreadMessageCount + 1
|
|
7611
7710
|
});
|
|
7612
7711
|
}
|
|
@@ -7630,8 +7729,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7630
7729
|
var user = event.user;
|
|
7631
7730
|
|
|
7632
7731
|
_this.state.next(function (current) {
|
|
7633
|
-
return _objectSpread$
|
|
7634
|
-
read: _objectSpread$
|
|
7732
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7733
|
+
read: _objectSpread$4(_objectSpread$4({}, current.read), {}, _defineProperty__default['default']({}, userId, {
|
|
7635
7734
|
lastReadAt: new Date(createdAt),
|
|
7636
7735
|
user: user,
|
|
7637
7736
|
lastReadMessageId: event.last_read_message_id,
|
|
@@ -7742,7 +7841,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7742
7841
|
}
|
|
7743
7842
|
|
|
7744
7843
|
_this.state.next(function (current) {
|
|
7745
|
-
return _objectSpread$
|
|
7844
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7746
7845
|
replies: addToMessageList(current.replies, formattedMessage, timestampChanged)
|
|
7747
7846
|
});
|
|
7748
7847
|
});
|
|
@@ -7759,7 +7858,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7759
7858
|
var _message$reply_count;
|
|
7760
7859
|
|
|
7761
7860
|
var formattedMessage = formatMessage(message);
|
|
7762
|
-
return _objectSpread$
|
|
7861
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7763
7862
|
deletedAt: formattedMessage.deleted_at,
|
|
7764
7863
|
parentMessage: formattedMessage,
|
|
7765
7864
|
replyCount: (_message$reply_count = message.reply_count) !== null && _message$reply_count !== void 0 ? _message$reply_count : current.replyCount
|
|
@@ -7830,9 +7929,9 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7830
7929
|
limit = _ref10$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref10$limit,
|
|
7831
7930
|
_ref10$sort = _ref10.sort,
|
|
7832
7931
|
sort = _ref10$sort === void 0 ? DEFAULT_SORT : _ref10$sort,
|
|
7833
|
-
otherOptions = _objectWithoutProperties__default['default'](_ref10, _excluded$
|
|
7932
|
+
otherOptions = _objectWithoutProperties__default['default'](_ref10, _excluded$2);
|
|
7834
7933
|
|
|
7835
|
-
return _this.channel.getReplies(_this.id, _objectSpread$
|
|
7934
|
+
return _this.channel.getReplies(_this.id, _objectSpread$4({
|
|
7836
7935
|
limit: limit
|
|
7837
7936
|
}, otherOptions), sort);
|
|
7838
7937
|
});
|
|
@@ -7876,12 +7975,12 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7876
7975
|
limit = Math.abs(count);
|
|
7877
7976
|
|
|
7878
7977
|
_this.state.partialNext({
|
|
7879
|
-
pagination: _objectSpread$
|
|
7978
|
+
pagination: _objectSpread$4(_objectSpread$4({}, pagination), {}, _defineProperty__default['default']({}, loadingKey, true))
|
|
7880
7979
|
});
|
|
7881
7980
|
|
|
7882
7981
|
_context3.prev = 7;
|
|
7883
7982
|
_context3.next = 10;
|
|
7884
|
-
return _this.queryReplies(_objectSpread$
|
|
7983
|
+
return _this.queryReplies(_objectSpread$4(_objectSpread$4({}, queryOptions), {}, {
|
|
7885
7984
|
limit: limit
|
|
7886
7985
|
}));
|
|
7887
7986
|
|
|
@@ -7903,9 +8002,9 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7903
8002
|
(_nextReplies = nextReplies)[insertionMethodKey].apply(_nextReplies, _toConsumableArray__default['default'](replies));
|
|
7904
8003
|
}
|
|
7905
8004
|
|
|
7906
|
-
return _objectSpread$
|
|
8005
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7907
8006
|
replies: nextReplies,
|
|
7908
|
-
pagination: _objectSpread$
|
|
8007
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, (_objectSpread4 = {}, _defineProperty__default['default'](_objectSpread4, cursorKey, data.messages.length < limit ? null : maybeNextCursor), _defineProperty__default['default'](_objectSpread4, loadingKey, false), _objectSpread4))
|
|
7909
8008
|
});
|
|
7910
8009
|
});
|
|
7911
8010
|
|
|
@@ -7919,8 +8018,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7919
8018
|
_this.client.logger('error', _context3.t0.message);
|
|
7920
8019
|
|
|
7921
8020
|
_this.state.next(function (current) {
|
|
7922
|
-
return _objectSpread$
|
|
7923
|
-
pagination: _objectSpread$
|
|
8021
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
8022
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, _defineProperty__default['default']({}, loadingKey, false))
|
|
7924
8023
|
});
|
|
7925
8024
|
});
|
|
7926
8025
|
|
|
@@ -8025,9 +8124,9 @@ var ownUnreadCountSelector = function ownUnreadCountSelector(currentUserId) {
|
|
|
8025
8124
|
};
|
|
8026
8125
|
};
|
|
8027
8126
|
|
|
8028
|
-
function ownKeys$
|
|
8127
|
+
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; }
|
|
8029
8128
|
|
|
8030
|
-
function _objectSpread$
|
|
8129
|
+
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__default['default'](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; }
|
|
8031
8130
|
var MODERATION_ENTITY_TYPES = {
|
|
8032
8131
|
user: 'stream:user',
|
|
8033
8132
|
message: 'stream:chat:v1:message'
|
|
@@ -8144,7 +8243,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8144
8243
|
case 0:
|
|
8145
8244
|
options = _args3.length > 4 && _args3[4] !== undefined ? _args3[4] : {};
|
|
8146
8245
|
_context3.next = 3;
|
|
8147
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/flag', _objectSpread$
|
|
8246
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/flag', _objectSpread$3({
|
|
8148
8247
|
entity_type: entityType,
|
|
8149
8248
|
entity_id: entityId,
|
|
8150
8249
|
entity_creator_id: entityCreatorID,
|
|
@@ -8189,7 +8288,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8189
8288
|
case 0:
|
|
8190
8289
|
options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
8191
8290
|
_context4.next = 3;
|
|
8192
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/mute', _objectSpread$
|
|
8291
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/mute', _objectSpread$3({
|
|
8193
8292
|
target_ids: [targetID]
|
|
8194
8293
|
}, options));
|
|
8195
8294
|
|
|
@@ -8227,7 +8326,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8227
8326
|
switch (_context5.prev = _context5.next) {
|
|
8228
8327
|
case 0:
|
|
8229
8328
|
_context5.next = 2;
|
|
8230
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/unmute', _objectSpread$
|
|
8329
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/unmute', _objectSpread$3({
|
|
8231
8330
|
target_ids: [targetID]
|
|
8232
8331
|
}, options));
|
|
8233
8332
|
|
|
@@ -8269,7 +8368,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8269
8368
|
case 0:
|
|
8270
8369
|
options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
8271
8370
|
_context6.next = 3;
|
|
8272
|
-
return this.client.get(this.client.baseURL + "/api/v2/moderation/user_report", _objectSpread$
|
|
8371
|
+
return this.client.get(this.client.baseURL + "/api/v2/moderation/user_report", _objectSpread$3({
|
|
8273
8372
|
user_id: userID
|
|
8274
8373
|
}, options));
|
|
8275
8374
|
|
|
@@ -8313,7 +8412,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8313
8412
|
sort = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : [];
|
|
8314
8413
|
options = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : {};
|
|
8315
8414
|
_context7.next = 5;
|
|
8316
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/review_queue', _objectSpread$
|
|
8415
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/review_queue', _objectSpread$3({
|
|
8317
8416
|
filter: filterConditions,
|
|
8318
8417
|
sort: normalizeQuerySort(sort)
|
|
8319
8418
|
}, options));
|
|
@@ -8405,26 +8504,20 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8405
8504
|
return getConfig;
|
|
8406
8505
|
}()
|
|
8407
8506
|
}, {
|
|
8408
|
-
key: "
|
|
8507
|
+
key: "deleteConfig",
|
|
8409
8508
|
value: function () {
|
|
8410
|
-
var
|
|
8411
|
-
var options,
|
|
8412
|
-
_args10 = arguments;
|
|
8509
|
+
var _deleteConfig = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee10(key) {
|
|
8413
8510
|
return _regeneratorRuntime__default['default'].wrap(function _callee10$(_context10) {
|
|
8414
8511
|
while (1) {
|
|
8415
8512
|
switch (_context10.prev = _context10.next) {
|
|
8416
8513
|
case 0:
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/submit_action', _objectSpread$2({
|
|
8420
|
-
action_type: actionType,
|
|
8421
|
-
item_id: itemID
|
|
8422
|
-
}, options));
|
|
8514
|
+
_context10.next = 2;
|
|
8515
|
+
return this.client.delete(this.client.baseURL + '/api/v2/moderation/config/' + key);
|
|
8423
8516
|
|
|
8424
|
-
case
|
|
8517
|
+
case 2:
|
|
8425
8518
|
return _context10.abrupt("return", _context10.sent);
|
|
8426
8519
|
|
|
8427
|
-
case
|
|
8520
|
+
case 3:
|
|
8428
8521
|
case "end":
|
|
8429
8522
|
return _context10.stop();
|
|
8430
8523
|
}
|
|
@@ -8432,30 +8525,154 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8432
8525
|
}, _callee10, this);
|
|
8433
8526
|
}));
|
|
8434
8527
|
|
|
8435
|
-
function
|
|
8436
|
-
return
|
|
8528
|
+
function deleteConfig(_x14) {
|
|
8529
|
+
return _deleteConfig.apply(this, arguments);
|
|
8437
8530
|
}
|
|
8438
8531
|
|
|
8439
|
-
return
|
|
8532
|
+
return deleteConfig;
|
|
8440
8533
|
}()
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
}
|
|
8534
|
+
/**
|
|
8535
|
+
* Query moderation configs
|
|
8536
|
+
* @param {Object} filterConditions Filter conditions for querying moderation configs
|
|
8537
|
+
* @param {Object} sort Sort conditions for querying moderation configs
|
|
8538
|
+
* @param {Object} options Additional options for querying moderation configs
|
|
8539
|
+
*/
|
|
8445
8540
|
|
|
8446
|
-
|
|
8541
|
+
}, {
|
|
8542
|
+
key: "queryConfigs",
|
|
8543
|
+
value: function () {
|
|
8544
|
+
var _queryConfigs = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee11(filterConditions, sort) {
|
|
8545
|
+
var options,
|
|
8546
|
+
_args11 = arguments;
|
|
8547
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee11$(_context11) {
|
|
8548
|
+
while (1) {
|
|
8549
|
+
switch (_context11.prev = _context11.next) {
|
|
8550
|
+
case 0:
|
|
8551
|
+
options = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : {};
|
|
8552
|
+
_context11.next = 3;
|
|
8553
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/configs', _objectSpread$3({
|
|
8554
|
+
filter: filterConditions,
|
|
8555
|
+
sort: sort
|
|
8556
|
+
}, options));
|
|
8447
8557
|
|
|
8448
|
-
|
|
8558
|
+
case 3:
|
|
8559
|
+
return _context11.abrupt("return", _context11.sent);
|
|
8449
8560
|
|
|
8450
|
-
|
|
8561
|
+
case 4:
|
|
8562
|
+
case "end":
|
|
8563
|
+
return _context11.stop();
|
|
8564
|
+
}
|
|
8565
|
+
}
|
|
8566
|
+
}, _callee11, this);
|
|
8567
|
+
}));
|
|
8451
8568
|
|
|
8452
|
-
function
|
|
8569
|
+
function queryConfigs(_x15, _x16) {
|
|
8570
|
+
return _queryConfigs.apply(this, arguments);
|
|
8571
|
+
}
|
|
8453
8572
|
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8573
|
+
return queryConfigs;
|
|
8574
|
+
}()
|
|
8575
|
+
}, {
|
|
8576
|
+
key: "submitAction",
|
|
8577
|
+
value: function () {
|
|
8578
|
+
var _submitAction = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee12(actionType, itemID) {
|
|
8579
|
+
var options,
|
|
8580
|
+
_args12 = arguments;
|
|
8581
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee12$(_context12) {
|
|
8582
|
+
while (1) {
|
|
8583
|
+
switch (_context12.prev = _context12.next) {
|
|
8584
|
+
case 0:
|
|
8585
|
+
options = _args12.length > 2 && _args12[2] !== undefined ? _args12[2] : {};
|
|
8586
|
+
_context12.next = 3;
|
|
8587
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/submit_action', _objectSpread$3({
|
|
8588
|
+
action_type: actionType,
|
|
8589
|
+
item_id: itemID
|
|
8590
|
+
}, options));
|
|
8591
|
+
|
|
8592
|
+
case 3:
|
|
8593
|
+
return _context12.abrupt("return", _context12.sent);
|
|
8594
|
+
|
|
8595
|
+
case 4:
|
|
8596
|
+
case "end":
|
|
8597
|
+
return _context12.stop();
|
|
8598
|
+
}
|
|
8599
|
+
}
|
|
8600
|
+
}, _callee12, this);
|
|
8601
|
+
}));
|
|
8602
|
+
|
|
8603
|
+
function submitAction(_x17, _x18) {
|
|
8604
|
+
return _submitAction.apply(this, arguments);
|
|
8605
|
+
}
|
|
8606
|
+
|
|
8607
|
+
return submitAction;
|
|
8608
|
+
}()
|
|
8609
|
+
/**
|
|
8610
|
+
*
|
|
8611
|
+
* @param {string} entityType string Type of entity to be checked E.g., stream:user, stream:chat:v1:message, or any custom string
|
|
8612
|
+
* @param {string} entityID string ID of the entity to be checked. This is mainly for tracking purposes
|
|
8613
|
+
* @param {string} entityCreatorID string ID of the entity creator
|
|
8614
|
+
* @param {object} moderationPayload object Content to be checked for moderation. E.g., { texts: ['text1', 'text2'], images: ['image1', 'image2']}
|
|
8615
|
+
* @param {Array} moderationPayload.texts array Array of texts to be checked for moderation
|
|
8616
|
+
* @param {Array} moderationPayload.images array Array of images to be checked for moderation
|
|
8617
|
+
* @param {Array} moderationPayload.videos array Array of videos to be checked for moderation
|
|
8618
|
+
* @param configKey
|
|
8619
|
+
* @param options
|
|
8620
|
+
* @returns
|
|
8621
|
+
*/
|
|
8622
|
+
|
|
8623
|
+
}, {
|
|
8624
|
+
key: "check",
|
|
8625
|
+
value: function () {
|
|
8626
|
+
var _check = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee13(entityType, entityID, entityCreatorID, moderationPayload, configKey, options) {
|
|
8627
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee13$(_context13) {
|
|
8628
|
+
while (1) {
|
|
8629
|
+
switch (_context13.prev = _context13.next) {
|
|
8630
|
+
case 0:
|
|
8631
|
+
_context13.next = 2;
|
|
8632
|
+
return this.client.post(this.client.baseURL + "/api/v2/moderation/check", {
|
|
8633
|
+
entity_type: entityType,
|
|
8634
|
+
entity_id: entityID,
|
|
8635
|
+
entity_creator_id: entityCreatorID,
|
|
8636
|
+
moderation_payload: moderationPayload,
|
|
8637
|
+
config_key: configKey,
|
|
8638
|
+
options: options
|
|
8639
|
+
});
|
|
8640
|
+
|
|
8641
|
+
case 2:
|
|
8642
|
+
return _context13.abrupt("return", _context13.sent);
|
|
8643
|
+
|
|
8644
|
+
case 3:
|
|
8645
|
+
case "end":
|
|
8646
|
+
return _context13.stop();
|
|
8647
|
+
}
|
|
8648
|
+
}
|
|
8649
|
+
}, _callee13, this);
|
|
8650
|
+
}));
|
|
8651
|
+
|
|
8652
|
+
function check(_x19, _x20, _x21, _x22, _x23, _x24) {
|
|
8653
|
+
return _check.apply(this, arguments);
|
|
8654
|
+
}
|
|
8655
|
+
|
|
8656
|
+
return check;
|
|
8657
|
+
}()
|
|
8658
|
+
}]);
|
|
8659
|
+
|
|
8660
|
+
return Moderation;
|
|
8661
|
+
}();
|
|
8662
|
+
|
|
8663
|
+
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; } } }; }
|
|
8664
|
+
|
|
8665
|
+
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); }
|
|
8666
|
+
|
|
8667
|
+
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; }
|
|
8668
|
+
|
|
8669
|
+
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; }
|
|
8670
|
+
|
|
8671
|
+
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__default['default'](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; }
|
|
8672
|
+
var DEFAULT_CONNECTION_RECOVERY_THROTTLE_DURATION = 1000;
|
|
8673
|
+
var MAX_QUERY_THREADS_LIMIT = 25;
|
|
8674
|
+
var ThreadManager = /*#__PURE__*/function () {
|
|
8675
|
+
function ThreadManager(_ref) {
|
|
8459
8676
|
var _this = this;
|
|
8460
8677
|
|
|
8461
8678
|
var client = _ref.client;
|
|
@@ -8595,7 +8812,7 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
8595
8812
|
var unsubscribeConnectionDropped = _this.client.on('connection.changed', function (event) {
|
|
8596
8813
|
if (event.online === false) {
|
|
8597
8814
|
_this.state.next(function (current) {
|
|
8598
|
-
return current.lastConnectionDropAt ? current : _objectSpread$
|
|
8815
|
+
return current.lastConnectionDropAt ? current : _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8599
8816
|
lastConnectionDropAt: new Date()
|
|
8600
8817
|
});
|
|
8601
8818
|
});
|
|
@@ -8682,213 +8899,1219 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
8682
8899
|
_context.prev = 7;
|
|
8683
8900
|
|
|
8684
8901
|
_this.state.next(function (current) {
|
|
8685
|
-
return _objectSpread$
|
|
8686
|
-
pagination: _objectSpread$
|
|
8902
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8903
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
8687
8904
|
isLoading: true
|
|
8688
8905
|
})
|
|
8689
8906
|
});
|
|
8690
8907
|
});
|
|
8691
8908
|
|
|
8692
|
-
_context.next = 11;
|
|
8693
|
-
return _this.queryThreads({
|
|
8694
|
-
limit: Math.min(limit, MAX_QUERY_THREADS_LIMIT) || MAX_QUERY_THREADS_LIMIT
|
|
8695
|
-
});
|
|
8909
|
+
_context.next = 11;
|
|
8910
|
+
return _this.queryThreads({
|
|
8911
|
+
limit: Math.min(limit, MAX_QUERY_THREADS_LIMIT) || MAX_QUERY_THREADS_LIMIT
|
|
8912
|
+
});
|
|
8913
|
+
|
|
8914
|
+
case 11:
|
|
8915
|
+
response = _context.sent;
|
|
8916
|
+
currentThreads = _this.threadsById;
|
|
8917
|
+
nextThreads = [];
|
|
8918
|
+
_iterator = _createForOfIteratorHelper$2(response.threads);
|
|
8919
|
+
|
|
8920
|
+
try {
|
|
8921
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
8922
|
+
incomingThread = _step.value;
|
|
8923
|
+
existingThread = currentThreads[incomingThread.id];
|
|
8924
|
+
|
|
8925
|
+
if (existingThread) {
|
|
8926
|
+
// Reuse thread instances if possible
|
|
8927
|
+
nextThreads.push(existingThread);
|
|
8928
|
+
|
|
8929
|
+
if (existingThread.hasStaleState) {
|
|
8930
|
+
existingThread.hydrateState(incomingThread);
|
|
8931
|
+
}
|
|
8932
|
+
} else {
|
|
8933
|
+
nextThreads.push(incomingThread);
|
|
8934
|
+
}
|
|
8935
|
+
}
|
|
8936
|
+
} catch (err) {
|
|
8937
|
+
_iterator.e(err);
|
|
8938
|
+
} finally {
|
|
8939
|
+
_iterator.f();
|
|
8940
|
+
}
|
|
8941
|
+
|
|
8942
|
+
_this.state.next(function (current) {
|
|
8943
|
+
var _response$next;
|
|
8944
|
+
|
|
8945
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8946
|
+
threads: nextThreads,
|
|
8947
|
+
unseenThreadIds: [],
|
|
8948
|
+
isThreadOrderStale: false,
|
|
8949
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
8950
|
+
isLoading: false,
|
|
8951
|
+
nextCursor: (_response$next = response.next) !== null && _response$next !== void 0 ? _response$next : null
|
|
8952
|
+
}),
|
|
8953
|
+
ready: true
|
|
8954
|
+
});
|
|
8955
|
+
});
|
|
8956
|
+
|
|
8957
|
+
_context.next = 23;
|
|
8958
|
+
break;
|
|
8959
|
+
|
|
8960
|
+
case 19:
|
|
8961
|
+
_context.prev = 19;
|
|
8962
|
+
_context.t0 = _context["catch"](7);
|
|
8963
|
+
|
|
8964
|
+
_this.client.logger('error', _context.t0.message);
|
|
8965
|
+
|
|
8966
|
+
_this.state.next(function (current) {
|
|
8967
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8968
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
8969
|
+
isLoading: false
|
|
8970
|
+
})
|
|
8971
|
+
});
|
|
8972
|
+
});
|
|
8973
|
+
|
|
8974
|
+
case 23:
|
|
8975
|
+
case "end":
|
|
8976
|
+
return _context.stop();
|
|
8977
|
+
}
|
|
8978
|
+
}
|
|
8979
|
+
}, _callee, null, [[7, 19]]);
|
|
8980
|
+
})));
|
|
8981
|
+
|
|
8982
|
+
_defineProperty__default['default'](this, "queryThreads", function () {
|
|
8983
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8984
|
+
return _this.client.queryThreads(_objectSpread$2({
|
|
8985
|
+
limit: 25,
|
|
8986
|
+
participant_limit: 10,
|
|
8987
|
+
reply_limit: 10,
|
|
8988
|
+
watch: true
|
|
8989
|
+
}, options));
|
|
8990
|
+
});
|
|
8991
|
+
|
|
8992
|
+
_defineProperty__default['default'](this, "loadNextPage", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
8993
|
+
var options,
|
|
8994
|
+
_this$state$getLatest4,
|
|
8995
|
+
pagination,
|
|
8996
|
+
response,
|
|
8997
|
+
_args2 = arguments;
|
|
8998
|
+
|
|
8999
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
9000
|
+
while (1) {
|
|
9001
|
+
switch (_context2.prev = _context2.next) {
|
|
9002
|
+
case 0:
|
|
9003
|
+
options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
9004
|
+
_this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
|
|
9005
|
+
|
|
9006
|
+
if (!(pagination.isLoadingNext || !pagination.nextCursor)) {
|
|
9007
|
+
_context2.next = 4;
|
|
9008
|
+
break;
|
|
9009
|
+
}
|
|
9010
|
+
|
|
9011
|
+
return _context2.abrupt("return");
|
|
9012
|
+
|
|
9013
|
+
case 4:
|
|
9014
|
+
_context2.prev = 4;
|
|
9015
|
+
|
|
9016
|
+
_this.state.partialNext({
|
|
9017
|
+
pagination: _objectSpread$2(_objectSpread$2({}, pagination), {}, {
|
|
9018
|
+
isLoadingNext: true
|
|
9019
|
+
})
|
|
9020
|
+
});
|
|
9021
|
+
|
|
9022
|
+
_context2.next = 8;
|
|
9023
|
+
return _this.queryThreads(_objectSpread$2(_objectSpread$2({}, options), {}, {
|
|
9024
|
+
next: pagination.nextCursor
|
|
9025
|
+
}));
|
|
9026
|
+
|
|
9027
|
+
case 8:
|
|
9028
|
+
response = _context2.sent;
|
|
9029
|
+
|
|
9030
|
+
_this.state.next(function (current) {
|
|
9031
|
+
var _response$next2;
|
|
9032
|
+
|
|
9033
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
9034
|
+
threads: response.threads.length ? current.threads.concat(response.threads) : current.threads,
|
|
9035
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
9036
|
+
nextCursor: (_response$next2 = response.next) !== null && _response$next2 !== void 0 ? _response$next2 : null,
|
|
9037
|
+
isLoadingNext: false
|
|
9038
|
+
})
|
|
9039
|
+
});
|
|
9040
|
+
});
|
|
9041
|
+
|
|
9042
|
+
_context2.next = 16;
|
|
9043
|
+
break;
|
|
9044
|
+
|
|
9045
|
+
case 12:
|
|
9046
|
+
_context2.prev = 12;
|
|
9047
|
+
_context2.t0 = _context2["catch"](4);
|
|
9048
|
+
|
|
9049
|
+
_this.client.logger('error', _context2.t0.message);
|
|
9050
|
+
|
|
9051
|
+
_this.state.next(function (current) {
|
|
9052
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
9053
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
9054
|
+
isLoadingNext: false
|
|
9055
|
+
})
|
|
9056
|
+
});
|
|
9057
|
+
});
|
|
9058
|
+
|
|
9059
|
+
case 16:
|
|
9060
|
+
case "end":
|
|
9061
|
+
return _context2.stop();
|
|
9062
|
+
}
|
|
9063
|
+
}
|
|
9064
|
+
}, _callee2, null, [[4, 12]]);
|
|
9065
|
+
})));
|
|
9066
|
+
|
|
9067
|
+
this.client = client;
|
|
9068
|
+
this.state = new StateStore({
|
|
9069
|
+
active: false,
|
|
9070
|
+
isThreadOrderStale: false,
|
|
9071
|
+
threads: [],
|
|
9072
|
+
unreadThreadCount: 0,
|
|
9073
|
+
unseenThreadIds: [],
|
|
9074
|
+
lastConnectionDropAt: null,
|
|
9075
|
+
pagination: {
|
|
9076
|
+
isLoading: false,
|
|
9077
|
+
isLoadingNext: false,
|
|
9078
|
+
nextCursor: null
|
|
9079
|
+
},
|
|
9080
|
+
ready: false
|
|
9081
|
+
});
|
|
9082
|
+
this.threadsByIdGetterCache = {
|
|
9083
|
+
threads: [],
|
|
9084
|
+
threadsById: {}
|
|
9085
|
+
};
|
|
9086
|
+
}
|
|
9087
|
+
|
|
9088
|
+
_createClass__default['default'](ThreadManager, [{
|
|
9089
|
+
key: "threadsById",
|
|
9090
|
+
get: function get() {
|
|
9091
|
+
var _this$state$getLatest5 = this.state.getLatestValue(),
|
|
9092
|
+
threads = _this$state$getLatest5.threads;
|
|
9093
|
+
|
|
9094
|
+
if (threads === this.threadsByIdGetterCache.threads) {
|
|
9095
|
+
return this.threadsByIdGetterCache.threadsById;
|
|
9096
|
+
}
|
|
9097
|
+
|
|
9098
|
+
var threadsById = threads.reduce(function (newThreadsById, thread) {
|
|
9099
|
+
newThreadsById[thread.id] = thread;
|
|
9100
|
+
return newThreadsById;
|
|
9101
|
+
}, {});
|
|
9102
|
+
this.threadsByIdGetterCache.threads = threads;
|
|
9103
|
+
this.threadsByIdGetterCache.threadsById = threadsById;
|
|
9104
|
+
return threadsById;
|
|
9105
|
+
}
|
|
9106
|
+
}]);
|
|
9107
|
+
|
|
9108
|
+
return ThreadManager;
|
|
9109
|
+
}();
|
|
9110
|
+
|
|
9111
|
+
var _excluded$1 = ["own_votes", "id"],
|
|
9112
|
+
_excluded2$1 = ["id"];
|
|
9113
|
+
|
|
9114
|
+
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; }
|
|
9115
|
+
|
|
9116
|
+
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__default['default'](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; }
|
|
9117
|
+
|
|
9118
|
+
var isPollUpdatedEvent = function isPollUpdatedEvent(e) {
|
|
9119
|
+
return e.type === 'poll.updated';
|
|
9120
|
+
};
|
|
9121
|
+
|
|
9122
|
+
var isPollClosedEventEvent = function isPollClosedEventEvent(e) {
|
|
9123
|
+
return e.type === 'poll.closed';
|
|
9124
|
+
};
|
|
9125
|
+
|
|
9126
|
+
var isPollVoteCastedEvent = function isPollVoteCastedEvent(e) {
|
|
9127
|
+
return e.type === 'poll.vote_casted';
|
|
9128
|
+
};
|
|
9129
|
+
|
|
9130
|
+
var isPollVoteChangedEvent = function isPollVoteChangedEvent(e) {
|
|
9131
|
+
return e.type === 'poll.vote_changed';
|
|
9132
|
+
};
|
|
9133
|
+
|
|
9134
|
+
var isPollVoteRemovedEvent = function isPollVoteRemovedEvent(e) {
|
|
9135
|
+
return e.type === 'poll.vote_removed';
|
|
9136
|
+
};
|
|
9137
|
+
|
|
9138
|
+
var isVoteAnswer = function isVoteAnswer(vote) {
|
|
9139
|
+
return !!(vote !== null && vote !== void 0 && vote.answer_text);
|
|
9140
|
+
};
|
|
9141
|
+
var Poll = /*#__PURE__*/function () {
|
|
9142
|
+
function Poll(_ref) {
|
|
9143
|
+
var _this = this;
|
|
9144
|
+
|
|
9145
|
+
var client = _ref.client,
|
|
9146
|
+
_poll = _ref.poll;
|
|
9147
|
+
|
|
9148
|
+
_classCallCheck__default['default'](this, Poll);
|
|
9149
|
+
|
|
9150
|
+
_defineProperty__default['default'](this, "state", void 0);
|
|
9151
|
+
|
|
9152
|
+
_defineProperty__default['default'](this, "id", void 0);
|
|
9153
|
+
|
|
9154
|
+
_defineProperty__default['default'](this, "client", void 0);
|
|
9155
|
+
|
|
9156
|
+
_defineProperty__default['default'](this, "unsubscribeFunctions", new Set());
|
|
9157
|
+
|
|
9158
|
+
_defineProperty__default['default'](this, "getInitialStateFromPollResponse", function (poll) {
|
|
9159
|
+
var _own_votes$reduce;
|
|
9160
|
+
|
|
9161
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9162
|
+
var own_votes = poll.own_votes;
|
|
9163
|
+
poll.id;
|
|
9164
|
+
var pollResponseForState = _objectWithoutProperties__default['default'](poll, _excluded$1);
|
|
9165
|
+
|
|
9166
|
+
var _ref2 = (_own_votes$reduce = own_votes === null || own_votes === void 0 ? void 0 : own_votes.reduce(function (acc, voteOrAnswer) {
|
|
9167
|
+
if (isVoteAnswer(voteOrAnswer)) {
|
|
9168
|
+
acc.ownAnswer = voteOrAnswer;
|
|
9169
|
+
} else {
|
|
9170
|
+
acc.ownVotes.push(voteOrAnswer);
|
|
9171
|
+
}
|
|
9172
|
+
|
|
9173
|
+
return acc;
|
|
9174
|
+
}, {
|
|
9175
|
+
ownVotes: []
|
|
9176
|
+
})) !== null && _own_votes$reduce !== void 0 ? _own_votes$reduce : {
|
|
9177
|
+
ownVotes: []
|
|
9178
|
+
},
|
|
9179
|
+
ownAnswer = _ref2.ownAnswer,
|
|
9180
|
+
ownVotes = _ref2.ownVotes;
|
|
9181
|
+
|
|
9182
|
+
return _objectSpread$1(_objectSpread$1({}, pollResponseForState), {}, {
|
|
9183
|
+
lastActivityAt: new Date(),
|
|
9184
|
+
maxVotedOptionIds: getMaxVotedOptionIds(pollResponseForState.vote_counts_by_option),
|
|
9185
|
+
ownAnswer: ownAnswer,
|
|
9186
|
+
ownVotesByOptionId: getOwnVotesByOptionId(ownVotes)
|
|
9187
|
+
});
|
|
9188
|
+
});
|
|
9189
|
+
|
|
9190
|
+
_defineProperty__default['default'](this, "reinitializeState", function (poll) {
|
|
9191
|
+
_this.state.partialNext(_this.getInitialStateFromPollResponse(poll));
|
|
9192
|
+
});
|
|
9193
|
+
|
|
9194
|
+
_defineProperty__default['default'](this, "handlePollUpdated", function (event) {
|
|
9195
|
+
var _event$poll;
|
|
9196
|
+
|
|
9197
|
+
if ((_event$poll = event.poll) !== null && _event$poll !== void 0 && _event$poll.id && event.poll.id !== _this.id) return;
|
|
9198
|
+
if (!isPollUpdatedEvent(event)) return; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9199
|
+
|
|
9200
|
+
var _extractPollData = extractPollData(event.poll),
|
|
9201
|
+
pollData = _objectWithoutProperties__default['default'](_extractPollData, _excluded2$1); // @ts-ignore
|
|
9202
|
+
|
|
9203
|
+
|
|
9204
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, pollData), {}, {
|
|
9205
|
+
lastActivityAt: new Date(event.created_at)
|
|
9206
|
+
}));
|
|
9207
|
+
});
|
|
9208
|
+
|
|
9209
|
+
_defineProperty__default['default'](this, "handlePollClosed", function (event) {
|
|
9210
|
+
var _event$poll2;
|
|
9211
|
+
|
|
9212
|
+
if ((_event$poll2 = event.poll) !== null && _event$poll2 !== void 0 && _event$poll2.id && event.poll.id !== _this.id) return;
|
|
9213
|
+
if (!isPollClosedEventEvent(event)) return; // @ts-ignore
|
|
9214
|
+
|
|
9215
|
+
_this.state.partialNext({
|
|
9216
|
+
is_closed: true,
|
|
9217
|
+
lastActivityAt: new Date(event.created_at)
|
|
9218
|
+
});
|
|
9219
|
+
});
|
|
9220
|
+
|
|
9221
|
+
_defineProperty__default['default'](this, "handleVoteCasted", function (event) {
|
|
9222
|
+
var _event$poll3;
|
|
9223
|
+
|
|
9224
|
+
if ((_event$poll3 = event.poll) !== null && _event$poll3 !== void 0 && _event$poll3.id && event.poll.id !== _this.id) return;
|
|
9225
|
+
if (!isPollVoteCastedEvent(event)) return;
|
|
9226
|
+
var currentState = _this.data;
|
|
9227
|
+
var isOwnVote = event.poll_vote.user_id === _this.client.userID;
|
|
9228
|
+
|
|
9229
|
+
var latestAnswers = _toConsumableArray__default['default'](currentState.latest_answers);
|
|
9230
|
+
|
|
9231
|
+
var ownAnswer = currentState.ownAnswer;
|
|
9232
|
+
var ownVotesByOptionId = currentState.ownVotesByOptionId;
|
|
9233
|
+
var maxVotedOptionIds = currentState.maxVotedOptionIds;
|
|
9234
|
+
|
|
9235
|
+
if (isOwnVote) {
|
|
9236
|
+
if (isVoteAnswer(event.poll_vote)) {
|
|
9237
|
+
ownAnswer = event.poll_vote;
|
|
9238
|
+
} else if (event.poll_vote.option_id) {
|
|
9239
|
+
ownVotesByOptionId[event.poll_vote.option_id] = event.poll_vote;
|
|
9240
|
+
}
|
|
9241
|
+
}
|
|
9242
|
+
|
|
9243
|
+
if (isVoteAnswer(event.poll_vote)) {
|
|
9244
|
+
latestAnswers = [event.poll_vote].concat(_toConsumableArray__default['default'](latestAnswers));
|
|
9245
|
+
} else {
|
|
9246
|
+
maxVotedOptionIds = getMaxVotedOptionIds(event.poll.vote_counts_by_option);
|
|
9247
|
+
}
|
|
9248
|
+
|
|
9249
|
+
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
9250
|
+
|
|
9251
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, pollEnrichData), {}, {
|
|
9252
|
+
latest_answers: latestAnswers,
|
|
9253
|
+
lastActivityAt: new Date(event.created_at),
|
|
9254
|
+
ownAnswer: ownAnswer,
|
|
9255
|
+
ownVotesByOptionId: ownVotesByOptionId,
|
|
9256
|
+
maxVotedOptionIds: maxVotedOptionIds
|
|
9257
|
+
}));
|
|
9258
|
+
});
|
|
9259
|
+
|
|
9260
|
+
_defineProperty__default['default'](this, "handleVoteChanged", function (event) {
|
|
9261
|
+
var _event$poll4;
|
|
9262
|
+
|
|
9263
|
+
// this event is triggered only when event.poll.enforce_unique_vote === true
|
|
9264
|
+
if ((_event$poll4 = event.poll) !== null && _event$poll4 !== void 0 && _event$poll4.id && event.poll.id !== _this.id) return;
|
|
9265
|
+
if (!isPollVoteChangedEvent(event)) return;
|
|
9266
|
+
var currentState = _this.data;
|
|
9267
|
+
var isOwnVote = event.poll_vote.user_id === _this.client.userID;
|
|
9268
|
+
|
|
9269
|
+
var latestAnswers = _toConsumableArray__default['default'](currentState.latest_answers);
|
|
9270
|
+
|
|
9271
|
+
var ownAnswer = currentState.ownAnswer;
|
|
9272
|
+
var ownVotesByOptionId = currentState.ownVotesByOptionId;
|
|
9273
|
+
var maxVotedOptionIds = currentState.maxVotedOptionIds;
|
|
9274
|
+
|
|
9275
|
+
if (isOwnVote) {
|
|
9276
|
+
if (isVoteAnswer(event.poll_vote)) {
|
|
9277
|
+
latestAnswers = [event.poll_vote].concat(_toConsumableArray__default['default'](latestAnswers.filter(function (answer) {
|
|
9278
|
+
return answer.id !== event.poll_vote.id;
|
|
9279
|
+
})));
|
|
9280
|
+
ownAnswer = event.poll_vote;
|
|
9281
|
+
} else if (event.poll_vote.option_id) {
|
|
9282
|
+
var _ownAnswer;
|
|
9283
|
+
|
|
9284
|
+
if (event.poll.enforce_unique_votes) {
|
|
9285
|
+
ownVotesByOptionId = _defineProperty__default['default']({}, event.poll_vote.option_id, event.poll_vote);
|
|
9286
|
+
} else {
|
|
9287
|
+
ownVotesByOptionId = Object.entries(ownVotesByOptionId).reduce(function (acc, _ref3) {
|
|
9288
|
+
var _ref4 = _slicedToArray__default['default'](_ref3, 2),
|
|
9289
|
+
optionId = _ref4[0],
|
|
9290
|
+
vote = _ref4[1];
|
|
9291
|
+
|
|
9292
|
+
if (optionId !== event.poll_vote.option_id && vote.id === event.poll_vote.id) {
|
|
9293
|
+
return acc;
|
|
9294
|
+
}
|
|
9295
|
+
|
|
9296
|
+
acc[optionId] = vote;
|
|
9297
|
+
return acc;
|
|
9298
|
+
}, {});
|
|
9299
|
+
ownVotesByOptionId[event.poll_vote.option_id] = event.poll_vote;
|
|
9300
|
+
}
|
|
9301
|
+
|
|
9302
|
+
if (((_ownAnswer = ownAnswer) === null || _ownAnswer === void 0 ? void 0 : _ownAnswer.id) === event.poll_vote.id) {
|
|
9303
|
+
ownAnswer = undefined;
|
|
9304
|
+
}
|
|
9305
|
+
|
|
9306
|
+
maxVotedOptionIds = getMaxVotedOptionIds(event.poll.vote_counts_by_option);
|
|
9307
|
+
}
|
|
9308
|
+
} else if (isVoteAnswer(event.poll_vote)) {
|
|
9309
|
+
latestAnswers = [event.poll_vote].concat(_toConsumableArray__default['default'](latestAnswers));
|
|
9310
|
+
} else {
|
|
9311
|
+
maxVotedOptionIds = getMaxVotedOptionIds(event.poll.vote_counts_by_option);
|
|
9312
|
+
}
|
|
9313
|
+
|
|
9314
|
+
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
9315
|
+
|
|
9316
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, pollEnrichData), {}, {
|
|
9317
|
+
latest_answers: latestAnswers,
|
|
9318
|
+
lastActivityAt: new Date(event.created_at),
|
|
9319
|
+
ownAnswer: ownAnswer,
|
|
9320
|
+
ownVotesByOptionId: ownVotesByOptionId,
|
|
9321
|
+
maxVotedOptionIds: maxVotedOptionIds
|
|
9322
|
+
}));
|
|
9323
|
+
});
|
|
9324
|
+
|
|
9325
|
+
_defineProperty__default['default'](this, "handleVoteRemoved", function (event) {
|
|
9326
|
+
var _event$poll5;
|
|
9327
|
+
|
|
9328
|
+
if ((_event$poll5 = event.poll) !== null && _event$poll5 !== void 0 && _event$poll5.id && event.poll.id !== _this.id) return;
|
|
9329
|
+
if (!isPollVoteRemovedEvent(event)) return;
|
|
9330
|
+
var currentState = _this.data;
|
|
9331
|
+
var isOwnVote = event.poll_vote.user_id === _this.client.userID;
|
|
9332
|
+
|
|
9333
|
+
var latestAnswers = _toConsumableArray__default['default'](currentState.latest_answers);
|
|
9334
|
+
|
|
9335
|
+
var ownAnswer = currentState.ownAnswer;
|
|
9336
|
+
|
|
9337
|
+
var ownVotesByOptionId = _objectSpread$1({}, currentState.ownVotesByOptionId);
|
|
9338
|
+
|
|
9339
|
+
var maxVotedOptionIds = currentState.maxVotedOptionIds;
|
|
9340
|
+
|
|
9341
|
+
if (isVoteAnswer(event.poll_vote)) {
|
|
9342
|
+
latestAnswers = latestAnswers.filter(function (answer) {
|
|
9343
|
+
return answer.id !== event.poll_vote.id;
|
|
9344
|
+
});
|
|
9345
|
+
|
|
9346
|
+
if (isOwnVote) {
|
|
9347
|
+
ownAnswer = undefined;
|
|
9348
|
+
}
|
|
9349
|
+
} else {
|
|
9350
|
+
maxVotedOptionIds = getMaxVotedOptionIds(event.poll.vote_counts_by_option);
|
|
9351
|
+
|
|
9352
|
+
if (isOwnVote && event.poll_vote.option_id) {
|
|
9353
|
+
delete ownVotesByOptionId[event.poll_vote.option_id];
|
|
9354
|
+
}
|
|
9355
|
+
}
|
|
9356
|
+
|
|
9357
|
+
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
9358
|
+
|
|
9359
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, pollEnrichData), {}, {
|
|
9360
|
+
latest_answers: latestAnswers,
|
|
9361
|
+
lastActivityAt: new Date(event.created_at),
|
|
9362
|
+
ownAnswer: ownAnswer,
|
|
9363
|
+
ownVotesByOptionId: ownVotesByOptionId,
|
|
9364
|
+
maxVotedOptionIds: maxVotedOptionIds
|
|
9365
|
+
}));
|
|
9366
|
+
});
|
|
9367
|
+
|
|
9368
|
+
_defineProperty__default['default'](this, "query", /*#__PURE__*/function () {
|
|
9369
|
+
var _ref5 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(id) {
|
|
9370
|
+
var _yield$_this$client$g, poll;
|
|
9371
|
+
|
|
9372
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
9373
|
+
while (1) {
|
|
9374
|
+
switch (_context.prev = _context.next) {
|
|
9375
|
+
case 0:
|
|
9376
|
+
_context.next = 2;
|
|
9377
|
+
return _this.client.getPoll(id);
|
|
9378
|
+
|
|
9379
|
+
case 2:
|
|
9380
|
+
_yield$_this$client$g = _context.sent;
|
|
9381
|
+
poll = _yield$_this$client$g.poll;
|
|
9382
|
+
|
|
9383
|
+
// @ts-ignore
|
|
9384
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, poll), {}, {
|
|
9385
|
+
lastActivityAt: new Date()
|
|
9386
|
+
}));
|
|
9387
|
+
|
|
9388
|
+
return _context.abrupt("return", poll);
|
|
9389
|
+
|
|
9390
|
+
case 6:
|
|
9391
|
+
case "end":
|
|
9392
|
+
return _context.stop();
|
|
9393
|
+
}
|
|
9394
|
+
}
|
|
9395
|
+
}, _callee);
|
|
9396
|
+
}));
|
|
9397
|
+
|
|
9398
|
+
return function (_x) {
|
|
9399
|
+
return _ref5.apply(this, arguments);
|
|
9400
|
+
};
|
|
9401
|
+
}());
|
|
9402
|
+
|
|
9403
|
+
_defineProperty__default['default'](this, "update", /*#__PURE__*/function () {
|
|
9404
|
+
var _ref6 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2(data) {
|
|
9405
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
9406
|
+
while (1) {
|
|
9407
|
+
switch (_context2.prev = _context2.next) {
|
|
9408
|
+
case 0:
|
|
9409
|
+
_context2.next = 2;
|
|
9410
|
+
return _this.client.updatePoll(_objectSpread$1(_objectSpread$1({}, data), {}, {
|
|
9411
|
+
id: _this.id
|
|
9412
|
+
}));
|
|
9413
|
+
|
|
9414
|
+
case 2:
|
|
9415
|
+
return _context2.abrupt("return", _context2.sent);
|
|
9416
|
+
|
|
9417
|
+
case 3:
|
|
9418
|
+
case "end":
|
|
9419
|
+
return _context2.stop();
|
|
9420
|
+
}
|
|
9421
|
+
}
|
|
9422
|
+
}, _callee2);
|
|
9423
|
+
}));
|
|
9424
|
+
|
|
9425
|
+
return function (_x2) {
|
|
9426
|
+
return _ref6.apply(this, arguments);
|
|
9427
|
+
};
|
|
9428
|
+
}());
|
|
9429
|
+
|
|
9430
|
+
_defineProperty__default['default'](this, "partialUpdate", /*#__PURE__*/function () {
|
|
9431
|
+
var _ref7 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(partialPollObject) {
|
|
9432
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
9433
|
+
while (1) {
|
|
9434
|
+
switch (_context3.prev = _context3.next) {
|
|
9435
|
+
case 0:
|
|
9436
|
+
_context3.next = 2;
|
|
9437
|
+
return _this.client.partialUpdatePoll(_this.id, partialPollObject);
|
|
9438
|
+
|
|
9439
|
+
case 2:
|
|
9440
|
+
return _context3.abrupt("return", _context3.sent);
|
|
9441
|
+
|
|
9442
|
+
case 3:
|
|
9443
|
+
case "end":
|
|
9444
|
+
return _context3.stop();
|
|
9445
|
+
}
|
|
9446
|
+
}
|
|
9447
|
+
}, _callee3);
|
|
9448
|
+
}));
|
|
9449
|
+
|
|
9450
|
+
return function (_x3) {
|
|
9451
|
+
return _ref7.apply(this, arguments);
|
|
9452
|
+
};
|
|
9453
|
+
}());
|
|
9454
|
+
|
|
9455
|
+
_defineProperty__default['default'](this, "close", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4() {
|
|
9456
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
9457
|
+
while (1) {
|
|
9458
|
+
switch (_context4.prev = _context4.next) {
|
|
9459
|
+
case 0:
|
|
9460
|
+
_context4.next = 2;
|
|
9461
|
+
return _this.client.closePoll(_this.id);
|
|
9462
|
+
|
|
9463
|
+
case 2:
|
|
9464
|
+
return _context4.abrupt("return", _context4.sent);
|
|
9465
|
+
|
|
9466
|
+
case 3:
|
|
9467
|
+
case "end":
|
|
9468
|
+
return _context4.stop();
|
|
9469
|
+
}
|
|
9470
|
+
}
|
|
9471
|
+
}, _callee4);
|
|
9472
|
+
})));
|
|
9473
|
+
|
|
9474
|
+
_defineProperty__default['default'](this, "delete", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5() {
|
|
9475
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
9476
|
+
while (1) {
|
|
9477
|
+
switch (_context5.prev = _context5.next) {
|
|
9478
|
+
case 0:
|
|
9479
|
+
_context5.next = 2;
|
|
9480
|
+
return _this.client.deletePoll(_this.id);
|
|
9481
|
+
|
|
9482
|
+
case 2:
|
|
9483
|
+
return _context5.abrupt("return", _context5.sent);
|
|
9484
|
+
|
|
9485
|
+
case 3:
|
|
9486
|
+
case "end":
|
|
9487
|
+
return _context5.stop();
|
|
9488
|
+
}
|
|
9489
|
+
}
|
|
9490
|
+
}, _callee5);
|
|
9491
|
+
})));
|
|
9492
|
+
|
|
9493
|
+
_defineProperty__default['default'](this, "createOption", /*#__PURE__*/function () {
|
|
9494
|
+
var _ref10 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6(option) {
|
|
9495
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
|
9496
|
+
while (1) {
|
|
9497
|
+
switch (_context6.prev = _context6.next) {
|
|
9498
|
+
case 0:
|
|
9499
|
+
_context6.next = 2;
|
|
9500
|
+
return _this.client.createPollOption(_this.id, option);
|
|
9501
|
+
|
|
9502
|
+
case 2:
|
|
9503
|
+
return _context6.abrupt("return", _context6.sent);
|
|
9504
|
+
|
|
9505
|
+
case 3:
|
|
9506
|
+
case "end":
|
|
9507
|
+
return _context6.stop();
|
|
9508
|
+
}
|
|
9509
|
+
}
|
|
9510
|
+
}, _callee6);
|
|
9511
|
+
}));
|
|
9512
|
+
|
|
9513
|
+
return function (_x4) {
|
|
9514
|
+
return _ref10.apply(this, arguments);
|
|
9515
|
+
};
|
|
9516
|
+
}());
|
|
9517
|
+
|
|
9518
|
+
_defineProperty__default['default'](this, "updateOption", /*#__PURE__*/function () {
|
|
9519
|
+
var _ref11 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee7(option) {
|
|
9520
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee7$(_context7) {
|
|
9521
|
+
while (1) {
|
|
9522
|
+
switch (_context7.prev = _context7.next) {
|
|
9523
|
+
case 0:
|
|
9524
|
+
_context7.next = 2;
|
|
9525
|
+
return _this.client.updatePollOption(_this.id, option);
|
|
9526
|
+
|
|
9527
|
+
case 2:
|
|
9528
|
+
return _context7.abrupt("return", _context7.sent);
|
|
9529
|
+
|
|
9530
|
+
case 3:
|
|
9531
|
+
case "end":
|
|
9532
|
+
return _context7.stop();
|
|
9533
|
+
}
|
|
9534
|
+
}
|
|
9535
|
+
}, _callee7);
|
|
9536
|
+
}));
|
|
9537
|
+
|
|
9538
|
+
return function (_x5) {
|
|
9539
|
+
return _ref11.apply(this, arguments);
|
|
9540
|
+
};
|
|
9541
|
+
}());
|
|
9542
|
+
|
|
9543
|
+
_defineProperty__default['default'](this, "deleteOption", /*#__PURE__*/function () {
|
|
9544
|
+
var _ref12 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee8(optionId) {
|
|
9545
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee8$(_context8) {
|
|
9546
|
+
while (1) {
|
|
9547
|
+
switch (_context8.prev = _context8.next) {
|
|
9548
|
+
case 0:
|
|
9549
|
+
_context8.next = 2;
|
|
9550
|
+
return _this.client.deletePollOption(_this.id, optionId);
|
|
9551
|
+
|
|
9552
|
+
case 2:
|
|
9553
|
+
return _context8.abrupt("return", _context8.sent);
|
|
9554
|
+
|
|
9555
|
+
case 3:
|
|
9556
|
+
case "end":
|
|
9557
|
+
return _context8.stop();
|
|
9558
|
+
}
|
|
9559
|
+
}
|
|
9560
|
+
}, _callee8);
|
|
9561
|
+
}));
|
|
9562
|
+
|
|
9563
|
+
return function (_x6) {
|
|
9564
|
+
return _ref12.apply(this, arguments);
|
|
9565
|
+
};
|
|
9566
|
+
}());
|
|
9567
|
+
|
|
9568
|
+
_defineProperty__default['default'](this, "castVote", /*#__PURE__*/function () {
|
|
9569
|
+
var _ref13 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee9(optionId, messageId) {
|
|
9570
|
+
var _this$data, max_votes_allowed, ownVotesByOptionId, reachedVoteLimit, _oldestVote2, oldestVote;
|
|
9571
|
+
|
|
9572
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee9$(_context9) {
|
|
9573
|
+
while (1) {
|
|
9574
|
+
switch (_context9.prev = _context9.next) {
|
|
9575
|
+
case 0:
|
|
9576
|
+
_this$data = _this.data, max_votes_allowed = _this$data.max_votes_allowed, ownVotesByOptionId = _this$data.ownVotesByOptionId;
|
|
9577
|
+
reachedVoteLimit = max_votes_allowed && max_votes_allowed === Object.keys(ownVotesByOptionId).length;
|
|
9578
|
+
|
|
9579
|
+
if (!reachedVoteLimit) {
|
|
9580
|
+
_context9.next = 8;
|
|
9581
|
+
break;
|
|
9582
|
+
}
|
|
9583
|
+
|
|
9584
|
+
oldestVote = Object.values(ownVotesByOptionId)[0];
|
|
9585
|
+
Object.values(ownVotesByOptionId).slice(1).forEach(function (vote) {
|
|
9586
|
+
var _oldestVote;
|
|
9587
|
+
|
|
9588
|
+
if (!((_oldestVote = oldestVote) !== null && _oldestVote !== void 0 && _oldestVote.created_at) || new Date(vote.created_at) < new Date(oldestVote.created_at)) {
|
|
9589
|
+
oldestVote = vote;
|
|
9590
|
+
}
|
|
9591
|
+
});
|
|
9592
|
+
|
|
9593
|
+
if (!((_oldestVote2 = oldestVote) !== null && _oldestVote2 !== void 0 && _oldestVote2.id)) {
|
|
9594
|
+
_context9.next = 8;
|
|
9595
|
+
break;
|
|
9596
|
+
}
|
|
9597
|
+
|
|
9598
|
+
_context9.next = 8;
|
|
9599
|
+
return _this.removeVote(oldestVote.id, messageId);
|
|
9600
|
+
|
|
9601
|
+
case 8:
|
|
9602
|
+
_context9.next = 10;
|
|
9603
|
+
return _this.client.castPollVote(messageId, _this.id, {
|
|
9604
|
+
option_id: optionId
|
|
9605
|
+
});
|
|
9606
|
+
|
|
9607
|
+
case 10:
|
|
9608
|
+
return _context9.abrupt("return", _context9.sent);
|
|
9609
|
+
|
|
9610
|
+
case 11:
|
|
9611
|
+
case "end":
|
|
9612
|
+
return _context9.stop();
|
|
9613
|
+
}
|
|
9614
|
+
}
|
|
9615
|
+
}, _callee9);
|
|
9616
|
+
}));
|
|
9617
|
+
|
|
9618
|
+
return function (_x7, _x8) {
|
|
9619
|
+
return _ref13.apply(this, arguments);
|
|
9620
|
+
};
|
|
9621
|
+
}());
|
|
9622
|
+
|
|
9623
|
+
_defineProperty__default['default'](this, "removeVote", /*#__PURE__*/function () {
|
|
9624
|
+
var _ref14 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee10(voteId, messageId) {
|
|
9625
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee10$(_context10) {
|
|
9626
|
+
while (1) {
|
|
9627
|
+
switch (_context10.prev = _context10.next) {
|
|
9628
|
+
case 0:
|
|
9629
|
+
_context10.next = 2;
|
|
9630
|
+
return _this.client.removePollVote(messageId, _this.id, voteId);
|
|
9631
|
+
|
|
9632
|
+
case 2:
|
|
9633
|
+
return _context10.abrupt("return", _context10.sent);
|
|
9634
|
+
|
|
9635
|
+
case 3:
|
|
9636
|
+
case "end":
|
|
9637
|
+
return _context10.stop();
|
|
9638
|
+
}
|
|
9639
|
+
}
|
|
9640
|
+
}, _callee10);
|
|
9641
|
+
}));
|
|
9642
|
+
|
|
9643
|
+
return function (_x9, _x10) {
|
|
9644
|
+
return _ref14.apply(this, arguments);
|
|
9645
|
+
};
|
|
9646
|
+
}());
|
|
9647
|
+
|
|
9648
|
+
_defineProperty__default['default'](this, "addAnswer", /*#__PURE__*/function () {
|
|
9649
|
+
var _ref15 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee11(answerText, messageId) {
|
|
9650
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee11$(_context11) {
|
|
9651
|
+
while (1) {
|
|
9652
|
+
switch (_context11.prev = _context11.next) {
|
|
9653
|
+
case 0:
|
|
9654
|
+
_context11.next = 2;
|
|
9655
|
+
return _this.client.addPollAnswer(messageId, _this.id, answerText);
|
|
9656
|
+
|
|
9657
|
+
case 2:
|
|
9658
|
+
return _context11.abrupt("return", _context11.sent);
|
|
9659
|
+
|
|
9660
|
+
case 3:
|
|
9661
|
+
case "end":
|
|
9662
|
+
return _context11.stop();
|
|
9663
|
+
}
|
|
9664
|
+
}
|
|
9665
|
+
}, _callee11);
|
|
9666
|
+
}));
|
|
9667
|
+
|
|
9668
|
+
return function (_x11, _x12) {
|
|
9669
|
+
return _ref15.apply(this, arguments);
|
|
9670
|
+
};
|
|
9671
|
+
}());
|
|
9672
|
+
|
|
9673
|
+
_defineProperty__default['default'](this, "removeAnswer", /*#__PURE__*/function () {
|
|
9674
|
+
var _ref16 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee12(answerId, messageId) {
|
|
9675
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee12$(_context12) {
|
|
9676
|
+
while (1) {
|
|
9677
|
+
switch (_context12.prev = _context12.next) {
|
|
9678
|
+
case 0:
|
|
9679
|
+
_context12.next = 2;
|
|
9680
|
+
return _this.client.removePollVote(messageId, _this.id, answerId);
|
|
9681
|
+
|
|
9682
|
+
case 2:
|
|
9683
|
+
return _context12.abrupt("return", _context12.sent);
|
|
9684
|
+
|
|
9685
|
+
case 3:
|
|
9686
|
+
case "end":
|
|
9687
|
+
return _context12.stop();
|
|
9688
|
+
}
|
|
9689
|
+
}
|
|
9690
|
+
}, _callee12);
|
|
9691
|
+
}));
|
|
9692
|
+
|
|
9693
|
+
return function (_x13, _x14) {
|
|
9694
|
+
return _ref16.apply(this, arguments);
|
|
9695
|
+
};
|
|
9696
|
+
}());
|
|
9697
|
+
|
|
9698
|
+
_defineProperty__default['default'](this, "queryAnswers", /*#__PURE__*/function () {
|
|
9699
|
+
var _ref17 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee13(params) {
|
|
9700
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee13$(_context13) {
|
|
9701
|
+
while (1) {
|
|
9702
|
+
switch (_context13.prev = _context13.next) {
|
|
9703
|
+
case 0:
|
|
9704
|
+
_context13.next = 2;
|
|
9705
|
+
return _this.client.queryPollAnswers(_this.id, params.filter, params.sort, params.options);
|
|
9706
|
+
|
|
9707
|
+
case 2:
|
|
9708
|
+
return _context13.abrupt("return", _context13.sent);
|
|
9709
|
+
|
|
9710
|
+
case 3:
|
|
9711
|
+
case "end":
|
|
9712
|
+
return _context13.stop();
|
|
9713
|
+
}
|
|
9714
|
+
}
|
|
9715
|
+
}, _callee13);
|
|
9716
|
+
}));
|
|
9717
|
+
|
|
9718
|
+
return function (_x15) {
|
|
9719
|
+
return _ref17.apply(this, arguments);
|
|
9720
|
+
};
|
|
9721
|
+
}());
|
|
9722
|
+
|
|
9723
|
+
_defineProperty__default['default'](this, "queryOptionVotes", /*#__PURE__*/function () {
|
|
9724
|
+
var _ref18 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee14(params) {
|
|
9725
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee14$(_context14) {
|
|
9726
|
+
while (1) {
|
|
9727
|
+
switch (_context14.prev = _context14.next) {
|
|
9728
|
+
case 0:
|
|
9729
|
+
_context14.next = 2;
|
|
9730
|
+
return _this.client.queryPollVotes(_this.id, params.filter, params.sort, params.options);
|
|
9731
|
+
|
|
9732
|
+
case 2:
|
|
9733
|
+
return _context14.abrupt("return", _context14.sent);
|
|
9734
|
+
|
|
9735
|
+
case 3:
|
|
9736
|
+
case "end":
|
|
9737
|
+
return _context14.stop();
|
|
9738
|
+
}
|
|
9739
|
+
}
|
|
9740
|
+
}, _callee14);
|
|
9741
|
+
}));
|
|
9742
|
+
|
|
9743
|
+
return function (_x16) {
|
|
9744
|
+
return _ref18.apply(this, arguments);
|
|
9745
|
+
};
|
|
9746
|
+
}());
|
|
9747
|
+
|
|
9748
|
+
this.client = client;
|
|
9749
|
+
this.id = _poll.id;
|
|
9750
|
+
this.state = new StateStore(this.getInitialStateFromPollResponse(_poll));
|
|
9751
|
+
}
|
|
9752
|
+
|
|
9753
|
+
_createClass__default['default'](Poll, [{
|
|
9754
|
+
key: "data",
|
|
9755
|
+
get: function get() {
|
|
9756
|
+
return this.state.getLatestValue();
|
|
9757
|
+
}
|
|
9758
|
+
}]);
|
|
9759
|
+
|
|
9760
|
+
return Poll;
|
|
9761
|
+
}();
|
|
9762
|
+
|
|
9763
|
+
function getMaxVotedOptionIds(voteCountsByOption) {
|
|
9764
|
+
var maxVotes = 0;
|
|
9765
|
+
var winningOptions = [];
|
|
9766
|
+
|
|
9767
|
+
for (var _i = 0, _Object$entries = Object.entries(voteCountsByOption !== null && voteCountsByOption !== void 0 ? voteCountsByOption : {}); _i < _Object$entries.length; _i++) {
|
|
9768
|
+
var _Object$entries$_i = _slicedToArray__default['default'](_Object$entries[_i], 2),
|
|
9769
|
+
id = _Object$entries$_i[0],
|
|
9770
|
+
count = _Object$entries$_i[1];
|
|
9771
|
+
|
|
9772
|
+
if (count > maxVotes) {
|
|
9773
|
+
winningOptions = [id];
|
|
9774
|
+
maxVotes = count;
|
|
9775
|
+
} else if (count === maxVotes) {
|
|
9776
|
+
winningOptions.push(id);
|
|
9777
|
+
}
|
|
9778
|
+
}
|
|
9779
|
+
|
|
9780
|
+
return winningOptions;
|
|
9781
|
+
}
|
|
9782
|
+
|
|
9783
|
+
function getOwnVotesByOptionId(ownVotes) {
|
|
9784
|
+
return !ownVotes ? {} : ownVotes.reduce(function (acc, vote) {
|
|
9785
|
+
if (isVoteAnswer(vote) || !vote.option_id) return acc;
|
|
9786
|
+
acc[vote.option_id] = vote;
|
|
9787
|
+
return acc;
|
|
9788
|
+
}, {});
|
|
9789
|
+
}
|
|
9790
|
+
|
|
9791
|
+
function extractPollData(pollResponse) {
|
|
9792
|
+
return {
|
|
9793
|
+
allow_answers: pollResponse.allow_answers,
|
|
9794
|
+
allow_user_suggested_options: pollResponse.allow_user_suggested_options,
|
|
9795
|
+
description: pollResponse.description,
|
|
9796
|
+
enforce_unique_vote: pollResponse.enforce_unique_vote,
|
|
9797
|
+
id: pollResponse.id,
|
|
9798
|
+
is_closed: pollResponse.is_closed,
|
|
9799
|
+
max_votes_allowed: pollResponse.max_votes_allowed,
|
|
9800
|
+
name: pollResponse.name,
|
|
9801
|
+
options: pollResponse.options,
|
|
9802
|
+
voting_visibility: pollResponse.voting_visibility
|
|
9803
|
+
};
|
|
9804
|
+
}
|
|
9805
|
+
function extractPollEnrichedData(pollResponse) {
|
|
9806
|
+
return {
|
|
9807
|
+
answers_count: pollResponse.answers_count,
|
|
9808
|
+
latest_votes_by_option: pollResponse.latest_votes_by_option,
|
|
9809
|
+
vote_count: pollResponse.vote_count,
|
|
9810
|
+
vote_counts_by_option: pollResponse.vote_counts_by_option
|
|
9811
|
+
};
|
|
9812
|
+
}
|
|
9813
|
+
|
|
9814
|
+
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; } } }; }
|
|
9815
|
+
|
|
9816
|
+
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); }
|
|
9817
|
+
|
|
9818
|
+
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; }
|
|
9819
|
+
var PollManager = /*#__PURE__*/function () {
|
|
9820
|
+
// The pollCache contains only polls that have been created and sent as messages
|
|
9821
|
+
// (i.e only polls that are coupled with a message, can be voted on and require a
|
|
9822
|
+
// reactive state). It shall work as a basic look-up table for our SDK to be able
|
|
9823
|
+
// to quickly consume poll state that will be reactive even without the polls being
|
|
9824
|
+
// rendered within the UI.
|
|
9825
|
+
function PollManager(_ref) {
|
|
9826
|
+
var _this = this;
|
|
9827
|
+
|
|
9828
|
+
var client = _ref.client;
|
|
9829
|
+
|
|
9830
|
+
_classCallCheck__default['default'](this, PollManager);
|
|
9831
|
+
|
|
9832
|
+
_defineProperty__default['default'](this, "client", void 0);
|
|
9833
|
+
|
|
9834
|
+
_defineProperty__default['default'](this, "pollCache", new Map());
|
|
9835
|
+
|
|
9836
|
+
_defineProperty__default['default'](this, "unsubscribeFunctions", new Set());
|
|
9837
|
+
|
|
9838
|
+
_defineProperty__default['default'](this, "fromState", function (id) {
|
|
9839
|
+
return _this.pollCache.get(id);
|
|
9840
|
+
});
|
|
9841
|
+
|
|
9842
|
+
_defineProperty__default['default'](this, "registerSubscriptions", function () {
|
|
9843
|
+
if (_this.unsubscribeFunctions.size) {
|
|
9844
|
+
// Already listening for events and changes
|
|
9845
|
+
return;
|
|
9846
|
+
}
|
|
9847
|
+
|
|
9848
|
+
_this.unsubscribeFunctions.add(_this.subscribeMessageNew());
|
|
9849
|
+
|
|
9850
|
+
_this.unsubscribeFunctions.add(_this.subscribePollUpdated());
|
|
9851
|
+
|
|
9852
|
+
_this.unsubscribeFunctions.add(_this.subscribePollClosed());
|
|
9853
|
+
|
|
9854
|
+
_this.unsubscribeFunctions.add(_this.subscribeVoteCasted());
|
|
9855
|
+
|
|
9856
|
+
_this.unsubscribeFunctions.add(_this.subscribeVoteChanged());
|
|
9857
|
+
|
|
9858
|
+
_this.unsubscribeFunctions.add(_this.subscribeVoteRemoved());
|
|
9859
|
+
});
|
|
9860
|
+
|
|
9861
|
+
_defineProperty__default['default'](this, "unregisterSubscriptions", function () {
|
|
9862
|
+
_this.unsubscribeFunctions.forEach(function (cleanupFunction) {
|
|
9863
|
+
return cleanupFunction();
|
|
9864
|
+
});
|
|
9865
|
+
|
|
9866
|
+
_this.unsubscribeFunctions.clear();
|
|
9867
|
+
});
|
|
9868
|
+
|
|
9869
|
+
_defineProperty__default['default'](this, "createPoll", /*#__PURE__*/function () {
|
|
9870
|
+
var _ref2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(poll) {
|
|
9871
|
+
var _yield$_this$client$c, createdPoll;
|
|
9872
|
+
|
|
9873
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
9874
|
+
while (1) {
|
|
9875
|
+
switch (_context.prev = _context.next) {
|
|
9876
|
+
case 0:
|
|
9877
|
+
_context.next = 2;
|
|
9878
|
+
return _this.client.createPoll(poll);
|
|
9879
|
+
|
|
9880
|
+
case 2:
|
|
9881
|
+
_yield$_this$client$c = _context.sent;
|
|
9882
|
+
createdPoll = _yield$_this$client$c.poll;
|
|
9883
|
+
return _context.abrupt("return", new Poll({
|
|
9884
|
+
client: _this.client,
|
|
9885
|
+
poll: createdPoll
|
|
9886
|
+
}));
|
|
9887
|
+
|
|
9888
|
+
case 5:
|
|
9889
|
+
case "end":
|
|
9890
|
+
return _context.stop();
|
|
9891
|
+
}
|
|
9892
|
+
}
|
|
9893
|
+
}, _callee);
|
|
9894
|
+
}));
|
|
9895
|
+
|
|
9896
|
+
return function (_x) {
|
|
9897
|
+
return _ref2.apply(this, arguments);
|
|
9898
|
+
};
|
|
9899
|
+
}());
|
|
9900
|
+
|
|
9901
|
+
_defineProperty__default['default'](this, "getPoll", /*#__PURE__*/function () {
|
|
9902
|
+
var _ref3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2(id) {
|
|
9903
|
+
var cachedPoll, _yield$_this$client$g, poll;
|
|
9904
|
+
|
|
9905
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
9906
|
+
while (1) {
|
|
9907
|
+
switch (_context2.prev = _context2.next) {
|
|
9908
|
+
case 0:
|
|
9909
|
+
cachedPoll = _this.fromState(id); // optimistically return the cached poll if it exists and update in the background
|
|
9910
|
+
|
|
9911
|
+
if (!cachedPoll) {
|
|
9912
|
+
_context2.next = 4;
|
|
9913
|
+
break;
|
|
9914
|
+
}
|
|
9915
|
+
|
|
9916
|
+
_this.client.getPoll(id).then(function (_ref4) {
|
|
9917
|
+
var poll = _ref4.poll;
|
|
9918
|
+
return _this.setOrOverwriteInCache(poll, true);
|
|
9919
|
+
});
|
|
9920
|
+
|
|
9921
|
+
return _context2.abrupt("return", cachedPoll);
|
|
9922
|
+
|
|
9923
|
+
case 4:
|
|
9924
|
+
_context2.next = 6;
|
|
9925
|
+
return _this.client.getPoll(id);
|
|
9926
|
+
|
|
9927
|
+
case 6:
|
|
9928
|
+
_yield$_this$client$g = _context2.sent;
|
|
9929
|
+
poll = _yield$_this$client$g.poll;
|
|
9930
|
+
|
|
9931
|
+
_this.setOrOverwriteInCache(poll);
|
|
9932
|
+
|
|
9933
|
+
return _context2.abrupt("return", _this.fromState(id));
|
|
9934
|
+
|
|
9935
|
+
case 10:
|
|
9936
|
+
case "end":
|
|
9937
|
+
return _context2.stop();
|
|
9938
|
+
}
|
|
9939
|
+
}
|
|
9940
|
+
}, _callee2);
|
|
9941
|
+
}));
|
|
9942
|
+
|
|
9943
|
+
return function (_x2) {
|
|
9944
|
+
return _ref3.apply(this, arguments);
|
|
9945
|
+
};
|
|
9946
|
+
}());
|
|
9947
|
+
|
|
9948
|
+
_defineProperty__default['default'](this, "queryPolls", /*#__PURE__*/function () {
|
|
9949
|
+
var _ref5 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(filter) {
|
|
9950
|
+
var sort,
|
|
9951
|
+
options,
|
|
9952
|
+
_yield$_this$client$q,
|
|
9953
|
+
polls,
|
|
9954
|
+
next,
|
|
9955
|
+
pollInstances,
|
|
9956
|
+
_args3 = arguments;
|
|
9957
|
+
|
|
9958
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
9959
|
+
while (1) {
|
|
9960
|
+
switch (_context3.prev = _context3.next) {
|
|
9961
|
+
case 0:
|
|
9962
|
+
sort = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : [];
|
|
9963
|
+
options = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
|
|
9964
|
+
_context3.next = 4;
|
|
9965
|
+
return _this.client.queryPolls(filter, sort, options);
|
|
9966
|
+
|
|
9967
|
+
case 4:
|
|
9968
|
+
_yield$_this$client$q = _context3.sent;
|
|
9969
|
+
polls = _yield$_this$client$q.polls;
|
|
9970
|
+
next = _yield$_this$client$q.next;
|
|
9971
|
+
pollInstances = polls.map(function (poll) {
|
|
9972
|
+
_this.setOrOverwriteInCache(poll, true);
|
|
9973
|
+
|
|
9974
|
+
return _this.fromState(poll.id);
|
|
9975
|
+
});
|
|
9976
|
+
return _context3.abrupt("return", {
|
|
9977
|
+
polls: pollInstances,
|
|
9978
|
+
next: next
|
|
9979
|
+
});
|
|
9980
|
+
|
|
9981
|
+
case 9:
|
|
9982
|
+
case "end":
|
|
9983
|
+
return _context3.stop();
|
|
9984
|
+
}
|
|
9985
|
+
}
|
|
9986
|
+
}, _callee3);
|
|
9987
|
+
}));
|
|
9988
|
+
|
|
9989
|
+
return function (_x3) {
|
|
9990
|
+
return _ref5.apply(this, arguments);
|
|
9991
|
+
};
|
|
9992
|
+
}());
|
|
8696
9993
|
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
nextThreads = [];
|
|
8701
|
-
_iterator = _createForOfIteratorHelper$1(response.threads);
|
|
9994
|
+
_defineProperty__default['default'](this, "hydratePollCache", function (messages, overwriteState) {
|
|
9995
|
+
var _iterator = _createForOfIteratorHelper$1(messages),
|
|
9996
|
+
_step;
|
|
8702
9997
|
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
existingThread = currentThreads[incomingThread.id];
|
|
9998
|
+
try {
|
|
9999
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
10000
|
+
var message = _step.value;
|
|
8707
10001
|
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
10002
|
+
if (!message.poll) {
|
|
10003
|
+
continue;
|
|
10004
|
+
}
|
|
8711
10005
|
|
|
8712
|
-
|
|
8713
|
-
existingThread.hydrateState(incomingThread);
|
|
8714
|
-
}
|
|
8715
|
-
} else {
|
|
8716
|
-
nextThreads.push(incomingThread);
|
|
8717
|
-
}
|
|
8718
|
-
}
|
|
8719
|
-
} catch (err) {
|
|
8720
|
-
_iterator.e(err);
|
|
8721
|
-
} finally {
|
|
8722
|
-
_iterator.f();
|
|
8723
|
-
}
|
|
10006
|
+
var pollResponse = message.poll;
|
|
8724
10007
|
|
|
8725
|
-
|
|
8726
|
-
|
|
10008
|
+
_this.setOrOverwriteInCache(pollResponse, overwriteState);
|
|
10009
|
+
}
|
|
10010
|
+
} catch (err) {
|
|
10011
|
+
_iterator.e(err);
|
|
10012
|
+
} finally {
|
|
10013
|
+
_iterator.f();
|
|
10014
|
+
}
|
|
10015
|
+
});
|
|
8727
10016
|
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
unseenThreadIds: [],
|
|
8731
|
-
isThreadOrderStale: false,
|
|
8732
|
-
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8733
|
-
isLoading: false,
|
|
8734
|
-
nextCursor: (_response$next = response.next) !== null && _response$next !== void 0 ? _response$next : null
|
|
8735
|
-
}),
|
|
8736
|
-
ready: true
|
|
8737
|
-
});
|
|
8738
|
-
});
|
|
10017
|
+
_defineProperty__default['default'](this, "setOrOverwriteInCache", function (pollResponse, overwriteState) {
|
|
10018
|
+
var pollFromCache = _this.fromState(pollResponse.id);
|
|
8739
10019
|
|
|
8740
|
-
|
|
8741
|
-
|
|
10020
|
+
if (!pollFromCache) {
|
|
10021
|
+
var poll = new Poll({
|
|
10022
|
+
client: _this.client,
|
|
10023
|
+
poll: pollResponse
|
|
10024
|
+
});
|
|
8742
10025
|
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
10026
|
+
_this.pollCache.set(poll.id, poll);
|
|
10027
|
+
} else if (overwriteState) {
|
|
10028
|
+
pollFromCache.reinitializeState(pollResponse);
|
|
10029
|
+
}
|
|
10030
|
+
});
|
|
8746
10031
|
|
|
8747
|
-
|
|
10032
|
+
_defineProperty__default['default'](this, "subscribePollUpdated", function () {
|
|
10033
|
+
return _this.client.on('poll.updated', function (event) {
|
|
10034
|
+
var _event$poll;
|
|
8748
10035
|
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8752
|
-
isLoading: false
|
|
8753
|
-
})
|
|
8754
|
-
});
|
|
8755
|
-
});
|
|
10036
|
+
if ((_event$poll = event.poll) !== null && _event$poll !== void 0 && _event$poll.id) {
|
|
10037
|
+
var _this$fromState;
|
|
8756
10038
|
|
|
8757
|
-
|
|
8758
|
-
case "end":
|
|
8759
|
-
return _context.stop();
|
|
8760
|
-
}
|
|
10039
|
+
(_this$fromState = _this.fromState(event.poll.id)) === null || _this$fromState === void 0 ? void 0 : _this$fromState.handlePollUpdated(event);
|
|
8761
10040
|
}
|
|
8762
|
-
}
|
|
8763
|
-
})));
|
|
8764
|
-
|
|
8765
|
-
_defineProperty__default['default'](this, "queryThreads", function () {
|
|
8766
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8767
|
-
return _this.client.queryThreads(_objectSpread$1({
|
|
8768
|
-
limit: 25,
|
|
8769
|
-
participant_limit: 10,
|
|
8770
|
-
reply_limit: 10,
|
|
8771
|
-
watch: true
|
|
8772
|
-
}, options));
|
|
10041
|
+
}).unsubscribe;
|
|
8773
10042
|
});
|
|
8774
10043
|
|
|
8775
|
-
_defineProperty__default['default'](this, "
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
pagination,
|
|
8779
|
-
response,
|
|
8780
|
-
_args2 = arguments;
|
|
10044
|
+
_defineProperty__default['default'](this, "subscribePollClosed", function () {
|
|
10045
|
+
return _this.client.on('poll.closed', function (event) {
|
|
10046
|
+
var _event$poll2;
|
|
8781
10047
|
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
switch (_context2.prev = _context2.next) {
|
|
8785
|
-
case 0:
|
|
8786
|
-
options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
8787
|
-
_this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
|
|
10048
|
+
if ((_event$poll2 = event.poll) !== null && _event$poll2 !== void 0 && _event$poll2.id) {
|
|
10049
|
+
var _this$fromState2;
|
|
8788
10050
|
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
10051
|
+
(_this$fromState2 = _this.fromState(event.poll.id)) === null || _this$fromState2 === void 0 ? void 0 : _this$fromState2.handlePollClosed(event);
|
|
10052
|
+
}
|
|
10053
|
+
}).unsubscribe;
|
|
10054
|
+
});
|
|
8793
10055
|
|
|
8794
|
-
|
|
10056
|
+
_defineProperty__default['default'](this, "subscribeVoteCasted", function () {
|
|
10057
|
+
return _this.client.on('poll.vote_casted', function (event) {
|
|
10058
|
+
var _event$poll3;
|
|
8795
10059
|
|
|
8796
|
-
|
|
8797
|
-
|
|
10060
|
+
if ((_event$poll3 = event.poll) !== null && _event$poll3 !== void 0 && _event$poll3.id) {
|
|
10061
|
+
var _this$fromState3;
|
|
8798
10062
|
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
});
|
|
10063
|
+
(_this$fromState3 = _this.fromState(event.poll.id)) === null || _this$fromState3 === void 0 ? void 0 : _this$fromState3.handleVoteCasted(event);
|
|
10064
|
+
}
|
|
10065
|
+
}).unsubscribe;
|
|
10066
|
+
});
|
|
8804
10067
|
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
}));
|
|
10068
|
+
_defineProperty__default['default'](this, "subscribeVoteChanged", function () {
|
|
10069
|
+
return _this.client.on('poll.vote_changed', function (event) {
|
|
10070
|
+
var _event$poll4;
|
|
8809
10071
|
|
|
8810
|
-
|
|
8811
|
-
|
|
10072
|
+
if ((_event$poll4 = event.poll) !== null && _event$poll4 !== void 0 && _event$poll4.id) {
|
|
10073
|
+
var _this$fromState4;
|
|
8812
10074
|
|
|
8813
|
-
|
|
8814
|
-
|
|
10075
|
+
(_this$fromState4 = _this.fromState(event.poll.id)) === null || _this$fromState4 === void 0 ? void 0 : _this$fromState4.handleVoteChanged(event);
|
|
10076
|
+
}
|
|
10077
|
+
}).unsubscribe;
|
|
10078
|
+
});
|
|
8815
10079
|
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
nextCursor: (_response$next2 = response.next) !== null && _response$next2 !== void 0 ? _response$next2 : null,
|
|
8820
|
-
isLoadingNext: false
|
|
8821
|
-
})
|
|
8822
|
-
});
|
|
8823
|
-
});
|
|
10080
|
+
_defineProperty__default['default'](this, "subscribeVoteRemoved", function () {
|
|
10081
|
+
return _this.client.on('poll.vote_removed', function (event) {
|
|
10082
|
+
var _event$poll5;
|
|
8824
10083
|
|
|
8825
|
-
|
|
8826
|
-
|
|
10084
|
+
if ((_event$poll5 = event.poll) !== null && _event$poll5 !== void 0 && _event$poll5.id) {
|
|
10085
|
+
var _this$fromState5;
|
|
8827
10086
|
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
10087
|
+
(_this$fromState5 = _this.fromState(event.poll.id)) === null || _this$fromState5 === void 0 ? void 0 : _this$fromState5.handleVoteRemoved(event);
|
|
10088
|
+
}
|
|
10089
|
+
}).unsubscribe;
|
|
10090
|
+
});
|
|
8831
10091
|
|
|
8832
|
-
|
|
10092
|
+
_defineProperty__default['default'](this, "subscribeMessageNew", function () {
|
|
10093
|
+
return _this.client.on('message.new', function (event) {
|
|
10094
|
+
var message = event.message;
|
|
8833
10095
|
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8837
|
-
isLoadingNext: false
|
|
8838
|
-
})
|
|
8839
|
-
});
|
|
8840
|
-
});
|
|
10096
|
+
if (message) {
|
|
10097
|
+
var formattedMessage = formatMessage(message);
|
|
8841
10098
|
|
|
8842
|
-
|
|
8843
|
-
case "end":
|
|
8844
|
-
return _context2.stop();
|
|
8845
|
-
}
|
|
10099
|
+
_this.hydratePollCache([formattedMessage]);
|
|
8846
10100
|
}
|
|
8847
|
-
}
|
|
8848
|
-
})
|
|
10101
|
+
}).unsubscribe;
|
|
10102
|
+
});
|
|
8849
10103
|
|
|
8850
10104
|
this.client = client;
|
|
8851
|
-
this.state = new StateStore({
|
|
8852
|
-
active: false,
|
|
8853
|
-
isThreadOrderStale: false,
|
|
8854
|
-
threads: [],
|
|
8855
|
-
unreadThreadCount: 0,
|
|
8856
|
-
unseenThreadIds: [],
|
|
8857
|
-
lastConnectionDropAt: null,
|
|
8858
|
-
pagination: {
|
|
8859
|
-
isLoading: false,
|
|
8860
|
-
isLoadingNext: false,
|
|
8861
|
-
nextCursor: null
|
|
8862
|
-
},
|
|
8863
|
-
ready: false
|
|
8864
|
-
});
|
|
8865
|
-
this.threadsByIdGetterCache = {
|
|
8866
|
-
threads: [],
|
|
8867
|
-
threadsById: {}
|
|
8868
|
-
};
|
|
8869
10105
|
}
|
|
8870
10106
|
|
|
8871
|
-
_createClass__default['default'](
|
|
8872
|
-
key: "
|
|
10107
|
+
_createClass__default['default'](PollManager, [{
|
|
10108
|
+
key: "data",
|
|
8873
10109
|
get: function get() {
|
|
8874
|
-
|
|
8875
|
-
threads = _this$state$getLatest5.threads;
|
|
8876
|
-
|
|
8877
|
-
if (threads === this.threadsByIdGetterCache.threads) {
|
|
8878
|
-
return this.threadsByIdGetterCache.threadsById;
|
|
8879
|
-
}
|
|
8880
|
-
|
|
8881
|
-
var threadsById = threads.reduce(function (newThreadsById, thread) {
|
|
8882
|
-
newThreadsById[thread.id] = thread;
|
|
8883
|
-
return newThreadsById;
|
|
8884
|
-
}, {});
|
|
8885
|
-
this.threadsByIdGetterCache.threads = threads;
|
|
8886
|
-
this.threadsByIdGetterCache.threadsById = threadsById;
|
|
8887
|
-
return threadsById;
|
|
10110
|
+
return this.pollCache;
|
|
8888
10111
|
}
|
|
8889
10112
|
}]);
|
|
8890
10113
|
|
|
8891
|
-
return
|
|
10114
|
+
return PollManager;
|
|
8892
10115
|
}();
|
|
8893
10116
|
|
|
8894
10117
|
var _excluded = ["created_at", "updated_at", "last_active", "online"],
|
|
@@ -8921,6 +10144,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8921
10144
|
|
|
8922
10145
|
_defineProperty__default['default'](this, "threads", void 0);
|
|
8923
10146
|
|
|
10147
|
+
_defineProperty__default['default'](this, "polls", void 0);
|
|
10148
|
+
|
|
8924
10149
|
_defineProperty__default['default'](this, "anonymous", void 0);
|
|
8925
10150
|
|
|
8926
10151
|
_defineProperty__default['default'](this, "persistUserOnConnectionFailure", void 0);
|
|
@@ -9819,6 +11044,9 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9819
11044
|
this.threads = new ThreadManager({
|
|
9820
11045
|
client: this
|
|
9821
11046
|
});
|
|
11047
|
+
this.polls = new PollManager({
|
|
11048
|
+
client: this
|
|
11049
|
+
});
|
|
9822
11050
|
}
|
|
9823
11051
|
/**
|
|
9824
11052
|
* Get a client instance
|
|
@@ -11085,6 +12313,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11085
12313
|
returnedPage: channelState.messages,
|
|
11086
12314
|
logger: this.logger
|
|
11087
12315
|
}));
|
|
12316
|
+
this.polls.hydratePollCache(updatedMessagesSet.messages, true);
|
|
11088
12317
|
}
|
|
11089
12318
|
|
|
11090
12319
|
channels.push(c);
|
|
@@ -13386,7 +14615,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13386
14615
|
}, {
|
|
13387
14616
|
key: "getUserAgent",
|
|
13388
14617
|
value: function getUserAgent() {
|
|
13389
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.
|
|
14618
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.43.0");
|
|
13390
14619
|
}
|
|
13391
14620
|
}, {
|
|
13392
14621
|
key: "setUserAgent",
|
|
@@ -14830,7 +16059,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
14830
16059
|
}()
|
|
14831
16060
|
/**
|
|
14832
16061
|
* Creates a poll
|
|
14833
|
-
* @param
|
|
16062
|
+
* @param poll PollData The poll that will be created
|
|
14834
16063
|
* @param userId string The user id (only serverside)
|
|
14835
16064
|
* @returns {APIResponse & CreatePollAPIResponse} The poll
|
|
14836
16065
|
*/
|
|
@@ -15030,13 +16259,11 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15030
16259
|
while (1) {
|
|
15031
16260
|
switch (_context103.prev = _context103.next) {
|
|
15032
16261
|
case 0:
|
|
15033
|
-
return _context103.abrupt("return", this.partialUpdatePoll(id,
|
|
16262
|
+
return _context103.abrupt("return", this.partialUpdatePoll(id, {
|
|
15034
16263
|
set: {
|
|
15035
16264
|
is_closed: true
|
|
15036
16265
|
}
|
|
15037
|
-
}, userId
|
|
15038
|
-
user_id: userId
|
|
15039
|
-
} : {})));
|
|
16266
|
+
}, userId));
|
|
15040
16267
|
|
|
15041
16268
|
case 1:
|
|
15042
16269
|
case "end":
|
|
@@ -15412,6 +16639,60 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15412
16639
|
|
|
15413
16640
|
return queryPollVotes;
|
|
15414
16641
|
}()
|
|
16642
|
+
/**
|
|
16643
|
+
* Queries poll answers
|
|
16644
|
+
* @param pollId
|
|
16645
|
+
* @param filter
|
|
16646
|
+
* @param sort
|
|
16647
|
+
* @param options Option object, {limit: 10, offset:0}
|
|
16648
|
+
* @param userId string The user id (only serverside)
|
|
16649
|
+
* @returns {APIResponse & PollAnswersAPIResponse} The poll votes
|
|
16650
|
+
*/
|
|
16651
|
+
|
|
16652
|
+
}, {
|
|
16653
|
+
key: "queryPollAnswers",
|
|
16654
|
+
value: function () {
|
|
16655
|
+
var _queryPollAnswers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee113(pollId) {
|
|
16656
|
+
var filter,
|
|
16657
|
+
sort,
|
|
16658
|
+
options,
|
|
16659
|
+
userId,
|
|
16660
|
+
q,
|
|
16661
|
+
_args113 = arguments;
|
|
16662
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee113$(_context113) {
|
|
16663
|
+
while (1) {
|
|
16664
|
+
switch (_context113.prev = _context113.next) {
|
|
16665
|
+
case 0:
|
|
16666
|
+
filter = _args113.length > 1 && _args113[1] !== undefined ? _args113[1] : {};
|
|
16667
|
+
sort = _args113.length > 2 && _args113[2] !== undefined ? _args113[2] : [];
|
|
16668
|
+
options = _args113.length > 3 && _args113[3] !== undefined ? _args113[3] : {};
|
|
16669
|
+
userId = _args113.length > 4 ? _args113[4] : undefined;
|
|
16670
|
+
q = userId ? "?user_id=".concat(userId) : '';
|
|
16671
|
+
_context113.next = 7;
|
|
16672
|
+
return this.post(this.baseURL + "/polls/".concat(encodeURIComponent(pollId), "/votes").concat(q), _objectSpread({
|
|
16673
|
+
filter: _objectSpread(_objectSpread({}, filter), {}, {
|
|
16674
|
+
is_answer: true
|
|
16675
|
+
}),
|
|
16676
|
+
sort: normalizeQuerySort(sort)
|
|
16677
|
+
}, options));
|
|
16678
|
+
|
|
16679
|
+
case 7:
|
|
16680
|
+
return _context113.abrupt("return", _context113.sent);
|
|
16681
|
+
|
|
16682
|
+
case 8:
|
|
16683
|
+
case "end":
|
|
16684
|
+
return _context113.stop();
|
|
16685
|
+
}
|
|
16686
|
+
}
|
|
16687
|
+
}, _callee113, this);
|
|
16688
|
+
}));
|
|
16689
|
+
|
|
16690
|
+
function queryPollAnswers(_x174) {
|
|
16691
|
+
return _queryPollAnswers.apply(this, arguments);
|
|
16692
|
+
}
|
|
16693
|
+
|
|
16694
|
+
return queryPollAnswers;
|
|
16695
|
+
}()
|
|
15415
16696
|
/**
|
|
15416
16697
|
* Query message history
|
|
15417
16698
|
* @param filter
|
|
@@ -15423,33 +16704,33 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15423
16704
|
}, {
|
|
15424
16705
|
key: "queryMessageHistory",
|
|
15425
16706
|
value: function () {
|
|
15426
|
-
var _queryMessageHistory = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
16707
|
+
var _queryMessageHistory = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee114() {
|
|
15427
16708
|
var filter,
|
|
15428
16709
|
sort,
|
|
15429
16710
|
options,
|
|
15430
|
-
|
|
15431
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
16711
|
+
_args114 = arguments;
|
|
16712
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee114$(_context114) {
|
|
15432
16713
|
while (1) {
|
|
15433
|
-
switch (
|
|
16714
|
+
switch (_context114.prev = _context114.next) {
|
|
15434
16715
|
case 0:
|
|
15435
|
-
filter =
|
|
15436
|
-
sort =
|
|
15437
|
-
options =
|
|
15438
|
-
|
|
16716
|
+
filter = _args114.length > 0 && _args114[0] !== undefined ? _args114[0] : {};
|
|
16717
|
+
sort = _args114.length > 1 && _args114[1] !== undefined ? _args114[1] : [];
|
|
16718
|
+
options = _args114.length > 2 && _args114[2] !== undefined ? _args114[2] : {};
|
|
16719
|
+
_context114.next = 5;
|
|
15439
16720
|
return this.post(this.baseURL + '/messages/history', _objectSpread({
|
|
15440
16721
|
filter: filter,
|
|
15441
16722
|
sort: normalizeQuerySort(sort)
|
|
15442
16723
|
}, options));
|
|
15443
16724
|
|
|
15444
16725
|
case 5:
|
|
15445
|
-
return
|
|
16726
|
+
return _context114.abrupt("return", _context114.sent);
|
|
15446
16727
|
|
|
15447
16728
|
case 6:
|
|
15448
16729
|
case "end":
|
|
15449
|
-
return
|
|
16730
|
+
return _context114.stop();
|
|
15450
16731
|
}
|
|
15451
16732
|
}
|
|
15452
|
-
},
|
|
16733
|
+
}, _callee114, this);
|
|
15453
16734
|
}));
|
|
15454
16735
|
|
|
15455
16736
|
function queryMessageHistory() {
|
|
@@ -15470,32 +16751,32 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15470
16751
|
}, {
|
|
15471
16752
|
key: "updateFlags",
|
|
15472
16753
|
value: function () {
|
|
15473
|
-
var _updateFlags = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
16754
|
+
var _updateFlags = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee115(message_ids, reviewed_by) {
|
|
15474
16755
|
var options,
|
|
15475
|
-
|
|
15476
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
16756
|
+
_args115 = arguments;
|
|
16757
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee115$(_context115) {
|
|
15477
16758
|
while (1) {
|
|
15478
|
-
switch (
|
|
16759
|
+
switch (_context115.prev = _context115.next) {
|
|
15479
16760
|
case 0:
|
|
15480
|
-
options =
|
|
15481
|
-
|
|
16761
|
+
options = _args115.length > 2 && _args115[2] !== undefined ? _args115[2] : {};
|
|
16762
|
+
_context115.next = 3;
|
|
15482
16763
|
return this.post(this.baseURL + '/automod/v1/moderation/update_flags', _objectSpread({
|
|
15483
16764
|
message_ids: message_ids,
|
|
15484
16765
|
reviewed_by: reviewed_by
|
|
15485
16766
|
}, options));
|
|
15486
16767
|
|
|
15487
16768
|
case 3:
|
|
15488
|
-
return
|
|
16769
|
+
return _context115.abrupt("return", _context115.sent);
|
|
15489
16770
|
|
|
15490
16771
|
case 4:
|
|
15491
16772
|
case "end":
|
|
15492
|
-
return
|
|
16773
|
+
return _context115.stop();
|
|
15493
16774
|
}
|
|
15494
16775
|
}
|
|
15495
|
-
},
|
|
16776
|
+
}, _callee115, this);
|
|
15496
16777
|
}));
|
|
15497
16778
|
|
|
15498
|
-
function updateFlags(
|
|
16779
|
+
function updateFlags(_x175, _x176) {
|
|
15499
16780
|
return _updateFlags.apply(this, arguments);
|
|
15500
16781
|
}
|
|
15501
16782
|
|
|
@@ -15677,6 +16958,8 @@ exports.MaxPriority = MaxPriority;
|
|
|
15677
16958
|
exports.MinPriority = MinPriority;
|
|
15678
16959
|
exports.Moderation = Moderation;
|
|
15679
16960
|
exports.Permission = Permission;
|
|
16961
|
+
exports.Poll = Poll;
|
|
16962
|
+
exports.PollManager = PollManager;
|
|
15680
16963
|
exports.Segment = Segment;
|
|
15681
16964
|
exports.StableWSConnection = StableWSConnection;
|
|
15682
16965
|
exports.StateStore = StateStore;
|
|
@@ -15690,8 +16973,11 @@ exports.buildWsSuccessAfterFailureInsight = buildWsSuccessAfterFailureInsight;
|
|
|
15690
16973
|
exports.chatCodes = chatCodes;
|
|
15691
16974
|
exports.decodeBase64 = decodeBase64;
|
|
15692
16975
|
exports.encodeBase64 = encodeBase64;
|
|
16976
|
+
exports.extractPollData = extractPollData;
|
|
16977
|
+
exports.extractPollEnrichedData = extractPollEnrichedData;
|
|
15693
16978
|
exports.formatMessage = formatMessage;
|
|
15694
16979
|
exports.isOwnUser = isOwnUser;
|
|
16980
|
+
exports.isVoteAnswer = isVoteAnswer;
|
|
15695
16981
|
exports.logChatPromiseExecution = logChatPromiseExecution;
|
|
15696
16982
|
exports.postInsights = postInsights;
|
|
15697
16983
|
//# sourceMappingURL=index.js.map
|