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