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