stream-chat 8.41.1 → 8.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.es.js +2167 -886
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +2170 -884
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +2167 -886
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2170 -884
- package/dist/index.js.map +1 -1
- package/dist/types/channel.d.ts +63 -3
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +1 -5
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +27 -15
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/index.d.ts +8 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/moderation.d.ts +30 -1
- package/dist/types/moderation.d.ts.map +1 -1
- package/dist/types/poll.d.ts +64 -0
- package/dist/types/poll.d.ts.map +1 -0
- package/dist/types/poll_manager.d.ts +31 -0
- package/dist/types/poll_manager.d.ts.map +1 -0
- package/dist/types/types.d.ts +59 -23
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/channel.ts +93 -27
- package/src/channel_state.ts +0 -92
- package/src/client.ts +112 -70
- package/src/index.ts +8 -6
- package/src/moderation.ts +64 -0
- package/src/poll.ts +414 -0
- package/src/poll_manager.ts +162 -0
- package/src/types.ts +93 -39
package/dist/index.es.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { fromByteArray } from 'base64-js';
|
|
2
|
-
import _extends from '@babel/runtime/helpers/extends';
|
|
3
|
-
import _typeof from '@babel/runtime/helpers/typeof';
|
|
4
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
6
2
|
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
7
3
|
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
8
4
|
import _createClass from '@babel/runtime/helpers/createClass';
|
|
9
5
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
10
6
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
7
|
+
import _extends from '@babel/runtime/helpers/extends';
|
|
8
|
+
import _typeof from '@babel/runtime/helpers/typeof';
|
|
9
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
10
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
11
11
|
import axios from 'axios';
|
|
12
12
|
import https from 'https';
|
|
13
13
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
@@ -94,15 +94,220 @@ var decodeBase64 = function decodeBase64(s) {
|
|
|
94
94
|
return r;
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
var Campaign = /*#__PURE__*/function () {
|
|
98
|
+
function Campaign(client, id, data) {
|
|
99
|
+
_classCallCheck(this, Campaign);
|
|
98
100
|
|
|
99
|
-
|
|
101
|
+
_defineProperty(this, "id", void 0);
|
|
100
102
|
|
|
101
|
-
|
|
103
|
+
_defineProperty(this, "data", void 0);
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
_defineProperty(this, "client", void 0);
|
|
104
106
|
|
|
105
|
-
|
|
107
|
+
this.client = client;
|
|
108
|
+
this.id = id;
|
|
109
|
+
this.data = data;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
_createClass(Campaign, [{
|
|
113
|
+
key: "create",
|
|
114
|
+
value: function () {
|
|
115
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
116
|
+
var _this$data, _this$data2, _this$data3, _this$data4, _this$data5, _this$data6, _this$data7, _this$data8;
|
|
117
|
+
|
|
118
|
+
var body, result;
|
|
119
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
120
|
+
while (1) {
|
|
121
|
+
switch (_context.prev = _context.next) {
|
|
122
|
+
case 0:
|
|
123
|
+
body = {
|
|
124
|
+
id: this.id,
|
|
125
|
+
message_template: (_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.message_template,
|
|
126
|
+
segment_ids: (_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2.segment_ids,
|
|
127
|
+
sender_id: (_this$data3 = this.data) === null || _this$data3 === void 0 ? void 0 : _this$data3.sender_id,
|
|
128
|
+
channel_template: (_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : _this$data4.channel_template,
|
|
129
|
+
create_channels: (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5.create_channels,
|
|
130
|
+
description: (_this$data6 = this.data) === null || _this$data6 === void 0 ? void 0 : _this$data6.description,
|
|
131
|
+
name: (_this$data7 = this.data) === null || _this$data7 === void 0 ? void 0 : _this$data7.name,
|
|
132
|
+
user_ids: (_this$data8 = this.data) === null || _this$data8 === void 0 ? void 0 : _this$data8.user_ids
|
|
133
|
+
};
|
|
134
|
+
_context.next = 3;
|
|
135
|
+
return this.client.createCampaign(body);
|
|
136
|
+
|
|
137
|
+
case 3:
|
|
138
|
+
result = _context.sent;
|
|
139
|
+
this.id = result.campaign.id;
|
|
140
|
+
this.data = result.campaign;
|
|
141
|
+
return _context.abrupt("return", result);
|
|
142
|
+
|
|
143
|
+
case 7:
|
|
144
|
+
case "end":
|
|
145
|
+
return _context.stop();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}, _callee, this);
|
|
149
|
+
}));
|
|
150
|
+
|
|
151
|
+
function create() {
|
|
152
|
+
return _create.apply(this, arguments);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return create;
|
|
156
|
+
}()
|
|
157
|
+
}, {
|
|
158
|
+
key: "verifyCampaignId",
|
|
159
|
+
value: function verifyCampaignId() {
|
|
160
|
+
if (!this.id) {
|
|
161
|
+
throw new Error('Campaign id is missing. Either create the campaign using campaign.create() or set the id during instantiation - const campaign = client.campaign(id)');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}, {
|
|
165
|
+
key: "start",
|
|
166
|
+
value: function () {
|
|
167
|
+
var _start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
|
|
168
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
169
|
+
while (1) {
|
|
170
|
+
switch (_context2.prev = _context2.next) {
|
|
171
|
+
case 0:
|
|
172
|
+
this.verifyCampaignId();
|
|
173
|
+
_context2.next = 3;
|
|
174
|
+
return this.client.startCampaign(this.id, options);
|
|
175
|
+
|
|
176
|
+
case 3:
|
|
177
|
+
return _context2.abrupt("return", _context2.sent);
|
|
178
|
+
|
|
179
|
+
case 4:
|
|
180
|
+
case "end":
|
|
181
|
+
return _context2.stop();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}, _callee2, this);
|
|
185
|
+
}));
|
|
186
|
+
|
|
187
|
+
function start(_x) {
|
|
188
|
+
return _start.apply(this, arguments);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return start;
|
|
192
|
+
}()
|
|
193
|
+
}, {
|
|
194
|
+
key: "update",
|
|
195
|
+
value: function () {
|
|
196
|
+
var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
|
|
197
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
198
|
+
while (1) {
|
|
199
|
+
switch (_context3.prev = _context3.next) {
|
|
200
|
+
case 0:
|
|
201
|
+
this.verifyCampaignId();
|
|
202
|
+
return _context3.abrupt("return", this.client.updateCampaign(this.id, data));
|
|
203
|
+
|
|
204
|
+
case 2:
|
|
205
|
+
case "end":
|
|
206
|
+
return _context3.stop();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}, _callee3, this);
|
|
210
|
+
}));
|
|
211
|
+
|
|
212
|
+
function update(_x2) {
|
|
213
|
+
return _update.apply(this, arguments);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return update;
|
|
217
|
+
}()
|
|
218
|
+
}, {
|
|
219
|
+
key: "delete",
|
|
220
|
+
value: function () {
|
|
221
|
+
var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
222
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
223
|
+
while (1) {
|
|
224
|
+
switch (_context4.prev = _context4.next) {
|
|
225
|
+
case 0:
|
|
226
|
+
this.verifyCampaignId();
|
|
227
|
+
_context4.next = 3;
|
|
228
|
+
return this.client.deleteCampaign(this.id);
|
|
229
|
+
|
|
230
|
+
case 3:
|
|
231
|
+
return _context4.abrupt("return", _context4.sent);
|
|
232
|
+
|
|
233
|
+
case 4:
|
|
234
|
+
case "end":
|
|
235
|
+
return _context4.stop();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}, _callee4, this);
|
|
239
|
+
}));
|
|
240
|
+
|
|
241
|
+
function _delete() {
|
|
242
|
+
return _delete2.apply(this, arguments);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return _delete;
|
|
246
|
+
}()
|
|
247
|
+
}, {
|
|
248
|
+
key: "stop",
|
|
249
|
+
value: function () {
|
|
250
|
+
var _stop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
251
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
252
|
+
while (1) {
|
|
253
|
+
switch (_context5.prev = _context5.next) {
|
|
254
|
+
case 0:
|
|
255
|
+
this.verifyCampaignId();
|
|
256
|
+
return _context5.abrupt("return", this.client.stopCampaign(this.id));
|
|
257
|
+
|
|
258
|
+
case 2:
|
|
259
|
+
case "end":
|
|
260
|
+
return _context5.stop();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}, _callee5, this);
|
|
264
|
+
}));
|
|
265
|
+
|
|
266
|
+
function stop() {
|
|
267
|
+
return _stop.apply(this, arguments);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return stop;
|
|
271
|
+
}()
|
|
272
|
+
}, {
|
|
273
|
+
key: "get",
|
|
274
|
+
value: function () {
|
|
275
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
276
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
277
|
+
while (1) {
|
|
278
|
+
switch (_context6.prev = _context6.next) {
|
|
279
|
+
case 0:
|
|
280
|
+
this.verifyCampaignId();
|
|
281
|
+
return _context6.abrupt("return", this.client.getCampaign(this.id));
|
|
282
|
+
|
|
283
|
+
case 2:
|
|
284
|
+
case "end":
|
|
285
|
+
return _context6.stop();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}, _callee6, this);
|
|
289
|
+
}));
|
|
290
|
+
|
|
291
|
+
function get() {
|
|
292
|
+
return _get.apply(this, arguments);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return get;
|
|
296
|
+
}()
|
|
297
|
+
}]);
|
|
298
|
+
|
|
299
|
+
return Campaign;
|
|
300
|
+
}();
|
|
301
|
+
|
|
302
|
+
function ownKeys$c(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
303
|
+
|
|
304
|
+
function _objectSpread$c(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$c(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$c(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
305
|
+
|
|
306
|
+
function _createForOfIteratorHelper$5(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function (_e) { function e(_x) { return _e.apply(this, arguments); } e.toString = function () { return _e.toString(); }; return e; }(function (e) { throw e; }), f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function (_e2) { function e(_x2) { return _e2.apply(this, arguments); } e.toString = function () { return _e2.toString(); }; return e; }(function (e) { didErr = true; err = e; }), f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
307
|
+
|
|
308
|
+
function _unsupportedIterableToArray$5(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$5(o, minLen); }
|
|
309
|
+
|
|
310
|
+
function _arrayLikeToArray$5(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
106
311
|
|
|
107
312
|
/**
|
|
108
313
|
* logChatPromiseExecution - utility function for logging the execution of a promise..
|
|
@@ -187,7 +392,7 @@ function normalizeQuerySort(sort) {
|
|
|
187
392
|
var sortFields = [];
|
|
188
393
|
var sortArr = Array.isArray(sort) ? sort : [sort];
|
|
189
394
|
|
|
190
|
-
var _iterator = _createForOfIteratorHelper$
|
|
395
|
+
var _iterator = _createForOfIteratorHelper$5(sortArr),
|
|
191
396
|
_step;
|
|
192
397
|
|
|
193
398
|
try {
|
|
@@ -357,7 +562,7 @@ var axiosParamsSerializer = function axiosParamsSerializer(params) {
|
|
|
357
562
|
*/
|
|
358
563
|
|
|
359
564
|
function formatMessage(message) {
|
|
360
|
-
return _objectSpread$
|
|
565
|
+
return _objectSpread$c(_objectSpread$c({}, message), {}, {
|
|
361
566
|
/**
|
|
362
567
|
* @deprecated please use `html`
|
|
363
568
|
*/
|
|
@@ -562,7 +767,7 @@ var messagePaginationCreatedAtAround = function messagePaginationCreatedAtAround
|
|
|
562
767
|
returnedPage = _ref3.returnedPage,
|
|
563
768
|
messagePaginationOptions = _ref3.messagePaginationOptions;
|
|
564
769
|
|
|
565
|
-
var newPagination = _objectSpread$
|
|
770
|
+
var newPagination = _objectSpread$c({}, parentSet.pagination);
|
|
566
771
|
|
|
567
772
|
if (!(messagePaginationOptions !== null && messagePaginationOptions !== void 0 && messagePaginationOptions.created_at_around)) return newPagination;
|
|
568
773
|
var hasPrev;
|
|
@@ -627,7 +832,7 @@ var messagePaginationIdAround = function messagePaginationIdAround(_ref5) {
|
|
|
627
832
|
returnedPage = _ref5.returnedPage,
|
|
628
833
|
messagePaginationOptions = _ref5.messagePaginationOptions;
|
|
629
834
|
|
|
630
|
-
var newPagination = _objectSpread$
|
|
835
|
+
var newPagination = _objectSpread$c({}, parentSet.pagination);
|
|
631
836
|
|
|
632
837
|
var _ref6 = messagePaginationOptions || {},
|
|
633
838
|
id_around = _ref6.id_around;
|
|
@@ -685,7 +890,7 @@ var messagePaginationLinear = function messagePaginationLinear(_ref8) {
|
|
|
685
890
|
returnedPage = _ref8.returnedPage,
|
|
686
891
|
messagePaginationOptions = _ref8.messagePaginationOptions;
|
|
687
892
|
|
|
688
|
-
var newPagination = _objectSpread$
|
|
893
|
+
var newPagination = _objectSpread$c({}, parentSet.pagination);
|
|
689
894
|
|
|
690
895
|
var hasPrev;
|
|
691
896
|
var hasNext;
|
|
@@ -739,9 +944,9 @@ var DEFAULT_MESSAGE_SET_PAGINATION = {
|
|
|
739
944
|
hasPrev: true
|
|
740
945
|
};
|
|
741
946
|
|
|
742
|
-
function ownKeys$
|
|
947
|
+
function ownKeys$b(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
743
948
|
|
|
744
|
-
function _objectSpread$
|
|
949
|
+
function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$b(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
745
950
|
|
|
746
951
|
/**
|
|
747
952
|
* ChannelState - A container class for the channel state.
|
|
@@ -814,153 +1019,42 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
814
1019
|
};
|
|
815
1020
|
});
|
|
816
1021
|
|
|
817
|
-
_defineProperty(this, "
|
|
818
|
-
var
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
if (!message) return;
|
|
823
|
-
if (message.poll_id !== pollVote.poll_id) return;
|
|
824
|
-
|
|
825
|
-
var updatedPoll = _objectSpread$a({}, poll);
|
|
1022
|
+
_defineProperty(this, "updateUserMessages", function (user) {
|
|
1023
|
+
var _updateUserMessages = function _updateUserMessages(messages, user) {
|
|
1024
|
+
for (var i = 0; i < messages.length; i++) {
|
|
1025
|
+
var _m$user;
|
|
826
1026
|
|
|
827
|
-
|
|
1027
|
+
var m = messages[i];
|
|
828
1028
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
});
|
|
835
|
-
} else if (pollVote.answer_text) {
|
|
836
|
-
// remove all previous votes where option_id is empty
|
|
837
|
-
ownVotes = ownVotes.filter(function (vote) {
|
|
838
|
-
return vote.answer_text;
|
|
839
|
-
});
|
|
1029
|
+
if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
|
|
1030
|
+
messages[i] = _objectSpread$b(_objectSpread$b({}, m), {}, {
|
|
1031
|
+
user: user
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
840
1034
|
}
|
|
1035
|
+
};
|
|
841
1036
|
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
updatedPoll.own_votes = ownVotes;
|
|
846
|
-
|
|
847
|
-
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
848
|
-
poll: updatedPoll
|
|
1037
|
+
_this.messageSets.forEach(function (set) {
|
|
1038
|
+
return _updateUserMessages(set.messages, user);
|
|
849
1039
|
});
|
|
850
1040
|
|
|
851
|
-
|
|
852
|
-
|
|
1041
|
+
for (var parentId in _this.threads) {
|
|
1042
|
+
_updateUserMessages(_this.threads[parentId], user);
|
|
1043
|
+
}
|
|
853
1044
|
|
|
854
|
-
|
|
855
|
-
|
|
1045
|
+
_updateUserMessages(_this.pinnedMessages, user);
|
|
1046
|
+
});
|
|
856
1047
|
|
|
857
|
-
|
|
1048
|
+
_defineProperty(this, "deleteUserMessages", function (user) {
|
|
1049
|
+
var hardDelete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
858
1050
|
|
|
859
|
-
|
|
860
|
-
|
|
1051
|
+
var _deleteUserMessages = function _deleteUserMessages(messages, user) {
|
|
1052
|
+
var hardDelete = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
861
1053
|
|
|
862
|
-
|
|
1054
|
+
for (var i = 0; i < messages.length; i++) {
|
|
1055
|
+
var _m$user2;
|
|
863
1056
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
if (pollVote.user_id === _this._channel.getClient().userID) {
|
|
867
|
-
ownVotes.push(pollVote);
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
updatedPoll.own_votes = ownVotes;
|
|
871
|
-
|
|
872
|
-
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
873
|
-
poll: updatedPoll
|
|
874
|
-
});
|
|
875
|
-
|
|
876
|
-
_this.addMessageSorted(newMessage, false, false);
|
|
877
|
-
});
|
|
878
|
-
|
|
879
|
-
_defineProperty(this, "removePollVote", function (pollVote, poll, messageId) {
|
|
880
|
-
var _message$poll3;
|
|
881
|
-
|
|
882
|
-
var message = _this.findMessage(messageId);
|
|
883
|
-
|
|
884
|
-
if (!message) return;
|
|
885
|
-
if (message.poll_id !== pollVote.poll_id) return;
|
|
886
|
-
|
|
887
|
-
var updatedPoll = _objectSpread$a({}, poll);
|
|
888
|
-
|
|
889
|
-
var ownVotes = _toConsumableArray(((_message$poll3 = message.poll) === null || _message$poll3 === void 0 ? void 0 : _message$poll3.own_votes) || []);
|
|
890
|
-
|
|
891
|
-
if (pollVote.user_id === _this._channel.getClient().userID) {
|
|
892
|
-
var index = ownVotes.findIndex(function (vote) {
|
|
893
|
-
return vote.option_id === pollVote.option_id;
|
|
894
|
-
});
|
|
895
|
-
|
|
896
|
-
if (index > -1) {
|
|
897
|
-
ownVotes.splice(index, 1);
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
updatedPoll.own_votes = ownVotes;
|
|
902
|
-
|
|
903
|
-
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
904
|
-
poll: updatedPoll
|
|
905
|
-
});
|
|
906
|
-
|
|
907
|
-
_this.addMessageSorted(newMessage, false, false);
|
|
908
|
-
});
|
|
909
|
-
|
|
910
|
-
_defineProperty(this, "updatePoll", function (poll, messageId) {
|
|
911
|
-
var _message$poll4;
|
|
912
|
-
|
|
913
|
-
var message = _this.findMessage(messageId);
|
|
914
|
-
|
|
915
|
-
if (!message) return;
|
|
916
|
-
|
|
917
|
-
var updatedPoll = _objectSpread$a(_objectSpread$a({}, poll), {}, {
|
|
918
|
-
own_votes: _toConsumableArray(((_message$poll4 = message.poll) === null || _message$poll4 === void 0 ? void 0 : _message$poll4.own_votes) || [])
|
|
919
|
-
});
|
|
920
|
-
|
|
921
|
-
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
922
|
-
poll: updatedPoll
|
|
923
|
-
});
|
|
924
|
-
|
|
925
|
-
_this.addMessageSorted(newMessage, false, false);
|
|
926
|
-
});
|
|
927
|
-
|
|
928
|
-
_defineProperty(this, "updateUserMessages", function (user) {
|
|
929
|
-
var _updateUserMessages = function _updateUserMessages(messages, user) {
|
|
930
|
-
for (var i = 0; i < messages.length; i++) {
|
|
931
|
-
var _m$user;
|
|
932
|
-
|
|
933
|
-
var m = messages[i];
|
|
934
|
-
|
|
935
|
-
if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
|
|
936
|
-
messages[i] = _objectSpread$a(_objectSpread$a({}, m), {}, {
|
|
937
|
-
user: user
|
|
938
|
-
});
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
|
|
943
|
-
_this.messageSets.forEach(function (set) {
|
|
944
|
-
return _updateUserMessages(set.messages, user);
|
|
945
|
-
});
|
|
946
|
-
|
|
947
|
-
for (var parentId in _this.threads) {
|
|
948
|
-
_updateUserMessages(_this.threads[parentId], user);
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
_updateUserMessages(_this.pinnedMessages, user);
|
|
952
|
-
});
|
|
953
|
-
|
|
954
|
-
_defineProperty(this, "deleteUserMessages", function (user) {
|
|
955
|
-
var hardDelete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
956
|
-
|
|
957
|
-
var _deleteUserMessages = function _deleteUserMessages(messages, user) {
|
|
958
|
-
var hardDelete = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
959
|
-
|
|
960
|
-
for (var i = 0; i < messages.length; i++) {
|
|
961
|
-
var _m$user2;
|
|
962
|
-
|
|
963
|
-
var m = messages[i];
|
|
1057
|
+
var m = messages[i];
|
|
964
1058
|
|
|
965
1059
|
if (((_m$user2 = m.user) === null || _m$user2 === void 0 ? void 0 : _m$user2.id) !== user.id) {
|
|
966
1060
|
continue;
|
|
@@ -988,7 +1082,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
988
1082
|
user: m.user
|
|
989
1083
|
};
|
|
990
1084
|
} else {
|
|
991
|
-
messages[i] = _objectSpread$
|
|
1085
|
+
messages[i] = _objectSpread$b(_objectSpread$b({}, m), {}, {
|
|
992
1086
|
type: 'deleted',
|
|
993
1087
|
deleted_at: user.deleted_at ? new Date(user.deleted_at) : null
|
|
994
1088
|
});
|
|
@@ -1306,7 +1400,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1306
1400
|
var parseMessage = function parseMessage(m) {
|
|
1307
1401
|
var _m$pinned_at, _m$updated_at;
|
|
1308
1402
|
|
|
1309
|
-
return _objectSpread$
|
|
1403
|
+
return _objectSpread$b(_objectSpread$b({}, m), {}, {
|
|
1310
1404
|
created_at: m.created_at.toISOString(),
|
|
1311
1405
|
pinned_at: (_m$pinned_at = m.pinned_at) === null || _m$pinned_at === void 0 ? void 0 : _m$pinned_at.toISOString(),
|
|
1312
1406
|
updated_at: (_m$updated_at = m.updated_at) === null || _m$updated_at === void 0 ? void 0 : _m$updated_at.toISOString()
|
|
@@ -1316,8 +1410,8 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1316
1410
|
var update = function update(messages) {
|
|
1317
1411
|
var updatedMessages = messages.reduce(function (acc, msg) {
|
|
1318
1412
|
if (msg.quoted_message_id === message.id) {
|
|
1319
|
-
acc.push(_objectSpread$
|
|
1320
|
-
quoted_message: remove ? _objectSpread$
|
|
1413
|
+
acc.push(_objectSpread$b(_objectSpread$b({}, parseMessage(msg)), {}, {
|
|
1414
|
+
quoted_message: remove ? _objectSpread$b(_objectSpread$b({}, message), {}, {
|
|
1321
1415
|
attachments: []
|
|
1322
1416
|
}) : message
|
|
1323
1417
|
}));
|
|
@@ -1800,15 +1894,15 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1800
1894
|
return ChannelState;
|
|
1801
1895
|
}();
|
|
1802
1896
|
|
|
1803
|
-
function _createForOfIteratorHelper$
|
|
1897
|
+
function _createForOfIteratorHelper$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$4(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
1804
1898
|
|
|
1805
|
-
function _unsupportedIterableToArray$
|
|
1899
|
+
function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen); }
|
|
1806
1900
|
|
|
1807
|
-
function _arrayLikeToArray$
|
|
1901
|
+
function _arrayLikeToArray$4(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
1808
1902
|
|
|
1809
|
-
function ownKeys$
|
|
1903
|
+
function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
1810
1904
|
|
|
1811
|
-
function _objectSpread$
|
|
1905
|
+
function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$a(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1812
1906
|
/**
|
|
1813
1907
|
* Channel - The Channel class manages it's own state.
|
|
1814
1908
|
*/
|
|
@@ -1881,7 +1975,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1881
1975
|
while (1) {
|
|
1882
1976
|
switch (_context.prev = _context.next) {
|
|
1883
1977
|
case 0:
|
|
1884
|
-
defaultOptions = _objectSpread$
|
|
1978
|
+
defaultOptions = _objectSpread$a(_objectSpread$a({}, options), {}, {
|
|
1885
1979
|
watch: false,
|
|
1886
1980
|
state: false,
|
|
1887
1981
|
presence: false
|
|
@@ -1953,7 +2047,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1953
2047
|
|
|
1954
2048
|
this.data = data; // this._data is used for the requests...
|
|
1955
2049
|
|
|
1956
|
-
this._data = _objectSpread$
|
|
2050
|
+
this._data = _objectSpread$a({}, data);
|
|
1957
2051
|
this.cid = "".concat(type, ":").concat(id);
|
|
1958
2052
|
this.listeners = {}; // perhaps the state variable should be private
|
|
1959
2053
|
|
|
@@ -2015,7 +2109,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2015
2109
|
switch (_context2.prev = _context2.next) {
|
|
2016
2110
|
case 0:
|
|
2017
2111
|
_context2.next = 2;
|
|
2018
|
-
return this.getClient().post(this._channelURL() + '/message', _objectSpread$
|
|
2112
|
+
return this.getClient().post(this._channelURL() + '/message', _objectSpread$a({
|
|
2019
2113
|
message: message
|
|
2020
2114
|
}, options));
|
|
2021
2115
|
|
|
@@ -2131,7 +2225,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2131
2225
|
|
|
2132
2226
|
case 3:
|
|
2133
2227
|
// Return a list of channels
|
|
2134
|
-
payload = _objectSpread$
|
|
2228
|
+
payload = _objectSpread$a(_objectSpread$a({
|
|
2135
2229
|
filter_conditions: {
|
|
2136
2230
|
cid: this.cid
|
|
2137
2231
|
}
|
|
@@ -2228,7 +2322,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2228
2322
|
|
|
2229
2323
|
_context5.next = 6;
|
|
2230
2324
|
return this.getClient().get(this.getClient().baseURL + '/members', {
|
|
2231
|
-
payload: _objectSpread$
|
|
2325
|
+
payload: _objectSpread$a({
|
|
2232
2326
|
type: type,
|
|
2233
2327
|
id: id,
|
|
2234
2328
|
members: members,
|
|
@@ -2334,7 +2428,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2334
2428
|
|
|
2335
2429
|
case 4:
|
|
2336
2430
|
_context7.next = 6;
|
|
2337
|
-
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(messageID), "/reaction"), _objectSpread$
|
|
2431
|
+
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(messageID), "/reaction"), _objectSpread$a({
|
|
2338
2432
|
reaction: reaction
|
|
2339
2433
|
}, options));
|
|
2340
2434
|
|
|
@@ -2415,7 +2509,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2415
2509
|
delete channelData[key];
|
|
2416
2510
|
});
|
|
2417
2511
|
_context8.next = 7;
|
|
2418
|
-
return this._update(_objectSpread$
|
|
2512
|
+
return this._update(_objectSpread$a({
|
|
2419
2513
|
message: updateMessage,
|
|
2420
2514
|
data: channelData
|
|
2421
2515
|
}, options));
|
|
@@ -2587,7 +2681,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2587
2681
|
case 0:
|
|
2588
2682
|
options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
2589
2683
|
_context12.next = 3;
|
|
2590
|
-
return this.getClient().delete(this._channelURL(), _objectSpread$
|
|
2684
|
+
return this.getClient().delete(this._channelURL(), _objectSpread$a({}, options));
|
|
2591
2685
|
|
|
2592
2686
|
case 3:
|
|
2593
2687
|
return _context12.abrupt("return", _context12.sent);
|
|
@@ -2663,7 +2757,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2663
2757
|
case 0:
|
|
2664
2758
|
options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
2665
2759
|
_context14.next = 3;
|
|
2666
|
-
return this._update(_objectSpread$
|
|
2760
|
+
return this._update(_objectSpread$a({
|
|
2667
2761
|
accept_invite: true
|
|
2668
2762
|
}, options));
|
|
2669
2763
|
|
|
@@ -2704,7 +2798,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2704
2798
|
case 0:
|
|
2705
2799
|
options = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
|
|
2706
2800
|
_context15.next = 3;
|
|
2707
|
-
return this._update(_objectSpread$
|
|
2801
|
+
return this._update(_objectSpread$a({
|
|
2708
2802
|
reject_invite: true
|
|
2709
2803
|
}, options));
|
|
2710
2804
|
|
|
@@ -2746,7 +2840,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2746
2840
|
case 0:
|
|
2747
2841
|
options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
|
|
2748
2842
|
_context16.next = 3;
|
|
2749
|
-
return this._update(_objectSpread$
|
|
2843
|
+
return this._update(_objectSpread$a({
|
|
2750
2844
|
add_members: members,
|
|
2751
2845
|
message: message
|
|
2752
2846
|
}, options));
|
|
@@ -2789,7 +2883,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2789
2883
|
case 0:
|
|
2790
2884
|
options = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
|
|
2791
2885
|
_context17.next = 3;
|
|
2792
|
-
return this._update(_objectSpread$
|
|
2886
|
+
return this._update(_objectSpread$a({
|
|
2793
2887
|
add_moderators: members,
|
|
2794
2888
|
message: message
|
|
2795
2889
|
}, options));
|
|
@@ -2832,7 +2926,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2832
2926
|
case 0:
|
|
2833
2927
|
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
2834
2928
|
_context18.next = 3;
|
|
2835
|
-
return this._update(_objectSpread$
|
|
2929
|
+
return this._update(_objectSpread$a({
|
|
2836
2930
|
assign_roles: roles,
|
|
2837
2931
|
message: message
|
|
2838
2932
|
}, options));
|
|
@@ -2875,7 +2969,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2875
2969
|
case 0:
|
|
2876
2970
|
options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
|
2877
2971
|
_context19.next = 3;
|
|
2878
|
-
return this._update(_objectSpread$
|
|
2972
|
+
return this._update(_objectSpread$a({
|
|
2879
2973
|
invites: members,
|
|
2880
2974
|
message: message
|
|
2881
2975
|
}, options));
|
|
@@ -2918,7 +3012,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2918
3012
|
case 0:
|
|
2919
3013
|
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
|
2920
3014
|
_context20.next = 3;
|
|
2921
|
-
return this._update(_objectSpread$
|
|
3015
|
+
return this._update(_objectSpread$a({
|
|
2922
3016
|
remove_members: members,
|
|
2923
3017
|
message: message
|
|
2924
3018
|
}, options));
|
|
@@ -2961,7 +3055,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2961
3055
|
case 0:
|
|
2962
3056
|
options = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : {};
|
|
2963
3057
|
_context21.next = 3;
|
|
2964
|
-
return this._update(_objectSpread$
|
|
3058
|
+
return this._update(_objectSpread$a({
|
|
2965
3059
|
demote_moderators: members,
|
|
2966
3060
|
message: message
|
|
2967
3061
|
}, options));
|
|
@@ -3046,7 +3140,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3046
3140
|
case 0:
|
|
3047
3141
|
opts = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
|
|
3048
3142
|
_context23.next = 3;
|
|
3049
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$
|
|
3143
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$a({
|
|
3050
3144
|
channel_cid: this.cid
|
|
3051
3145
|
}, opts));
|
|
3052
3146
|
|
|
@@ -3088,7 +3182,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3088
3182
|
case 0:
|
|
3089
3183
|
opts = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {};
|
|
3090
3184
|
_context24.next = 3;
|
|
3091
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$
|
|
3185
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$a({
|
|
3092
3186
|
channel_cid: this.cid
|
|
3093
3187
|
}, opts));
|
|
3094
3188
|
|
|
@@ -3109,6 +3203,258 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3109
3203
|
|
|
3110
3204
|
return unmute;
|
|
3111
3205
|
}()
|
|
3206
|
+
/**
|
|
3207
|
+
* archive - archives the current channel
|
|
3208
|
+
* @param {{ user_id?: string }} opts user_id if called server side
|
|
3209
|
+
* @return {Promise<ChannelMemberResponse<StreamChatGenerics>>} The server response
|
|
3210
|
+
*
|
|
3211
|
+
* example:
|
|
3212
|
+
* await channel.archives();
|
|
3213
|
+
*
|
|
3214
|
+
* example server side:
|
|
3215
|
+
* await channel.archive({user_id: userId});
|
|
3216
|
+
*
|
|
3217
|
+
*/
|
|
3218
|
+
|
|
3219
|
+
}, {
|
|
3220
|
+
key: "archive",
|
|
3221
|
+
value: function () {
|
|
3222
|
+
var _archive = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
|
|
3223
|
+
var opts,
|
|
3224
|
+
cli,
|
|
3225
|
+
uid,
|
|
3226
|
+
resp,
|
|
3227
|
+
_args25 = arguments;
|
|
3228
|
+
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
3229
|
+
while (1) {
|
|
3230
|
+
switch (_context25.prev = _context25.next) {
|
|
3231
|
+
case 0:
|
|
3232
|
+
opts = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {};
|
|
3233
|
+
cli = this.getClient();
|
|
3234
|
+
uid = opts.user_id || cli.userID;
|
|
3235
|
+
|
|
3236
|
+
if (uid) {
|
|
3237
|
+
_context25.next = 5;
|
|
3238
|
+
break;
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
throw Error('A user_id is required for archiving a channel');
|
|
3242
|
+
|
|
3243
|
+
case 5:
|
|
3244
|
+
_context25.next = 7;
|
|
3245
|
+
return this.partialUpdateMember(uid, {
|
|
3246
|
+
set: {
|
|
3247
|
+
archived: true
|
|
3248
|
+
}
|
|
3249
|
+
});
|
|
3250
|
+
|
|
3251
|
+
case 7:
|
|
3252
|
+
resp = _context25.sent;
|
|
3253
|
+
return _context25.abrupt("return", resp.channel_member);
|
|
3254
|
+
|
|
3255
|
+
case 9:
|
|
3256
|
+
case "end":
|
|
3257
|
+
return _context25.stop();
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
}, _callee25, this);
|
|
3261
|
+
}));
|
|
3262
|
+
|
|
3263
|
+
function archive() {
|
|
3264
|
+
return _archive.apply(this, arguments);
|
|
3265
|
+
}
|
|
3266
|
+
|
|
3267
|
+
return archive;
|
|
3268
|
+
}()
|
|
3269
|
+
/**
|
|
3270
|
+
* unarchive - unarchives the current channel
|
|
3271
|
+
* @param {{ user_id?: string }} opts user_id if called server side
|
|
3272
|
+
* @return {Promise<ChannelMemberResponse<StreamChatGenerics>>} The server response
|
|
3273
|
+
*
|
|
3274
|
+
* example:
|
|
3275
|
+
* await channel.unarchive();
|
|
3276
|
+
*
|
|
3277
|
+
* example server side:
|
|
3278
|
+
* await channel.unarchive({user_id: userId});
|
|
3279
|
+
*
|
|
3280
|
+
*/
|
|
3281
|
+
|
|
3282
|
+
}, {
|
|
3283
|
+
key: "unarchive",
|
|
3284
|
+
value: function () {
|
|
3285
|
+
var _unarchive = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {
|
|
3286
|
+
var opts,
|
|
3287
|
+
cli,
|
|
3288
|
+
uid,
|
|
3289
|
+
resp,
|
|
3290
|
+
_args26 = arguments;
|
|
3291
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context26) {
|
|
3292
|
+
while (1) {
|
|
3293
|
+
switch (_context26.prev = _context26.next) {
|
|
3294
|
+
case 0:
|
|
3295
|
+
opts = _args26.length > 0 && _args26[0] !== undefined ? _args26[0] : {};
|
|
3296
|
+
cli = this.getClient();
|
|
3297
|
+
uid = opts.user_id || cli.userID;
|
|
3298
|
+
|
|
3299
|
+
if (uid) {
|
|
3300
|
+
_context26.next = 5;
|
|
3301
|
+
break;
|
|
3302
|
+
}
|
|
3303
|
+
|
|
3304
|
+
throw Error('A user_id is required for unarchiving a channel');
|
|
3305
|
+
|
|
3306
|
+
case 5:
|
|
3307
|
+
_context26.next = 7;
|
|
3308
|
+
return this.partialUpdateMember(uid, {
|
|
3309
|
+
set: {
|
|
3310
|
+
archived: false
|
|
3311
|
+
}
|
|
3312
|
+
});
|
|
3313
|
+
|
|
3314
|
+
case 7:
|
|
3315
|
+
resp = _context26.sent;
|
|
3316
|
+
return _context26.abrupt("return", resp.channel_member);
|
|
3317
|
+
|
|
3318
|
+
case 9:
|
|
3319
|
+
case "end":
|
|
3320
|
+
return _context26.stop();
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
}, _callee26, this);
|
|
3324
|
+
}));
|
|
3325
|
+
|
|
3326
|
+
function unarchive() {
|
|
3327
|
+
return _unarchive.apply(this, arguments);
|
|
3328
|
+
}
|
|
3329
|
+
|
|
3330
|
+
return unarchive;
|
|
3331
|
+
}()
|
|
3332
|
+
/**
|
|
3333
|
+
* pin - pins the current channel
|
|
3334
|
+
* @param {{ user_id?: string }} opts user_id if called server side
|
|
3335
|
+
* @return {Promise<ChannelMemberResponse<StreamChatGenerics>>} The server response
|
|
3336
|
+
*
|
|
3337
|
+
* example:
|
|
3338
|
+
* await channel.pin();
|
|
3339
|
+
*
|
|
3340
|
+
* example server side:
|
|
3341
|
+
* await channel.pin({user_id: userId});
|
|
3342
|
+
*
|
|
3343
|
+
*/
|
|
3344
|
+
|
|
3345
|
+
}, {
|
|
3346
|
+
key: "pin",
|
|
3347
|
+
value: function () {
|
|
3348
|
+
var _pin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {
|
|
3349
|
+
var opts,
|
|
3350
|
+
cli,
|
|
3351
|
+
uid,
|
|
3352
|
+
resp,
|
|
3353
|
+
_args27 = arguments;
|
|
3354
|
+
return _regeneratorRuntime.wrap(function _callee27$(_context27) {
|
|
3355
|
+
while (1) {
|
|
3356
|
+
switch (_context27.prev = _context27.next) {
|
|
3357
|
+
case 0:
|
|
3358
|
+
opts = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : {};
|
|
3359
|
+
cli = this.getClient();
|
|
3360
|
+
uid = opts.user_id || cli.userID;
|
|
3361
|
+
|
|
3362
|
+
if (uid) {
|
|
3363
|
+
_context27.next = 5;
|
|
3364
|
+
break;
|
|
3365
|
+
}
|
|
3366
|
+
|
|
3367
|
+
throw Error('A user_id is required for pinning a channel');
|
|
3368
|
+
|
|
3369
|
+
case 5:
|
|
3370
|
+
_context27.next = 7;
|
|
3371
|
+
return this.partialUpdateMember(uid, {
|
|
3372
|
+
set: {
|
|
3373
|
+
pinned: true
|
|
3374
|
+
}
|
|
3375
|
+
});
|
|
3376
|
+
|
|
3377
|
+
case 7:
|
|
3378
|
+
resp = _context27.sent;
|
|
3379
|
+
return _context27.abrupt("return", resp.channel_member);
|
|
3380
|
+
|
|
3381
|
+
case 9:
|
|
3382
|
+
case "end":
|
|
3383
|
+
return _context27.stop();
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
}, _callee27, this);
|
|
3387
|
+
}));
|
|
3388
|
+
|
|
3389
|
+
function pin() {
|
|
3390
|
+
return _pin.apply(this, arguments);
|
|
3391
|
+
}
|
|
3392
|
+
|
|
3393
|
+
return pin;
|
|
3394
|
+
}()
|
|
3395
|
+
/**
|
|
3396
|
+
* unpin - unpins the current channel
|
|
3397
|
+
* @param {{ user_id?: string }} opts user_id if called server side
|
|
3398
|
+
* @return {Promise<ChannelMemberResponse<StreamChatGenerics>>} The server response
|
|
3399
|
+
*
|
|
3400
|
+
* example:
|
|
3401
|
+
* await channel.unpin();
|
|
3402
|
+
*
|
|
3403
|
+
* example server side:
|
|
3404
|
+
* await channel.unpin({user_id: userId});
|
|
3405
|
+
*
|
|
3406
|
+
*/
|
|
3407
|
+
|
|
3408
|
+
}, {
|
|
3409
|
+
key: "unpin",
|
|
3410
|
+
value: function () {
|
|
3411
|
+
var _unpin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
|
|
3412
|
+
var opts,
|
|
3413
|
+
cli,
|
|
3414
|
+
uid,
|
|
3415
|
+
resp,
|
|
3416
|
+
_args28 = arguments;
|
|
3417
|
+
return _regeneratorRuntime.wrap(function _callee28$(_context28) {
|
|
3418
|
+
while (1) {
|
|
3419
|
+
switch (_context28.prev = _context28.next) {
|
|
3420
|
+
case 0:
|
|
3421
|
+
opts = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {};
|
|
3422
|
+
cli = this.getClient();
|
|
3423
|
+
uid = opts.user_id || cli.userID;
|
|
3424
|
+
|
|
3425
|
+
if (uid) {
|
|
3426
|
+
_context28.next = 5;
|
|
3427
|
+
break;
|
|
3428
|
+
}
|
|
3429
|
+
|
|
3430
|
+
throw Error('A user_id is required for unpinning a channel');
|
|
3431
|
+
|
|
3432
|
+
case 5:
|
|
3433
|
+
_context28.next = 7;
|
|
3434
|
+
return this.partialUpdateMember(uid, {
|
|
3435
|
+
set: {
|
|
3436
|
+
pinned: false
|
|
3437
|
+
}
|
|
3438
|
+
});
|
|
3439
|
+
|
|
3440
|
+
case 7:
|
|
3441
|
+
resp = _context28.sent;
|
|
3442
|
+
return _context28.abrupt("return", resp.channel_member);
|
|
3443
|
+
|
|
3444
|
+
case 9:
|
|
3445
|
+
case "end":
|
|
3446
|
+
return _context28.stop();
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
}, _callee28, this);
|
|
3450
|
+
}));
|
|
3451
|
+
|
|
3452
|
+
function unpin() {
|
|
3453
|
+
return _unpin.apply(this, arguments);
|
|
3454
|
+
}
|
|
3455
|
+
|
|
3456
|
+
return unpin;
|
|
3457
|
+
}()
|
|
3112
3458
|
/**
|
|
3113
3459
|
* muteStatus - returns the mute status for the current channel
|
|
3114
3460
|
* @return {{ muted: boolean; createdAt: Date | null; expiresAt: Date | null }} { muted: true | false, createdAt: Date | null, expiresAt: Date | null}
|
|
@@ -3147,18 +3493,18 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3147
3493
|
}, {
|
|
3148
3494
|
key: "keystroke",
|
|
3149
3495
|
value: function () {
|
|
3150
|
-
var _keystroke = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
3496
|
+
var _keystroke = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(parent_id, options) {
|
|
3151
3497
|
var now, diff;
|
|
3152
|
-
return _regeneratorRuntime.wrap(function
|
|
3498
|
+
return _regeneratorRuntime.wrap(function _callee29$(_context29) {
|
|
3153
3499
|
while (1) {
|
|
3154
|
-
switch (
|
|
3500
|
+
switch (_context29.prev = _context29.next) {
|
|
3155
3501
|
case 0:
|
|
3156
3502
|
if (this._isTypingIndicatorsEnabled()) {
|
|
3157
|
-
|
|
3503
|
+
_context29.next = 2;
|
|
3158
3504
|
break;
|
|
3159
3505
|
}
|
|
3160
3506
|
|
|
3161
|
-
return
|
|
3507
|
+
return _context29.abrupt("return");
|
|
3162
3508
|
|
|
3163
3509
|
case 2:
|
|
3164
3510
|
now = new Date();
|
|
@@ -3167,23 +3513,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3167
3513
|
this.isTyping = true; // send a typing.start every 2 seconds
|
|
3168
3514
|
|
|
3169
3515
|
if (!(diff === null || diff > 2000)) {
|
|
3170
|
-
|
|
3516
|
+
_context29.next = 10;
|
|
3171
3517
|
break;
|
|
3172
3518
|
}
|
|
3173
3519
|
|
|
3174
3520
|
this.lastTypingEvent = new Date();
|
|
3175
|
-
|
|
3176
|
-
return this.sendEvent(_objectSpread$
|
|
3521
|
+
_context29.next = 10;
|
|
3522
|
+
return this.sendEvent(_objectSpread$a({
|
|
3177
3523
|
type: 'typing.start',
|
|
3178
3524
|
parent_id: parent_id
|
|
3179
3525
|
}, options || {}));
|
|
3180
3526
|
|
|
3181
3527
|
case 10:
|
|
3182
3528
|
case "end":
|
|
3183
|
-
return
|
|
3529
|
+
return _context29.stop();
|
|
3184
3530
|
}
|
|
3185
3531
|
}
|
|
3186
|
-
},
|
|
3532
|
+
}, _callee29, this);
|
|
3187
3533
|
}));
|
|
3188
3534
|
|
|
3189
3535
|
function keystroke(_x27, _x28) {
|
|
@@ -3201,33 +3547,33 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3201
3547
|
}, {
|
|
3202
3548
|
key: "stopTyping",
|
|
3203
3549
|
value: function () {
|
|
3204
|
-
var _stopTyping = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
3205
|
-
return _regeneratorRuntime.wrap(function
|
|
3550
|
+
var _stopTyping = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30(parent_id, options) {
|
|
3551
|
+
return _regeneratorRuntime.wrap(function _callee30$(_context30) {
|
|
3206
3552
|
while (1) {
|
|
3207
|
-
switch (
|
|
3553
|
+
switch (_context30.prev = _context30.next) {
|
|
3208
3554
|
case 0:
|
|
3209
3555
|
if (this._isTypingIndicatorsEnabled()) {
|
|
3210
|
-
|
|
3556
|
+
_context30.next = 2;
|
|
3211
3557
|
break;
|
|
3212
3558
|
}
|
|
3213
3559
|
|
|
3214
|
-
return
|
|
3560
|
+
return _context30.abrupt("return");
|
|
3215
3561
|
|
|
3216
3562
|
case 2:
|
|
3217
3563
|
this.lastTypingEvent = null;
|
|
3218
3564
|
this.isTyping = false;
|
|
3219
|
-
|
|
3220
|
-
return this.sendEvent(_objectSpread$
|
|
3565
|
+
_context30.next = 6;
|
|
3566
|
+
return this.sendEvent(_objectSpread$a({
|
|
3221
3567
|
type: 'typing.stop',
|
|
3222
3568
|
parent_id: parent_id
|
|
3223
3569
|
}, options || {}));
|
|
3224
3570
|
|
|
3225
3571
|
case 6:
|
|
3226
3572
|
case "end":
|
|
3227
|
-
return
|
|
3573
|
+
return _context30.stop();
|
|
3228
3574
|
}
|
|
3229
3575
|
}
|
|
3230
|
-
},
|
|
3576
|
+
}, _callee30, this);
|
|
3231
3577
|
}));
|
|
3232
3578
|
|
|
3233
3579
|
function stopTyping(_x29, _x30) {
|
|
@@ -3282,39 +3628,39 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3282
3628
|
}, {
|
|
3283
3629
|
key: "markRead",
|
|
3284
3630
|
value: function () {
|
|
3285
|
-
var _markRead = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
3631
|
+
var _markRead = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
|
|
3286
3632
|
var _this$getConfig2;
|
|
3287
3633
|
|
|
3288
3634
|
var data,
|
|
3289
|
-
|
|
3290
|
-
return _regeneratorRuntime.wrap(function
|
|
3635
|
+
_args31 = arguments;
|
|
3636
|
+
return _regeneratorRuntime.wrap(function _callee31$(_context31) {
|
|
3291
3637
|
while (1) {
|
|
3292
|
-
switch (
|
|
3638
|
+
switch (_context31.prev = _context31.next) {
|
|
3293
3639
|
case 0:
|
|
3294
|
-
data =
|
|
3640
|
+
data = _args31.length > 0 && _args31[0] !== undefined ? _args31[0] : {};
|
|
3295
3641
|
|
|
3296
3642
|
this._checkInitialized();
|
|
3297
3643
|
|
|
3298
3644
|
if (!(!((_this$getConfig2 = this.getConfig()) !== null && _this$getConfig2 !== void 0 && _this$getConfig2.read_events) && !this.getClient()._isUsingServerAuth())) {
|
|
3299
|
-
|
|
3645
|
+
_context31.next = 4;
|
|
3300
3646
|
break;
|
|
3301
3647
|
}
|
|
3302
3648
|
|
|
3303
|
-
return
|
|
3649
|
+
return _context31.abrupt("return", Promise.resolve(null));
|
|
3304
3650
|
|
|
3305
3651
|
case 4:
|
|
3306
|
-
|
|
3307
|
-
return this.getClient().post(this._channelURL() + '/read', _objectSpread$
|
|
3652
|
+
_context31.next = 6;
|
|
3653
|
+
return this.getClient().post(this._channelURL() + '/read', _objectSpread$a({}, data));
|
|
3308
3654
|
|
|
3309
3655
|
case 6:
|
|
3310
|
-
return
|
|
3656
|
+
return _context31.abrupt("return", _context31.sent);
|
|
3311
3657
|
|
|
3312
3658
|
case 7:
|
|
3313
3659
|
case "end":
|
|
3314
|
-
return
|
|
3660
|
+
return _context31.stop();
|
|
3315
3661
|
}
|
|
3316
3662
|
}
|
|
3317
|
-
},
|
|
3663
|
+
}, _callee31, this);
|
|
3318
3664
|
}));
|
|
3319
3665
|
|
|
3320
3666
|
function markRead() {
|
|
@@ -3333,35 +3679,35 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3333
3679
|
}, {
|
|
3334
3680
|
key: "markUnread",
|
|
3335
3681
|
value: function () {
|
|
3336
|
-
var _markUnread = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
3682
|
+
var _markUnread = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32(data) {
|
|
3337
3683
|
var _this$getConfig3;
|
|
3338
3684
|
|
|
3339
|
-
return _regeneratorRuntime.wrap(function
|
|
3685
|
+
return _regeneratorRuntime.wrap(function _callee32$(_context32) {
|
|
3340
3686
|
while (1) {
|
|
3341
|
-
switch (
|
|
3687
|
+
switch (_context32.prev = _context32.next) {
|
|
3342
3688
|
case 0:
|
|
3343
3689
|
this._checkInitialized();
|
|
3344
3690
|
|
|
3345
3691
|
if (!(!((_this$getConfig3 = this.getConfig()) !== null && _this$getConfig3 !== void 0 && _this$getConfig3.read_events) && !this.getClient()._isUsingServerAuth())) {
|
|
3346
|
-
|
|
3692
|
+
_context32.next = 3;
|
|
3347
3693
|
break;
|
|
3348
3694
|
}
|
|
3349
3695
|
|
|
3350
|
-
return
|
|
3696
|
+
return _context32.abrupt("return", Promise.resolve(null));
|
|
3351
3697
|
|
|
3352
3698
|
case 3:
|
|
3353
|
-
|
|
3354
|
-
return this.getClient().post(this._channelURL() + '/unread', _objectSpread$
|
|
3699
|
+
_context32.next = 5;
|
|
3700
|
+
return this.getClient().post(this._channelURL() + '/unread', _objectSpread$a({}, data));
|
|
3355
3701
|
|
|
3356
3702
|
case 5:
|
|
3357
|
-
return
|
|
3703
|
+
return _context32.abrupt("return", _context32.sent);
|
|
3358
3704
|
|
|
3359
3705
|
case 6:
|
|
3360
3706
|
case "end":
|
|
3361
|
-
return
|
|
3707
|
+
return _context32.stop();
|
|
3362
3708
|
}
|
|
3363
3709
|
}
|
|
3364
|
-
},
|
|
3710
|
+
}, _callee32, this);
|
|
3365
3711
|
}));
|
|
3366
3712
|
|
|
3367
3713
|
function markUnread(_x31) {
|
|
@@ -3399,11 +3745,11 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3399
3745
|
}, {
|
|
3400
3746
|
key: "watch",
|
|
3401
3747
|
value: function () {
|
|
3402
|
-
var _watch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
3748
|
+
var _watch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33(options) {
|
|
3403
3749
|
var defaultOptions, combined, state;
|
|
3404
|
-
return _regeneratorRuntime.wrap(function
|
|
3750
|
+
return _regeneratorRuntime.wrap(function _callee33$(_context33) {
|
|
3405
3751
|
while (1) {
|
|
3406
|
-
switch (
|
|
3752
|
+
switch (_context33.prev = _context33.next) {
|
|
3407
3753
|
case 0:
|
|
3408
3754
|
defaultOptions = {
|
|
3409
3755
|
state: true,
|
|
@@ -3411,7 +3757,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3411
3757
|
presence: false
|
|
3412
3758
|
}; // Make sure we wait for the connect promise if there is a pending one
|
|
3413
3759
|
|
|
3414
|
-
|
|
3760
|
+
_context33.next = 3;
|
|
3415
3761
|
return this.getClient().wsPromise;
|
|
3416
3762
|
|
|
3417
3763
|
case 3:
|
|
@@ -3419,12 +3765,12 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3419
3765
|
defaultOptions.watch = false;
|
|
3420
3766
|
}
|
|
3421
3767
|
|
|
3422
|
-
combined = _objectSpread$
|
|
3423
|
-
|
|
3768
|
+
combined = _objectSpread$a(_objectSpread$a({}, defaultOptions), options);
|
|
3769
|
+
_context33.next = 7;
|
|
3424
3770
|
return this.query(combined, 'latest');
|
|
3425
3771
|
|
|
3426
3772
|
case 7:
|
|
3427
|
-
state =
|
|
3773
|
+
state = _context33.sent;
|
|
3428
3774
|
this.initialized = true;
|
|
3429
3775
|
this.data = state.channel;
|
|
3430
3776
|
|
|
@@ -3433,14 +3779,14 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3433
3779
|
channel: this
|
|
3434
3780
|
});
|
|
3435
3781
|
|
|
3436
|
-
return
|
|
3782
|
+
return _context33.abrupt("return", state);
|
|
3437
3783
|
|
|
3438
3784
|
case 12:
|
|
3439
3785
|
case "end":
|
|
3440
|
-
return
|
|
3786
|
+
return _context33.stop();
|
|
3441
3787
|
}
|
|
3442
3788
|
}
|
|
3443
|
-
},
|
|
3789
|
+
}, _callee33, this);
|
|
3444
3790
|
}));
|
|
3445
3791
|
|
|
3446
3792
|
function watch(_x32) {
|
|
@@ -3458,31 +3804,31 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3458
3804
|
}, {
|
|
3459
3805
|
key: "stopWatching",
|
|
3460
3806
|
value: function () {
|
|
3461
|
-
var _stopWatching = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
3807
|
+
var _stopWatching = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34() {
|
|
3462
3808
|
var response;
|
|
3463
|
-
return _regeneratorRuntime.wrap(function
|
|
3809
|
+
return _regeneratorRuntime.wrap(function _callee34$(_context34) {
|
|
3464
3810
|
while (1) {
|
|
3465
|
-
switch (
|
|
3811
|
+
switch (_context34.prev = _context34.next) {
|
|
3466
3812
|
case 0:
|
|
3467
|
-
|
|
3813
|
+
_context34.next = 2;
|
|
3468
3814
|
return this.getClient().post(this._channelURL() + '/stop-watching', {});
|
|
3469
3815
|
|
|
3470
3816
|
case 2:
|
|
3471
|
-
response =
|
|
3817
|
+
response = _context34.sent;
|
|
3472
3818
|
|
|
3473
3819
|
this._client.logger('info', "channel:watch() - stopped watching channel ".concat(this.cid), {
|
|
3474
3820
|
tags: ['channel'],
|
|
3475
3821
|
channel: this
|
|
3476
3822
|
});
|
|
3477
3823
|
|
|
3478
|
-
return
|
|
3824
|
+
return _context34.abrupt("return", response);
|
|
3479
3825
|
|
|
3480
3826
|
case 5:
|
|
3481
3827
|
case "end":
|
|
3482
|
-
return
|
|
3828
|
+
return _context34.stop();
|
|
3483
3829
|
}
|
|
3484
3830
|
}
|
|
3485
|
-
},
|
|
3831
|
+
}, _callee34, this);
|
|
3486
3832
|
}));
|
|
3487
3833
|
|
|
3488
3834
|
function stopWatching() {
|
|
@@ -3505,34 +3851,34 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3505
3851
|
}, {
|
|
3506
3852
|
key: "getReplies",
|
|
3507
3853
|
value: function () {
|
|
3508
|
-
var _getReplies = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
3854
|
+
var _getReplies = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee35(parent_id, options, sort) {
|
|
3509
3855
|
var normalizedSort, data;
|
|
3510
|
-
return _regeneratorRuntime.wrap(function
|
|
3856
|
+
return _regeneratorRuntime.wrap(function _callee35$(_context35) {
|
|
3511
3857
|
while (1) {
|
|
3512
|
-
switch (
|
|
3858
|
+
switch (_context35.prev = _context35.next) {
|
|
3513
3859
|
case 0:
|
|
3514
3860
|
normalizedSort = sort ? normalizeQuerySort(sort) : undefined;
|
|
3515
|
-
|
|
3516
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(parent_id), "/replies"), _objectSpread$
|
|
3861
|
+
_context35.next = 3;
|
|
3862
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(parent_id), "/replies"), _objectSpread$a({
|
|
3517
3863
|
sort: normalizedSort
|
|
3518
3864
|
}, options));
|
|
3519
3865
|
|
|
3520
3866
|
case 3:
|
|
3521
|
-
data =
|
|
3867
|
+
data = _context35.sent;
|
|
3522
3868
|
|
|
3523
3869
|
// add any messages to our thread state
|
|
3524
3870
|
if (data.messages) {
|
|
3525
3871
|
this.state.addMessagesSorted(data.messages);
|
|
3526
3872
|
}
|
|
3527
3873
|
|
|
3528
|
-
return
|
|
3874
|
+
return _context35.abrupt("return", data);
|
|
3529
3875
|
|
|
3530
3876
|
case 6:
|
|
3531
3877
|
case "end":
|
|
3532
|
-
return
|
|
3878
|
+
return _context35.stop();
|
|
3533
3879
|
}
|
|
3534
3880
|
}
|
|
3535
|
-
},
|
|
3881
|
+
}, _callee35, this);
|
|
3536
3882
|
}));
|
|
3537
3883
|
|
|
3538
3884
|
function getReplies(_x33, _x34, _x35) {
|
|
@@ -3553,30 +3899,30 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3553
3899
|
}, {
|
|
3554
3900
|
key: "getPinnedMessages",
|
|
3555
3901
|
value: function () {
|
|
3556
|
-
var _getPinnedMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
3902
|
+
var _getPinnedMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee36(options) {
|
|
3557
3903
|
var sort,
|
|
3558
|
-
|
|
3559
|
-
return _regeneratorRuntime.wrap(function
|
|
3904
|
+
_args36 = arguments;
|
|
3905
|
+
return _regeneratorRuntime.wrap(function _callee36$(_context36) {
|
|
3560
3906
|
while (1) {
|
|
3561
|
-
switch (
|
|
3907
|
+
switch (_context36.prev = _context36.next) {
|
|
3562
3908
|
case 0:
|
|
3563
|
-
sort =
|
|
3564
|
-
|
|
3909
|
+
sort = _args36.length > 1 && _args36[1] !== undefined ? _args36[1] : [];
|
|
3910
|
+
_context36.next = 3;
|
|
3565
3911
|
return this.getClient().get(this._channelURL() + '/pinned_messages', {
|
|
3566
|
-
payload: _objectSpread$
|
|
3912
|
+
payload: _objectSpread$a(_objectSpread$a({}, options), {}, {
|
|
3567
3913
|
sort: normalizeQuerySort(sort)
|
|
3568
3914
|
})
|
|
3569
3915
|
});
|
|
3570
3916
|
|
|
3571
3917
|
case 3:
|
|
3572
|
-
return
|
|
3918
|
+
return _context36.abrupt("return", _context36.sent);
|
|
3573
3919
|
|
|
3574
3920
|
case 4:
|
|
3575
3921
|
case "end":
|
|
3576
|
-
return
|
|
3922
|
+
return _context36.stop();
|
|
3577
3923
|
}
|
|
3578
3924
|
}
|
|
3579
|
-
},
|
|
3925
|
+
}, _callee36, this);
|
|
3580
3926
|
}));
|
|
3581
3927
|
|
|
3582
3928
|
function getPinnedMessages(_x36) {
|
|
@@ -3597,7 +3943,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3597
3943
|
}, {
|
|
3598
3944
|
key: "getReactions",
|
|
3599
3945
|
value: function getReactions(message_id, options) {
|
|
3600
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(message_id), "/reactions"), _objectSpread$
|
|
3946
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(message_id), "/reactions"), _objectSpread$a({}, options));
|
|
3601
3947
|
}
|
|
3602
3948
|
/**
|
|
3603
3949
|
* getMessagesById - Retrieves a list of messages by ID
|
|
@@ -3715,7 +4061,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3715
4061
|
* @return {Promise<QueryChannelAPIResponse<StreamChatGenerics>>} Returns a query response
|
|
3716
4062
|
*/
|
|
3717
4063
|
function () {
|
|
3718
|
-
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
4064
|
+
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee37(options) {
|
|
3719
4065
|
var _options$messages$lim, _options$messages, _this$data6, _this$data7;
|
|
3720
4066
|
|
|
3721
4067
|
var messageSetToAddToIfDoesNotExist,
|
|
@@ -3726,14 +4072,14 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3726
4072
|
_this$_initializeStat,
|
|
3727
4073
|
messageSet,
|
|
3728
4074
|
areCapabilitiesChanged,
|
|
3729
|
-
|
|
4075
|
+
_args37 = arguments;
|
|
3730
4076
|
|
|
3731
|
-
return _regeneratorRuntime.wrap(function
|
|
4077
|
+
return _regeneratorRuntime.wrap(function _callee37$(_context37) {
|
|
3732
4078
|
while (1) {
|
|
3733
|
-
switch (
|
|
4079
|
+
switch (_context37.prev = _context37.next) {
|
|
3734
4080
|
case 0:
|
|
3735
|
-
messageSetToAddToIfDoesNotExist =
|
|
3736
|
-
|
|
4081
|
+
messageSetToAddToIfDoesNotExist = _args37.length > 1 && _args37[1] !== undefined ? _args37[1] : 'current';
|
|
4082
|
+
_context37.next = 3;
|
|
3737
4083
|
return this.getClient().wsPromise;
|
|
3738
4084
|
|
|
3739
4085
|
case 3:
|
|
@@ -3743,14 +4089,14 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3743
4089
|
queryURL += "/".concat(encodeURIComponent(this.id));
|
|
3744
4090
|
}
|
|
3745
4091
|
|
|
3746
|
-
|
|
3747
|
-
return this.getClient().post(queryURL + '/query', _objectSpread$
|
|
4092
|
+
_context37.next = 7;
|
|
4093
|
+
return this.getClient().post(queryURL + '/query', _objectSpread$a({
|
|
3748
4094
|
data: this._data,
|
|
3749
4095
|
state: true
|
|
3750
4096
|
}, options));
|
|
3751
4097
|
|
|
3752
4098
|
case 7:
|
|
3753
|
-
state =
|
|
4099
|
+
state = _context37.sent;
|
|
3754
4100
|
|
|
3755
4101
|
// update the channel id if it was missing
|
|
3756
4102
|
if (!this.id) {
|
|
@@ -3779,13 +4125,14 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3779
4125
|
|
|
3780
4126
|
|
|
3781
4127
|
_this$_initializeStat = this._initializeState(state, messageSetToAddToIfDoesNotExist), messageSet = _this$_initializeStat.messageSet;
|
|
3782
|
-
messageSet.pagination = _objectSpread$
|
|
4128
|
+
messageSet.pagination = _objectSpread$a(_objectSpread$a({}, messageSet.pagination), messageSetPagination({
|
|
3783
4129
|
parentSet: messageSet,
|
|
3784
4130
|
messagePaginationOptions: options === null || options === void 0 ? void 0 : options.messages,
|
|
3785
4131
|
requestedPageSize: (_options$messages$lim = options === null || options === void 0 ? void 0 : (_options$messages = options.messages) === null || _options$messages === void 0 ? void 0 : _options$messages.limit) !== null && _options$messages$lim !== void 0 ? _options$messages$lim : DEFAULT_QUERY_CHANNEL_MESSAGE_LIST_PAGE_SIZE,
|
|
3786
4132
|
returnedPage: state.messages,
|
|
3787
4133
|
logger: this.getClient().logger
|
|
3788
4134
|
}));
|
|
4135
|
+
this.getClient().polls.hydratePollCache(messageSet.messages, true);
|
|
3789
4136
|
areCapabilitiesChanged = _toConsumableArray(state.channel.own_capabilities || []).sort().join() !== _toConsumableArray(Array.isArray((_this$data6 = this.data) === null || _this$data6 === void 0 ? void 0 : _this$data6.own_capabilities) ? (_this$data7 = this.data) === null || _this$data7 === void 0 ? void 0 : _this$data7.own_capabilities : []).sort().join();
|
|
3790
4137
|
this.data = state.channel;
|
|
3791
4138
|
this.offlineMode = false;
|
|
@@ -3805,14 +4152,14 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3805
4152
|
isLatestMessageSet: messageSet.isLatest
|
|
3806
4153
|
}
|
|
3807
4154
|
});
|
|
3808
|
-
return
|
|
4155
|
+
return _context37.abrupt("return", state);
|
|
3809
4156
|
|
|
3810
|
-
case
|
|
4157
|
+
case 19:
|
|
3811
4158
|
case "end":
|
|
3812
|
-
return
|
|
4159
|
+
return _context37.stop();
|
|
3813
4160
|
}
|
|
3814
4161
|
}
|
|
3815
|
-
},
|
|
4162
|
+
}, _callee37, this);
|
|
3816
4163
|
}));
|
|
3817
4164
|
|
|
3818
4165
|
function query(_x37) {
|
|
@@ -3832,28 +4179,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3832
4179
|
}, {
|
|
3833
4180
|
key: "banUser",
|
|
3834
4181
|
value: function () {
|
|
3835
|
-
var _banUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
3836
|
-
return _regeneratorRuntime.wrap(function
|
|
4182
|
+
var _banUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee38(targetUserID, options) {
|
|
4183
|
+
return _regeneratorRuntime.wrap(function _callee38$(_context38) {
|
|
3837
4184
|
while (1) {
|
|
3838
|
-
switch (
|
|
4185
|
+
switch (_context38.prev = _context38.next) {
|
|
3839
4186
|
case 0:
|
|
3840
4187
|
this._checkInitialized();
|
|
3841
4188
|
|
|
3842
|
-
|
|
3843
|
-
return this.getClient().banUser(targetUserID, _objectSpread$
|
|
4189
|
+
_context38.next = 3;
|
|
4190
|
+
return this.getClient().banUser(targetUserID, _objectSpread$a(_objectSpread$a({}, options), {}, {
|
|
3844
4191
|
type: this.type,
|
|
3845
4192
|
id: this.id
|
|
3846
4193
|
}));
|
|
3847
4194
|
|
|
3848
4195
|
case 3:
|
|
3849
|
-
return
|
|
4196
|
+
return _context38.abrupt("return", _context38.sent);
|
|
3850
4197
|
|
|
3851
4198
|
case 4:
|
|
3852
4199
|
case "end":
|
|
3853
|
-
return
|
|
4200
|
+
return _context38.stop();
|
|
3854
4201
|
}
|
|
3855
4202
|
}
|
|
3856
|
-
},
|
|
4203
|
+
}, _callee38, this);
|
|
3857
4204
|
}));
|
|
3858
4205
|
|
|
3859
4206
|
function banUser(_x38, _x39) {
|
|
@@ -3874,34 +4221,34 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3874
4221
|
}, {
|
|
3875
4222
|
key: "hide",
|
|
3876
4223
|
value: function () {
|
|
3877
|
-
var _hide = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
4224
|
+
var _hide = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee39() {
|
|
3878
4225
|
var userId,
|
|
3879
4226
|
clearHistory,
|
|
3880
|
-
|
|
3881
|
-
return _regeneratorRuntime.wrap(function
|
|
4227
|
+
_args39 = arguments;
|
|
4228
|
+
return _regeneratorRuntime.wrap(function _callee39$(_context39) {
|
|
3882
4229
|
while (1) {
|
|
3883
|
-
switch (
|
|
4230
|
+
switch (_context39.prev = _context39.next) {
|
|
3884
4231
|
case 0:
|
|
3885
|
-
userId =
|
|
3886
|
-
clearHistory =
|
|
4232
|
+
userId = _args39.length > 0 && _args39[0] !== undefined ? _args39[0] : null;
|
|
4233
|
+
clearHistory = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : false;
|
|
3887
4234
|
|
|
3888
4235
|
this._checkInitialized();
|
|
3889
4236
|
|
|
3890
|
-
|
|
4237
|
+
_context39.next = 5;
|
|
3891
4238
|
return this.getClient().post("".concat(this._channelURL(), "/hide"), {
|
|
3892
4239
|
user_id: userId,
|
|
3893
4240
|
clear_history: clearHistory
|
|
3894
4241
|
});
|
|
3895
4242
|
|
|
3896
4243
|
case 5:
|
|
3897
|
-
return
|
|
4244
|
+
return _context39.abrupt("return", _context39.sent);
|
|
3898
4245
|
|
|
3899
4246
|
case 6:
|
|
3900
4247
|
case "end":
|
|
3901
|
-
return
|
|
4248
|
+
return _context39.stop();
|
|
3902
4249
|
}
|
|
3903
4250
|
}
|
|
3904
|
-
},
|
|
4251
|
+
}, _callee39, this);
|
|
3905
4252
|
}));
|
|
3906
4253
|
|
|
3907
4254
|
function hide() {
|
|
@@ -3920,31 +4267,31 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3920
4267
|
}, {
|
|
3921
4268
|
key: "show",
|
|
3922
4269
|
value: function () {
|
|
3923
|
-
var _show = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
4270
|
+
var _show = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee40() {
|
|
3924
4271
|
var userId,
|
|
3925
|
-
|
|
3926
|
-
return _regeneratorRuntime.wrap(function
|
|
4272
|
+
_args40 = arguments;
|
|
4273
|
+
return _regeneratorRuntime.wrap(function _callee40$(_context40) {
|
|
3927
4274
|
while (1) {
|
|
3928
|
-
switch (
|
|
4275
|
+
switch (_context40.prev = _context40.next) {
|
|
3929
4276
|
case 0:
|
|
3930
|
-
userId =
|
|
4277
|
+
userId = _args40.length > 0 && _args40[0] !== undefined ? _args40[0] : null;
|
|
3931
4278
|
|
|
3932
4279
|
this._checkInitialized();
|
|
3933
4280
|
|
|
3934
|
-
|
|
4281
|
+
_context40.next = 4;
|
|
3935
4282
|
return this.getClient().post("".concat(this._channelURL(), "/show"), {
|
|
3936
4283
|
user_id: userId
|
|
3937
4284
|
});
|
|
3938
4285
|
|
|
3939
4286
|
case 4:
|
|
3940
|
-
return
|
|
4287
|
+
return _context40.abrupt("return", _context40.sent);
|
|
3941
4288
|
|
|
3942
4289
|
case 5:
|
|
3943
4290
|
case "end":
|
|
3944
|
-
return
|
|
4291
|
+
return _context40.stop();
|
|
3945
4292
|
}
|
|
3946
4293
|
}
|
|
3947
|
-
},
|
|
4294
|
+
}, _callee40, this);
|
|
3948
4295
|
}));
|
|
3949
4296
|
|
|
3950
4297
|
function show() {
|
|
@@ -3963,28 +4310,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3963
4310
|
}, {
|
|
3964
4311
|
key: "unbanUser",
|
|
3965
4312
|
value: function () {
|
|
3966
|
-
var _unbanUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
3967
|
-
return _regeneratorRuntime.wrap(function
|
|
4313
|
+
var _unbanUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee41(targetUserID) {
|
|
4314
|
+
return _regeneratorRuntime.wrap(function _callee41$(_context41) {
|
|
3968
4315
|
while (1) {
|
|
3969
|
-
switch (
|
|
4316
|
+
switch (_context41.prev = _context41.next) {
|
|
3970
4317
|
case 0:
|
|
3971
4318
|
this._checkInitialized();
|
|
3972
4319
|
|
|
3973
|
-
|
|
4320
|
+
_context41.next = 3;
|
|
3974
4321
|
return this.getClient().unbanUser(targetUserID, {
|
|
3975
4322
|
type: this.type,
|
|
3976
4323
|
id: this.id
|
|
3977
4324
|
});
|
|
3978
4325
|
|
|
3979
4326
|
case 3:
|
|
3980
|
-
return
|
|
4327
|
+
return _context41.abrupt("return", _context41.sent);
|
|
3981
4328
|
|
|
3982
4329
|
case 4:
|
|
3983
4330
|
case "end":
|
|
3984
|
-
return
|
|
4331
|
+
return _context41.stop();
|
|
3985
4332
|
}
|
|
3986
4333
|
}
|
|
3987
|
-
},
|
|
4334
|
+
}, _callee41, this);
|
|
3988
4335
|
}));
|
|
3989
4336
|
|
|
3990
4337
|
function unbanUser(_x40) {
|
|
@@ -4004,28 +4351,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4004
4351
|
}, {
|
|
4005
4352
|
key: "shadowBan",
|
|
4006
4353
|
value: function () {
|
|
4007
|
-
var _shadowBan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
4008
|
-
return _regeneratorRuntime.wrap(function
|
|
4354
|
+
var _shadowBan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee42(targetUserID, options) {
|
|
4355
|
+
return _regeneratorRuntime.wrap(function _callee42$(_context42) {
|
|
4009
4356
|
while (1) {
|
|
4010
|
-
switch (
|
|
4357
|
+
switch (_context42.prev = _context42.next) {
|
|
4011
4358
|
case 0:
|
|
4012
4359
|
this._checkInitialized();
|
|
4013
4360
|
|
|
4014
|
-
|
|
4015
|
-
return this.getClient().shadowBan(targetUserID, _objectSpread$
|
|
4361
|
+
_context42.next = 3;
|
|
4362
|
+
return this.getClient().shadowBan(targetUserID, _objectSpread$a(_objectSpread$a({}, options), {}, {
|
|
4016
4363
|
type: this.type,
|
|
4017
4364
|
id: this.id
|
|
4018
4365
|
}));
|
|
4019
4366
|
|
|
4020
4367
|
case 3:
|
|
4021
|
-
return
|
|
4368
|
+
return _context42.abrupt("return", _context42.sent);
|
|
4022
4369
|
|
|
4023
4370
|
case 4:
|
|
4024
4371
|
case "end":
|
|
4025
|
-
return
|
|
4372
|
+
return _context42.stop();
|
|
4026
4373
|
}
|
|
4027
4374
|
}
|
|
4028
|
-
},
|
|
4375
|
+
}, _callee42, this);
|
|
4029
4376
|
}));
|
|
4030
4377
|
|
|
4031
4378
|
function shadowBan(_x41, _x42) {
|
|
@@ -4044,28 +4391,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4044
4391
|
}, {
|
|
4045
4392
|
key: "removeShadowBan",
|
|
4046
4393
|
value: function () {
|
|
4047
|
-
var _removeShadowBan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
4048
|
-
return _regeneratorRuntime.wrap(function
|
|
4394
|
+
var _removeShadowBan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee43(targetUserID) {
|
|
4395
|
+
return _regeneratorRuntime.wrap(function _callee43$(_context43) {
|
|
4049
4396
|
while (1) {
|
|
4050
|
-
switch (
|
|
4397
|
+
switch (_context43.prev = _context43.next) {
|
|
4051
4398
|
case 0:
|
|
4052
4399
|
this._checkInitialized();
|
|
4053
4400
|
|
|
4054
|
-
|
|
4401
|
+
_context43.next = 3;
|
|
4055
4402
|
return this.getClient().removeShadowBan(targetUserID, {
|
|
4056
4403
|
type: this.type,
|
|
4057
4404
|
id: this.id
|
|
4058
4405
|
});
|
|
4059
4406
|
|
|
4060
4407
|
case 3:
|
|
4061
|
-
return
|
|
4408
|
+
return _context43.abrupt("return", _context43.sent);
|
|
4062
4409
|
|
|
4063
4410
|
case 4:
|
|
4064
4411
|
case "end":
|
|
4065
|
-
return
|
|
4412
|
+
return _context43.stop();
|
|
4066
4413
|
}
|
|
4067
4414
|
}
|
|
4068
|
-
},
|
|
4415
|
+
}, _callee43, this);
|
|
4069
4416
|
}));
|
|
4070
4417
|
|
|
4071
4418
|
function removeShadowBan(_x43) {
|
|
@@ -4084,23 +4431,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4084
4431
|
}, {
|
|
4085
4432
|
key: "createCall",
|
|
4086
4433
|
value: function () {
|
|
4087
|
-
var _createCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
4088
|
-
return _regeneratorRuntime.wrap(function
|
|
4434
|
+
var _createCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee44(options) {
|
|
4435
|
+
return _regeneratorRuntime.wrap(function _callee44$(_context44) {
|
|
4089
4436
|
while (1) {
|
|
4090
|
-
switch (
|
|
4437
|
+
switch (_context44.prev = _context44.next) {
|
|
4091
4438
|
case 0:
|
|
4092
|
-
|
|
4439
|
+
_context44.next = 2;
|
|
4093
4440
|
return this.getClient().post(this._channelURL() + '/call', options);
|
|
4094
4441
|
|
|
4095
4442
|
case 2:
|
|
4096
|
-
return
|
|
4443
|
+
return _context44.abrupt("return", _context44.sent);
|
|
4097
4444
|
|
|
4098
4445
|
case 3:
|
|
4099
4446
|
case "end":
|
|
4100
|
-
return
|
|
4447
|
+
return _context44.stop();
|
|
4101
4448
|
}
|
|
4102
4449
|
}
|
|
4103
|
-
},
|
|
4450
|
+
}, _callee44, this);
|
|
4104
4451
|
}));
|
|
4105
4452
|
|
|
4106
4453
|
function createCall(_x44) {
|
|
@@ -4119,23 +4466,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4119
4466
|
}, {
|
|
4120
4467
|
key: "vote",
|
|
4121
4468
|
value: function () {
|
|
4122
|
-
var _vote2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
4123
|
-
return _regeneratorRuntime.wrap(function
|
|
4469
|
+
var _vote2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee45(messageId, pollId, _vote) {
|
|
4470
|
+
return _regeneratorRuntime.wrap(function _callee45$(_context45) {
|
|
4124
4471
|
while (1) {
|
|
4125
|
-
switch (
|
|
4472
|
+
switch (_context45.prev = _context45.next) {
|
|
4126
4473
|
case 0:
|
|
4127
|
-
|
|
4474
|
+
_context45.next = 2;
|
|
4128
4475
|
return this.getClient().castPollVote(messageId, pollId, _vote);
|
|
4129
4476
|
|
|
4130
4477
|
case 2:
|
|
4131
|
-
return
|
|
4478
|
+
return _context45.abrupt("return", _context45.sent);
|
|
4132
4479
|
|
|
4133
4480
|
case 3:
|
|
4134
4481
|
case "end":
|
|
4135
|
-
return
|
|
4482
|
+
return _context45.stop();
|
|
4136
4483
|
}
|
|
4137
4484
|
}
|
|
4138
|
-
},
|
|
4485
|
+
}, _callee45, this);
|
|
4139
4486
|
}));
|
|
4140
4487
|
|
|
4141
4488
|
function vote(_x45, _x46, _x47) {
|
|
@@ -4147,23 +4494,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4147
4494
|
}, {
|
|
4148
4495
|
key: "removeVote",
|
|
4149
4496
|
value: function () {
|
|
4150
|
-
var _removeVote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
4151
|
-
return _regeneratorRuntime.wrap(function
|
|
4497
|
+
var _removeVote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee46(messageId, pollId, voteId) {
|
|
4498
|
+
return _regeneratorRuntime.wrap(function _callee46$(_context46) {
|
|
4152
4499
|
while (1) {
|
|
4153
|
-
switch (
|
|
4500
|
+
switch (_context46.prev = _context46.next) {
|
|
4154
4501
|
case 0:
|
|
4155
|
-
|
|
4502
|
+
_context46.next = 2;
|
|
4156
4503
|
return this.getClient().removePollVote(messageId, pollId, voteId);
|
|
4157
4504
|
|
|
4158
4505
|
case 2:
|
|
4159
|
-
return
|
|
4506
|
+
return _context46.abrupt("return", _context46.sent);
|
|
4160
4507
|
|
|
4161
4508
|
case 3:
|
|
4162
4509
|
case "end":
|
|
4163
|
-
return
|
|
4510
|
+
return _context46.stop();
|
|
4164
4511
|
}
|
|
4165
4512
|
}
|
|
4166
|
-
},
|
|
4513
|
+
}, _callee46, this);
|
|
4167
4514
|
}));
|
|
4168
4515
|
|
|
4169
4516
|
function removeVote(_x48, _x49, _x50) {
|
|
@@ -4466,7 +4813,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4466
4813
|
});
|
|
4467
4814
|
}
|
|
4468
4815
|
|
|
4469
|
-
channel.data = _objectSpread$
|
|
4816
|
+
channel.data = _objectSpread$a(_objectSpread$a({}, event.channel), {}, {
|
|
4470
4817
|
hidden: (_event$channel$hidden = (_event$channel3 = event.channel) === null || _event$channel3 === void 0 ? void 0 : _event$channel3.hidden) !== null && _event$channel$hidden !== void 0 ? _event$channel$hidden : (_channel$data2 = channel.data) === null || _channel$data2 === void 0 ? void 0 : _channel$data2.hidden,
|
|
4471
4818
|
own_capabilities: (_event$channel$own_ca = (_event$channel4 = event.channel) === null || _event$channel4 === void 0 ? void 0 : _event$channel4.own_capabilities) !== null && _event$channel$own_ca !== void 0 ? _event$channel$own_ca : (_channel$data3 = channel.data) === null || _channel$data3 === void 0 ? void 0 : _channel$data3.own_capabilities
|
|
4472
4819
|
});
|
|
@@ -4474,49 +4821,6 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4474
4821
|
|
|
4475
4822
|
break;
|
|
4476
4823
|
|
|
4477
|
-
case 'poll.updated':
|
|
4478
|
-
if (event.poll) {
|
|
4479
|
-
var _event$message;
|
|
4480
|
-
|
|
4481
|
-
channelState.updatePoll(event.poll, ((_event$message = event.message) === null || _event$message === void 0 ? void 0 : _event$message.id) || '');
|
|
4482
|
-
}
|
|
4483
|
-
|
|
4484
|
-
break;
|
|
4485
|
-
|
|
4486
|
-
case 'poll.vote_casted':
|
|
4487
|
-
if (event.poll_vote && event.poll) {
|
|
4488
|
-
var _event$message2;
|
|
4489
|
-
|
|
4490
|
-
channelState.addPollVote(event.poll_vote, event.poll, ((_event$message2 = event.message) === null || _event$message2 === void 0 ? void 0 : _event$message2.id) || '');
|
|
4491
|
-
}
|
|
4492
|
-
|
|
4493
|
-
break;
|
|
4494
|
-
|
|
4495
|
-
case 'poll.vote_changed':
|
|
4496
|
-
if (event.poll_vote && event.poll) {
|
|
4497
|
-
var _event$message3;
|
|
4498
|
-
|
|
4499
|
-
channelState.updatePollVote(event.poll_vote, event.poll, ((_event$message3 = event.message) === null || _event$message3 === void 0 ? void 0 : _event$message3.id) || '');
|
|
4500
|
-
}
|
|
4501
|
-
|
|
4502
|
-
break;
|
|
4503
|
-
|
|
4504
|
-
case 'poll.vote_removed':
|
|
4505
|
-
if (event.poll_vote && event.poll) {
|
|
4506
|
-
var _event$message4;
|
|
4507
|
-
|
|
4508
|
-
channelState.removePollVote(event.poll_vote, event.poll, ((_event$message4 = event.message) === null || _event$message4 === void 0 ? void 0 : _event$message4.id) || '');
|
|
4509
|
-
}
|
|
4510
|
-
|
|
4511
|
-
break;
|
|
4512
|
-
|
|
4513
|
-
case 'poll.closed':
|
|
4514
|
-
if (event.message) {
|
|
4515
|
-
channelState.addMessageSorted(event.message, false, false);
|
|
4516
|
-
}
|
|
4517
|
-
|
|
4518
|
-
break;
|
|
4519
|
-
|
|
4520
4824
|
case 'reaction.new':
|
|
4521
4825
|
if (event.message && event.reaction) {
|
|
4522
4826
|
event.message = channelState.addReaction(event.reaction, event.message);
|
|
@@ -4540,7 +4844,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4540
4844
|
break;
|
|
4541
4845
|
|
|
4542
4846
|
case 'channel.hidden':
|
|
4543
|
-
channel.data = _objectSpread$
|
|
4847
|
+
channel.data = _objectSpread$a(_objectSpread$a({}, channel.data), {}, {
|
|
4544
4848
|
hidden: true
|
|
4545
4849
|
});
|
|
4546
4850
|
|
|
@@ -4551,26 +4855,26 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4551
4855
|
break;
|
|
4552
4856
|
|
|
4553
4857
|
case 'channel.visible':
|
|
4554
|
-
channel.data = _objectSpread$
|
|
4858
|
+
channel.data = _objectSpread$a(_objectSpread$a({}, channel.data), {}, {
|
|
4555
4859
|
hidden: false
|
|
4556
4860
|
});
|
|
4557
4861
|
break;
|
|
4558
4862
|
|
|
4559
4863
|
case 'user.banned':
|
|
4560
4864
|
if (!((_event$user11 = event.user) !== null && _event$user11 !== void 0 && _event$user11.id)) break;
|
|
4561
|
-
channelState.members[event.user.id] = _objectSpread$
|
|
4865
|
+
channelState.members[event.user.id] = _objectSpread$a(_objectSpread$a({}, channelState.members[event.user.id] || {}), {}, {
|
|
4562
4866
|
shadow_banned: !!event.shadow,
|
|
4563
4867
|
banned: !event.shadow,
|
|
4564
|
-
user: _objectSpread$
|
|
4868
|
+
user: _objectSpread$a(_objectSpread$a({}, ((_channelState$members = channelState.members[event.user.id]) === null || _channelState$members === void 0 ? void 0 : _channelState$members.user) || {}), event.user)
|
|
4565
4869
|
});
|
|
4566
4870
|
break;
|
|
4567
4871
|
|
|
4568
4872
|
case 'user.unbanned':
|
|
4569
4873
|
if (!((_event$user12 = event.user) !== null && _event$user12 !== void 0 && _event$user12.id)) break;
|
|
4570
|
-
channelState.members[event.user.id] = _objectSpread$
|
|
4874
|
+
channelState.members[event.user.id] = _objectSpread$a(_objectSpread$a({}, channelState.members[event.user.id] || {}), {}, {
|
|
4571
4875
|
shadow_banned: false,
|
|
4572
4876
|
banned: false,
|
|
4573
|
-
user: _objectSpread$
|
|
4877
|
+
user: _objectSpread$a(_objectSpread$a({}, ((_channelState$members2 = channelState.members[event.user.id]) === null || _channelState$members2 === void 0 ? void 0 : _channelState$members2.user) || {}), event.user)
|
|
4574
4878
|
});
|
|
4575
4879
|
break;
|
|
4576
4880
|
} // any event can send over the online count
|
|
@@ -4600,7 +4904,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4600
4904
|
|
|
4601
4905
|
|
|
4602
4906
|
if (state.members) {
|
|
4603
|
-
var _iterator = _createForOfIteratorHelper$
|
|
4907
|
+
var _iterator = _createForOfIteratorHelper$4(state.members),
|
|
4604
4908
|
_step;
|
|
4605
4909
|
|
|
4606
4910
|
try {
|
|
@@ -4644,7 +4948,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4644
4948
|
|
|
4645
4949
|
|
|
4646
4950
|
if (state.watchers) {
|
|
4647
|
-
var _iterator2 = _createForOfIteratorHelper$
|
|
4951
|
+
var _iterator2 = _createForOfIteratorHelper$4(state.watchers),
|
|
4648
4952
|
_step2;
|
|
4649
4953
|
|
|
4650
4954
|
try {
|
|
@@ -4680,7 +4984,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4680
4984
|
|
|
4681
4985
|
|
|
4682
4986
|
if (state.read) {
|
|
4683
|
-
var _iterator3 = _createForOfIteratorHelper$
|
|
4987
|
+
var _iterator3 = _createForOfIteratorHelper$4(state.read),
|
|
4684
4988
|
_step3;
|
|
4685
4989
|
|
|
4686
4990
|
try {
|
|
@@ -4754,11 +5058,11 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4754
5058
|
return Channel;
|
|
4755
5059
|
}();
|
|
4756
5060
|
|
|
4757
|
-
function _createForOfIteratorHelper$
|
|
5061
|
+
function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4758
5062
|
|
|
4759
|
-
function _unsupportedIterableToArray$
|
|
5063
|
+
function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
|
|
4760
5064
|
|
|
4761
|
-
function _arrayLikeToArray$
|
|
5065
|
+
function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
4762
5066
|
|
|
4763
5067
|
/**
|
|
4764
5068
|
* ClientState - A container class for the client state.
|
|
@@ -4781,7 +5085,7 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
4781
5085
|
_createClass(ClientState, [{
|
|
4782
5086
|
key: "updateUsers",
|
|
4783
5087
|
value: function updateUsers(users) {
|
|
4784
|
-
var _iterator = _createForOfIteratorHelper$
|
|
5088
|
+
var _iterator = _createForOfIteratorHelper$3(users),
|
|
4785
5089
|
_step;
|
|
4786
5090
|
|
|
4787
5091
|
try {
|
|
@@ -4829,9 +5133,9 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
4829
5133
|
return ClientState;
|
|
4830
5134
|
}();
|
|
4831
5135
|
|
|
4832
|
-
function ownKeys$
|
|
5136
|
+
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4833
5137
|
|
|
4834
|
-
function _objectSpread$
|
|
5138
|
+
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$9(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4835
5139
|
var InsightMetrics = function InsightMetrics() {
|
|
4836
5140
|
_classCallCheck(this, InsightMetrics);
|
|
4837
5141
|
|
|
@@ -4910,7 +5214,7 @@ var postInsights = /*#__PURE__*/function () {
|
|
|
4910
5214
|
};
|
|
4911
5215
|
}();
|
|
4912
5216
|
function buildWsFatalInsight(connection, event) {
|
|
4913
|
-
return _objectSpread$
|
|
5217
|
+
return _objectSpread$9(_objectSpread$9({}, event), buildWsBaseInsight(connection));
|
|
4914
5218
|
}
|
|
4915
5219
|
|
|
4916
5220
|
function buildWsBaseInsight(connection) {
|
|
@@ -4943,9 +5247,9 @@ function buildWsSuccessAfterFailureInsight(connection) {
|
|
|
4943
5247
|
return buildWsBaseInsight(connection);
|
|
4944
5248
|
}
|
|
4945
5249
|
|
|
4946
|
-
function ownKeys$
|
|
5250
|
+
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4947
5251
|
|
|
4948
|
-
function _objectSpread$
|
|
5252
|
+
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4949
5253
|
|
|
4950
5254
|
// Type guards to check WebSocket error type
|
|
4951
5255
|
var isCloseEvent = function isCloseEvent(res) {
|
|
@@ -5309,7 +5613,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
5309
5613
|
value: function _log(msg) {
|
|
5310
5614
|
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5311
5615
|
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5312
|
-
this.client.logger(level, 'connection:' + msg, _objectSpread$
|
|
5616
|
+
this.client.logger(level, 'connection:' + msg, _objectSpread$8({
|
|
5313
5617
|
tags: ['connection']
|
|
5314
5618
|
}, extra));
|
|
5315
5619
|
}
|
|
@@ -5900,9 +6204,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
5900
6204
|
return StableWSConnection;
|
|
5901
6205
|
}();
|
|
5902
6206
|
|
|
5903
|
-
function ownKeys$
|
|
6207
|
+
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5904
6208
|
|
|
5905
|
-
function _objectSpread$
|
|
6209
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
5906
6210
|
|
|
5907
6211
|
/**
|
|
5908
6212
|
* Creates the JWT token that can be used for a UserSession
|
|
@@ -5923,7 +6227,7 @@ function JWTUserToken(apiSecret, userId) {
|
|
|
5923
6227
|
throw new TypeError('userId should be a string');
|
|
5924
6228
|
}
|
|
5925
6229
|
|
|
5926
|
-
var payload = _objectSpread$
|
|
6230
|
+
var payload = _objectSpread$7({
|
|
5927
6231
|
user_id: userId
|
|
5928
6232
|
}, extraData); // make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
5929
6233
|
|
|
@@ -6333,9 +6637,9 @@ function isErrorResponse(res) {
|
|
|
6333
6637
|
return !res.status || res.status < 200 || 300 <= res.status;
|
|
6334
6638
|
}
|
|
6335
6639
|
|
|
6336
|
-
function ownKeys$
|
|
6640
|
+
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
6337
6641
|
|
|
6338
|
-
function _objectSpread$
|
|
6642
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6339
6643
|
var ConnectionState;
|
|
6340
6644
|
|
|
6341
6645
|
(function (ConnectionState) {
|
|
@@ -6398,7 +6702,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
6398
6702
|
_context.next = 4;
|
|
6399
6703
|
return _this.client.doAxiosRequest('get', _this.client.baseURL.replace(':3030', ':8900') + '/longpoll', // replace port if present for testing with local API
|
|
6400
6704
|
undefined, {
|
|
6401
|
-
config: _objectSpread$
|
|
6705
|
+
config: _objectSpread$6(_objectSpread$6({}, config), {}, {
|
|
6402
6706
|
cancelToken: (_this$cancelToken2 = _this.cancelToken) === null || _this$cancelToken2 === void 0 ? void 0 : _this$cancelToken2.token
|
|
6403
6707
|
}),
|
|
6404
6708
|
params: params
|
|
@@ -6676,7 +6980,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
6676
6980
|
value: function _log(msg) {
|
|
6677
6981
|
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6678
6982
|
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
6679
|
-
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$
|
|
6983
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$6({
|
|
6680
6984
|
tags: ['connection_fallback', 'connection']
|
|
6681
6985
|
}, extra));
|
|
6682
6986
|
}
|
|
@@ -6709,250 +7013,45 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
6709
7013
|
return WSConnectionFallback;
|
|
6710
7014
|
}();
|
|
6711
7015
|
|
|
6712
|
-
var
|
|
6713
|
-
function
|
|
6714
|
-
_classCallCheck(this,
|
|
7016
|
+
var Segment = /*#__PURE__*/function () {
|
|
7017
|
+
function Segment(client, type, id, data) {
|
|
7018
|
+
_classCallCheck(this, Segment);
|
|
6715
7019
|
|
|
6716
|
-
_defineProperty(this, "
|
|
7020
|
+
_defineProperty(this, "type", void 0);
|
|
6717
7021
|
|
|
6718
|
-
_defineProperty(this, "
|
|
7022
|
+
_defineProperty(this, "id", void 0);
|
|
6719
7023
|
|
|
6720
7024
|
_defineProperty(this, "client", void 0);
|
|
6721
7025
|
|
|
7026
|
+
_defineProperty(this, "data", void 0);
|
|
7027
|
+
|
|
6722
7028
|
this.client = client;
|
|
7029
|
+
this.type = type;
|
|
6723
7030
|
this.id = id;
|
|
6724
7031
|
this.data = data;
|
|
6725
7032
|
}
|
|
6726
7033
|
|
|
6727
|
-
_createClass(
|
|
7034
|
+
_createClass(Segment, [{
|
|
6728
7035
|
key: "create",
|
|
6729
7036
|
value: function () {
|
|
6730
7037
|
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
6731
|
-
var _this$data, _this$data2, _this$data3, _this$data4, _this$data5
|
|
7038
|
+
var _this$data, _this$data2, _this$data3, _this$data4, _this$data5;
|
|
6732
7039
|
|
|
6733
|
-
var body
|
|
7040
|
+
var body;
|
|
6734
7041
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
6735
7042
|
while (1) {
|
|
6736
7043
|
switch (_context.prev = _context.next) {
|
|
6737
7044
|
case 0:
|
|
6738
7045
|
body = {
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
create_channels: (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5.create_channels,
|
|
6745
|
-
description: (_this$data6 = this.data) === null || _this$data6 === void 0 ? void 0 : _this$data6.description,
|
|
6746
|
-
name: (_this$data7 = this.data) === null || _this$data7 === void 0 ? void 0 : _this$data7.name,
|
|
6747
|
-
user_ids: (_this$data8 = this.data) === null || _this$data8 === void 0 ? void 0 : _this$data8.user_ids
|
|
7046
|
+
name: (_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.name,
|
|
7047
|
+
filter: (_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2.filter,
|
|
7048
|
+
description: (_this$data3 = this.data) === null || _this$data3 === void 0 ? void 0 : _this$data3.description,
|
|
7049
|
+
all_sender_channels: (_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : _this$data4.all_sender_channels,
|
|
7050
|
+
all_users: (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5.all_users
|
|
6748
7051
|
};
|
|
6749
|
-
_context.
|
|
6750
|
-
return this.client.createCampaign(body);
|
|
6751
|
-
|
|
6752
|
-
case 3:
|
|
6753
|
-
result = _context.sent;
|
|
6754
|
-
this.id = result.campaign.id;
|
|
6755
|
-
this.data = result.campaign;
|
|
6756
|
-
return _context.abrupt("return", result);
|
|
7052
|
+
return _context.abrupt("return", this.client.createSegment(this.type, this.id, body));
|
|
6757
7053
|
|
|
6758
|
-
case
|
|
6759
|
-
case "end":
|
|
6760
|
-
return _context.stop();
|
|
6761
|
-
}
|
|
6762
|
-
}
|
|
6763
|
-
}, _callee, this);
|
|
6764
|
-
}));
|
|
6765
|
-
|
|
6766
|
-
function create() {
|
|
6767
|
-
return _create.apply(this, arguments);
|
|
6768
|
-
}
|
|
6769
|
-
|
|
6770
|
-
return create;
|
|
6771
|
-
}()
|
|
6772
|
-
}, {
|
|
6773
|
-
key: "verifyCampaignId",
|
|
6774
|
-
value: function verifyCampaignId() {
|
|
6775
|
-
if (!this.id) {
|
|
6776
|
-
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)');
|
|
6777
|
-
}
|
|
6778
|
-
}
|
|
6779
|
-
}, {
|
|
6780
|
-
key: "start",
|
|
6781
|
-
value: function () {
|
|
6782
|
-
var _start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
|
|
6783
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
6784
|
-
while (1) {
|
|
6785
|
-
switch (_context2.prev = _context2.next) {
|
|
6786
|
-
case 0:
|
|
6787
|
-
this.verifyCampaignId();
|
|
6788
|
-
_context2.next = 3;
|
|
6789
|
-
return this.client.startCampaign(this.id, options);
|
|
6790
|
-
|
|
6791
|
-
case 3:
|
|
6792
|
-
return _context2.abrupt("return", _context2.sent);
|
|
6793
|
-
|
|
6794
|
-
case 4:
|
|
6795
|
-
case "end":
|
|
6796
|
-
return _context2.stop();
|
|
6797
|
-
}
|
|
6798
|
-
}
|
|
6799
|
-
}, _callee2, this);
|
|
6800
|
-
}));
|
|
6801
|
-
|
|
6802
|
-
function start(_x) {
|
|
6803
|
-
return _start.apply(this, arguments);
|
|
6804
|
-
}
|
|
6805
|
-
|
|
6806
|
-
return start;
|
|
6807
|
-
}()
|
|
6808
|
-
}, {
|
|
6809
|
-
key: "update",
|
|
6810
|
-
value: function () {
|
|
6811
|
-
var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
|
|
6812
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
6813
|
-
while (1) {
|
|
6814
|
-
switch (_context3.prev = _context3.next) {
|
|
6815
|
-
case 0:
|
|
6816
|
-
this.verifyCampaignId();
|
|
6817
|
-
return _context3.abrupt("return", this.client.updateCampaign(this.id, data));
|
|
6818
|
-
|
|
6819
|
-
case 2:
|
|
6820
|
-
case "end":
|
|
6821
|
-
return _context3.stop();
|
|
6822
|
-
}
|
|
6823
|
-
}
|
|
6824
|
-
}, _callee3, this);
|
|
6825
|
-
}));
|
|
6826
|
-
|
|
6827
|
-
function update(_x2) {
|
|
6828
|
-
return _update.apply(this, arguments);
|
|
6829
|
-
}
|
|
6830
|
-
|
|
6831
|
-
return update;
|
|
6832
|
-
}()
|
|
6833
|
-
}, {
|
|
6834
|
-
key: "delete",
|
|
6835
|
-
value: function () {
|
|
6836
|
-
var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
6837
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
6838
|
-
while (1) {
|
|
6839
|
-
switch (_context4.prev = _context4.next) {
|
|
6840
|
-
case 0:
|
|
6841
|
-
this.verifyCampaignId();
|
|
6842
|
-
_context4.next = 3;
|
|
6843
|
-
return this.client.deleteCampaign(this.id);
|
|
6844
|
-
|
|
6845
|
-
case 3:
|
|
6846
|
-
return _context4.abrupt("return", _context4.sent);
|
|
6847
|
-
|
|
6848
|
-
case 4:
|
|
6849
|
-
case "end":
|
|
6850
|
-
return _context4.stop();
|
|
6851
|
-
}
|
|
6852
|
-
}
|
|
6853
|
-
}, _callee4, this);
|
|
6854
|
-
}));
|
|
6855
|
-
|
|
6856
|
-
function _delete() {
|
|
6857
|
-
return _delete2.apply(this, arguments);
|
|
6858
|
-
}
|
|
6859
|
-
|
|
6860
|
-
return _delete;
|
|
6861
|
-
}()
|
|
6862
|
-
}, {
|
|
6863
|
-
key: "stop",
|
|
6864
|
-
value: function () {
|
|
6865
|
-
var _stop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
6866
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
6867
|
-
while (1) {
|
|
6868
|
-
switch (_context5.prev = _context5.next) {
|
|
6869
|
-
case 0:
|
|
6870
|
-
this.verifyCampaignId();
|
|
6871
|
-
return _context5.abrupt("return", this.client.stopCampaign(this.id));
|
|
6872
|
-
|
|
6873
|
-
case 2:
|
|
6874
|
-
case "end":
|
|
6875
|
-
return _context5.stop();
|
|
6876
|
-
}
|
|
6877
|
-
}
|
|
6878
|
-
}, _callee5, this);
|
|
6879
|
-
}));
|
|
6880
|
-
|
|
6881
|
-
function stop() {
|
|
6882
|
-
return _stop.apply(this, arguments);
|
|
6883
|
-
}
|
|
6884
|
-
|
|
6885
|
-
return stop;
|
|
6886
|
-
}()
|
|
6887
|
-
}, {
|
|
6888
|
-
key: "get",
|
|
6889
|
-
value: function () {
|
|
6890
|
-
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
6891
|
-
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
6892
|
-
while (1) {
|
|
6893
|
-
switch (_context6.prev = _context6.next) {
|
|
6894
|
-
case 0:
|
|
6895
|
-
this.verifyCampaignId();
|
|
6896
|
-
return _context6.abrupt("return", this.client.getCampaign(this.id));
|
|
6897
|
-
|
|
6898
|
-
case 2:
|
|
6899
|
-
case "end":
|
|
6900
|
-
return _context6.stop();
|
|
6901
|
-
}
|
|
6902
|
-
}
|
|
6903
|
-
}, _callee6, this);
|
|
6904
|
-
}));
|
|
6905
|
-
|
|
6906
|
-
function get() {
|
|
6907
|
-
return _get.apply(this, arguments);
|
|
6908
|
-
}
|
|
6909
|
-
|
|
6910
|
-
return get;
|
|
6911
|
-
}()
|
|
6912
|
-
}]);
|
|
6913
|
-
|
|
6914
|
-
return Campaign;
|
|
6915
|
-
}();
|
|
6916
|
-
|
|
6917
|
-
var Segment = /*#__PURE__*/function () {
|
|
6918
|
-
function Segment(client, type, id, data) {
|
|
6919
|
-
_classCallCheck(this, Segment);
|
|
6920
|
-
|
|
6921
|
-
_defineProperty(this, "type", void 0);
|
|
6922
|
-
|
|
6923
|
-
_defineProperty(this, "id", void 0);
|
|
6924
|
-
|
|
6925
|
-
_defineProperty(this, "client", void 0);
|
|
6926
|
-
|
|
6927
|
-
_defineProperty(this, "data", void 0);
|
|
6928
|
-
|
|
6929
|
-
this.client = client;
|
|
6930
|
-
this.type = type;
|
|
6931
|
-
this.id = id;
|
|
6932
|
-
this.data = data;
|
|
6933
|
-
}
|
|
6934
|
-
|
|
6935
|
-
_createClass(Segment, [{
|
|
6936
|
-
key: "create",
|
|
6937
|
-
value: function () {
|
|
6938
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
6939
|
-
var _this$data, _this$data2, _this$data3, _this$data4, _this$data5;
|
|
6940
|
-
|
|
6941
|
-
var body;
|
|
6942
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
6943
|
-
while (1) {
|
|
6944
|
-
switch (_context.prev = _context.next) {
|
|
6945
|
-
case 0:
|
|
6946
|
-
body = {
|
|
6947
|
-
name: (_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.name,
|
|
6948
|
-
filter: (_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2.filter,
|
|
6949
|
-
description: (_this$data3 = this.data) === null || _this$data3 === void 0 ? void 0 : _this$data3.description,
|
|
6950
|
-
all_sender_channels: (_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : _this$data4.all_sender_channels,
|
|
6951
|
-
all_users: (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5.all_users
|
|
6952
|
-
};
|
|
6953
|
-
return _context.abrupt("return", this.client.createSegment(this.type, this.id, body));
|
|
6954
|
-
|
|
6955
|
-
case 2:
|
|
7054
|
+
case 2:
|
|
6956
7055
|
case "end":
|
|
6957
7056
|
return _context.stop();
|
|
6958
7057
|
}
|
|
@@ -7256,9 +7355,9 @@ var VotingVisibility;
|
|
|
7256
7355
|
VotingVisibility["public"] = "public";
|
|
7257
7356
|
})(VotingVisibility || (VotingVisibility = {}));
|
|
7258
7357
|
|
|
7259
|
-
function ownKeys$
|
|
7358
|
+
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
7260
7359
|
|
|
7261
|
-
function _objectSpread$
|
|
7360
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
7262
7361
|
|
|
7263
7362
|
function isPatch(value) {
|
|
7264
7363
|
return typeof value === 'function';
|
|
@@ -7288,7 +7387,7 @@ var StateStore = function StateStore(value) {
|
|
|
7288
7387
|
|
|
7289
7388
|
_defineProperty(this, "partialNext", function (partial) {
|
|
7290
7389
|
return _this.next(function (current) {
|
|
7291
|
-
return _objectSpread$
|
|
7390
|
+
return _objectSpread$5(_objectSpread$5({}, current), partial);
|
|
7292
7391
|
});
|
|
7293
7392
|
});
|
|
7294
7393
|
|
|
@@ -7338,11 +7437,11 @@ var StateStore = function StateStore(value) {
|
|
|
7338
7437
|
|
|
7339
7438
|
_defineProperty(StateStore, "logCount", 5);
|
|
7340
7439
|
|
|
7341
|
-
var _excluded$
|
|
7440
|
+
var _excluded$2 = ["limit", "sort"];
|
|
7342
7441
|
|
|
7343
|
-
function ownKeys$
|
|
7442
|
+
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
7344
7443
|
|
|
7345
|
-
function _objectSpread$
|
|
7444
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
7346
7445
|
var DEFAULT_PAGE_LIMIT = 50;
|
|
7347
7446
|
var DEFAULT_SORT = [{
|
|
7348
7447
|
created_at: -1
|
|
@@ -7571,14 +7670,14 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7571
7670
|
if (userId === ((_event$user2 = event.user) === null || _event$user2 === void 0 ? void 0 : _event$user2.id)) {
|
|
7572
7671
|
// The user who just sent a message to the thread has no unread messages
|
|
7573
7672
|
// in that thread
|
|
7574
|
-
nextUserRead = _objectSpread$
|
|
7673
|
+
nextUserRead = _objectSpread$4(_objectSpread$4({}, nextUserRead), {}, {
|
|
7575
7674
|
lastReadAt: event.created_at ? new Date(event.created_at) : new Date(),
|
|
7576
7675
|
user: event.user,
|
|
7577
7676
|
unreadMessageCount: 0
|
|
7578
7677
|
});
|
|
7579
7678
|
} else if (active && userId === _this.client.userID) ; else {
|
|
7580
7679
|
// Increment unread count for all users except the author of the new message
|
|
7581
|
-
nextUserRead = _objectSpread$
|
|
7680
|
+
nextUserRead = _objectSpread$4(_objectSpread$4({}, nextUserRead), {}, {
|
|
7582
7681
|
unreadMessageCount: userRead.unreadMessageCount + 1
|
|
7583
7682
|
});
|
|
7584
7683
|
}
|
|
@@ -7602,8 +7701,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7602
7701
|
var user = event.user;
|
|
7603
7702
|
|
|
7604
7703
|
_this.state.next(function (current) {
|
|
7605
|
-
return _objectSpread$
|
|
7606
|
-
read: _objectSpread$
|
|
7704
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7705
|
+
read: _objectSpread$4(_objectSpread$4({}, current.read), {}, _defineProperty({}, userId, {
|
|
7607
7706
|
lastReadAt: new Date(createdAt),
|
|
7608
7707
|
user: user,
|
|
7609
7708
|
lastReadMessageId: event.last_read_message_id,
|
|
@@ -7714,7 +7813,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7714
7813
|
}
|
|
7715
7814
|
|
|
7716
7815
|
_this.state.next(function (current) {
|
|
7717
|
-
return _objectSpread$
|
|
7816
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7718
7817
|
replies: addToMessageList(current.replies, formattedMessage, timestampChanged)
|
|
7719
7818
|
});
|
|
7720
7819
|
});
|
|
@@ -7731,7 +7830,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7731
7830
|
var _message$reply_count;
|
|
7732
7831
|
|
|
7733
7832
|
var formattedMessage = formatMessage(message);
|
|
7734
|
-
return _objectSpread$
|
|
7833
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7735
7834
|
deletedAt: formattedMessage.deleted_at,
|
|
7736
7835
|
parentMessage: formattedMessage,
|
|
7737
7836
|
replyCount: (_message$reply_count = message.reply_count) !== null && _message$reply_count !== void 0 ? _message$reply_count : current.replyCount
|
|
@@ -7802,9 +7901,9 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7802
7901
|
limit = _ref10$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref10$limit,
|
|
7803
7902
|
_ref10$sort = _ref10.sort,
|
|
7804
7903
|
sort = _ref10$sort === void 0 ? DEFAULT_SORT : _ref10$sort,
|
|
7805
|
-
otherOptions = _objectWithoutProperties(_ref10, _excluded$
|
|
7904
|
+
otherOptions = _objectWithoutProperties(_ref10, _excluded$2);
|
|
7806
7905
|
|
|
7807
|
-
return _this.channel.getReplies(_this.id, _objectSpread$
|
|
7906
|
+
return _this.channel.getReplies(_this.id, _objectSpread$4({
|
|
7808
7907
|
limit: limit
|
|
7809
7908
|
}, otherOptions), sort);
|
|
7810
7909
|
});
|
|
@@ -7848,12 +7947,12 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7848
7947
|
limit = Math.abs(count);
|
|
7849
7948
|
|
|
7850
7949
|
_this.state.partialNext({
|
|
7851
|
-
pagination: _objectSpread$
|
|
7950
|
+
pagination: _objectSpread$4(_objectSpread$4({}, pagination), {}, _defineProperty({}, loadingKey, true))
|
|
7852
7951
|
});
|
|
7853
7952
|
|
|
7854
7953
|
_context3.prev = 7;
|
|
7855
7954
|
_context3.next = 10;
|
|
7856
|
-
return _this.queryReplies(_objectSpread$
|
|
7955
|
+
return _this.queryReplies(_objectSpread$4(_objectSpread$4({}, queryOptions), {}, {
|
|
7857
7956
|
limit: limit
|
|
7858
7957
|
}));
|
|
7859
7958
|
|
|
@@ -7875,9 +7974,9 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7875
7974
|
(_nextReplies = nextReplies)[insertionMethodKey].apply(_nextReplies, _toConsumableArray(replies));
|
|
7876
7975
|
}
|
|
7877
7976
|
|
|
7878
|
-
return _objectSpread$
|
|
7977
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7879
7978
|
replies: nextReplies,
|
|
7880
|
-
pagination: _objectSpread$
|
|
7979
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, cursorKey, data.messages.length < limit ? null : maybeNextCursor), _defineProperty(_objectSpread4, loadingKey, false), _objectSpread4))
|
|
7881
7980
|
});
|
|
7882
7981
|
});
|
|
7883
7982
|
|
|
@@ -7891,8 +7990,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7891
7990
|
_this.client.logger('error', _context3.t0.message);
|
|
7892
7991
|
|
|
7893
7992
|
_this.state.next(function (current) {
|
|
7894
|
-
return _objectSpread$
|
|
7895
|
-
pagination: _objectSpread$
|
|
7993
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
7994
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, _defineProperty({}, loadingKey, false))
|
|
7896
7995
|
});
|
|
7897
7996
|
});
|
|
7898
7997
|
|
|
@@ -7997,9 +8096,9 @@ var ownUnreadCountSelector = function ownUnreadCountSelector(currentUserId) {
|
|
|
7997
8096
|
};
|
|
7998
8097
|
};
|
|
7999
8098
|
|
|
8000
|
-
function ownKeys$
|
|
8099
|
+
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
8001
8100
|
|
|
8002
|
-
function _objectSpread$
|
|
8101
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8003
8102
|
var MODERATION_ENTITY_TYPES = {
|
|
8004
8103
|
user: 'stream:user',
|
|
8005
8104
|
message: 'stream:chat:v1:message'
|
|
@@ -8116,7 +8215,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8116
8215
|
case 0:
|
|
8117
8216
|
options = _args3.length > 4 && _args3[4] !== undefined ? _args3[4] : {};
|
|
8118
8217
|
_context3.next = 3;
|
|
8119
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/flag', _objectSpread$
|
|
8218
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/flag', _objectSpread$3({
|
|
8120
8219
|
entity_type: entityType,
|
|
8121
8220
|
entity_id: entityId,
|
|
8122
8221
|
entity_creator_id: entityCreatorID,
|
|
@@ -8161,7 +8260,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8161
8260
|
case 0:
|
|
8162
8261
|
options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
8163
8262
|
_context4.next = 3;
|
|
8164
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/mute', _objectSpread$
|
|
8263
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/mute', _objectSpread$3({
|
|
8165
8264
|
target_ids: [targetID]
|
|
8166
8265
|
}, options));
|
|
8167
8266
|
|
|
@@ -8199,7 +8298,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8199
8298
|
switch (_context5.prev = _context5.next) {
|
|
8200
8299
|
case 0:
|
|
8201
8300
|
_context5.next = 2;
|
|
8202
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/unmute', _objectSpread$
|
|
8301
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/unmute', _objectSpread$3({
|
|
8203
8302
|
target_ids: [targetID]
|
|
8204
8303
|
}, options));
|
|
8205
8304
|
|
|
@@ -8241,7 +8340,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8241
8340
|
case 0:
|
|
8242
8341
|
options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
8243
8342
|
_context6.next = 3;
|
|
8244
|
-
return this.client.get(this.client.baseURL + "/api/v2/moderation/user_report", _objectSpread$
|
|
8343
|
+
return this.client.get(this.client.baseURL + "/api/v2/moderation/user_report", _objectSpread$3({
|
|
8245
8344
|
user_id: userID
|
|
8246
8345
|
}, options));
|
|
8247
8346
|
|
|
@@ -8285,7 +8384,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8285
8384
|
sort = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : [];
|
|
8286
8385
|
options = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : {};
|
|
8287
8386
|
_context7.next = 5;
|
|
8288
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/review_queue', _objectSpread$
|
|
8387
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/review_queue', _objectSpread$3({
|
|
8289
8388
|
filter: filterConditions,
|
|
8290
8389
|
sort: normalizeQuerySort(sort)
|
|
8291
8390
|
}, options));
|
|
@@ -8377,26 +8476,20 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8377
8476
|
return getConfig;
|
|
8378
8477
|
}()
|
|
8379
8478
|
}, {
|
|
8380
|
-
key: "
|
|
8479
|
+
key: "deleteConfig",
|
|
8381
8480
|
value: function () {
|
|
8382
|
-
var
|
|
8383
|
-
var options,
|
|
8384
|
-
_args10 = arguments;
|
|
8481
|
+
var _deleteConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(key) {
|
|
8385
8482
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
8386
8483
|
while (1) {
|
|
8387
8484
|
switch (_context10.prev = _context10.next) {
|
|
8388
8485
|
case 0:
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/submit_action', _objectSpread$2({
|
|
8392
|
-
action_type: actionType,
|
|
8393
|
-
item_id: itemID
|
|
8394
|
-
}, options));
|
|
8486
|
+
_context10.next = 2;
|
|
8487
|
+
return this.client.delete(this.client.baseURL + '/api/v2/moderation/config/' + key);
|
|
8395
8488
|
|
|
8396
|
-
case
|
|
8489
|
+
case 2:
|
|
8397
8490
|
return _context10.abrupt("return", _context10.sent);
|
|
8398
8491
|
|
|
8399
|
-
case
|
|
8492
|
+
case 3:
|
|
8400
8493
|
case "end":
|
|
8401
8494
|
return _context10.stop();
|
|
8402
8495
|
}
|
|
@@ -8404,31 +8497,155 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8404
8497
|
}, _callee10, this);
|
|
8405
8498
|
}));
|
|
8406
8499
|
|
|
8407
|
-
function
|
|
8408
|
-
return
|
|
8500
|
+
function deleteConfig(_x14) {
|
|
8501
|
+
return _deleteConfig.apply(this, arguments);
|
|
8409
8502
|
}
|
|
8410
8503
|
|
|
8411
|
-
return
|
|
8504
|
+
return deleteConfig;
|
|
8412
8505
|
}()
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
}
|
|
8417
|
-
|
|
8418
|
-
|
|
8506
|
+
/**
|
|
8507
|
+
* Query moderation configs
|
|
8508
|
+
* @param {Object} filterConditions Filter conditions for querying moderation configs
|
|
8509
|
+
* @param {Object} sort Sort conditions for querying moderation configs
|
|
8510
|
+
* @param {Object} options Additional options for querying moderation configs
|
|
8511
|
+
*/
|
|
8419
8512
|
|
|
8420
|
-
|
|
8513
|
+
}, {
|
|
8514
|
+
key: "queryConfigs",
|
|
8515
|
+
value: function () {
|
|
8516
|
+
var _queryConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(filterConditions, sort) {
|
|
8517
|
+
var options,
|
|
8518
|
+
_args11 = arguments;
|
|
8519
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
8520
|
+
while (1) {
|
|
8521
|
+
switch (_context11.prev = _context11.next) {
|
|
8522
|
+
case 0:
|
|
8523
|
+
options = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : {};
|
|
8524
|
+
_context11.next = 3;
|
|
8525
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/configs', _objectSpread$3({
|
|
8526
|
+
filter: filterConditions,
|
|
8527
|
+
sort: sort
|
|
8528
|
+
}, options));
|
|
8421
8529
|
|
|
8422
|
-
|
|
8530
|
+
case 3:
|
|
8531
|
+
return _context11.abrupt("return", _context11.sent);
|
|
8423
8532
|
|
|
8424
|
-
|
|
8533
|
+
case 4:
|
|
8534
|
+
case "end":
|
|
8535
|
+
return _context11.stop();
|
|
8536
|
+
}
|
|
8537
|
+
}
|
|
8538
|
+
}, _callee11, this);
|
|
8539
|
+
}));
|
|
8425
8540
|
|
|
8426
|
-
function
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8541
|
+
function queryConfigs(_x15, _x16) {
|
|
8542
|
+
return _queryConfigs.apply(this, arguments);
|
|
8543
|
+
}
|
|
8544
|
+
|
|
8545
|
+
return queryConfigs;
|
|
8546
|
+
}()
|
|
8547
|
+
}, {
|
|
8548
|
+
key: "submitAction",
|
|
8549
|
+
value: function () {
|
|
8550
|
+
var _submitAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(actionType, itemID) {
|
|
8551
|
+
var options,
|
|
8552
|
+
_args12 = arguments;
|
|
8553
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
8554
|
+
while (1) {
|
|
8555
|
+
switch (_context12.prev = _context12.next) {
|
|
8556
|
+
case 0:
|
|
8557
|
+
options = _args12.length > 2 && _args12[2] !== undefined ? _args12[2] : {};
|
|
8558
|
+
_context12.next = 3;
|
|
8559
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/submit_action', _objectSpread$3({
|
|
8560
|
+
action_type: actionType,
|
|
8561
|
+
item_id: itemID
|
|
8562
|
+
}, options));
|
|
8563
|
+
|
|
8564
|
+
case 3:
|
|
8565
|
+
return _context12.abrupt("return", _context12.sent);
|
|
8566
|
+
|
|
8567
|
+
case 4:
|
|
8568
|
+
case "end":
|
|
8569
|
+
return _context12.stop();
|
|
8570
|
+
}
|
|
8571
|
+
}
|
|
8572
|
+
}, _callee12, this);
|
|
8573
|
+
}));
|
|
8574
|
+
|
|
8575
|
+
function submitAction(_x17, _x18) {
|
|
8576
|
+
return _submitAction.apply(this, arguments);
|
|
8577
|
+
}
|
|
8578
|
+
|
|
8579
|
+
return submitAction;
|
|
8580
|
+
}()
|
|
8581
|
+
/**
|
|
8582
|
+
*
|
|
8583
|
+
* @param {string} entityType string Type of entity to be checked E.g., stream:user, stream:chat:v1:message, or any custom string
|
|
8584
|
+
* @param {string} entityID string ID of the entity to be checked. This is mainly for tracking purposes
|
|
8585
|
+
* @param {string} entityCreatorID string ID of the entity creator
|
|
8586
|
+
* @param {object} moderationPayload object Content to be checked for moderation. E.g., { texts: ['text1', 'text2'], images: ['image1', 'image2']}
|
|
8587
|
+
* @param {Array} moderationPayload.texts array Array of texts to be checked for moderation
|
|
8588
|
+
* @param {Array} moderationPayload.images array Array of images to be checked for moderation
|
|
8589
|
+
* @param {Array} moderationPayload.videos array Array of videos to be checked for moderation
|
|
8590
|
+
* @param configKey
|
|
8591
|
+
* @param options
|
|
8592
|
+
* @returns
|
|
8593
|
+
*/
|
|
8594
|
+
|
|
8595
|
+
}, {
|
|
8596
|
+
key: "check",
|
|
8597
|
+
value: function () {
|
|
8598
|
+
var _check = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(entityType, entityID, entityCreatorID, moderationPayload, configKey, options) {
|
|
8599
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
8600
|
+
while (1) {
|
|
8601
|
+
switch (_context13.prev = _context13.next) {
|
|
8602
|
+
case 0:
|
|
8603
|
+
_context13.next = 2;
|
|
8604
|
+
return this.client.post(this.client.baseURL + "/api/v2/moderation/check", {
|
|
8605
|
+
entity_type: entityType,
|
|
8606
|
+
entity_id: entityID,
|
|
8607
|
+
entity_creator_id: entityCreatorID,
|
|
8608
|
+
moderation_payload: moderationPayload,
|
|
8609
|
+
config_key: configKey,
|
|
8610
|
+
options: options
|
|
8611
|
+
});
|
|
8612
|
+
|
|
8613
|
+
case 2:
|
|
8614
|
+
return _context13.abrupt("return", _context13.sent);
|
|
8615
|
+
|
|
8616
|
+
case 3:
|
|
8617
|
+
case "end":
|
|
8618
|
+
return _context13.stop();
|
|
8619
|
+
}
|
|
8620
|
+
}
|
|
8621
|
+
}, _callee13, this);
|
|
8622
|
+
}));
|
|
8623
|
+
|
|
8624
|
+
function check(_x19, _x20, _x21, _x22, _x23, _x24) {
|
|
8625
|
+
return _check.apply(this, arguments);
|
|
8626
|
+
}
|
|
8627
|
+
|
|
8628
|
+
return check;
|
|
8629
|
+
}()
|
|
8630
|
+
}]);
|
|
8631
|
+
|
|
8632
|
+
return Moderation;
|
|
8633
|
+
}();
|
|
8634
|
+
|
|
8635
|
+
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; } } }; }
|
|
8636
|
+
|
|
8637
|
+
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); }
|
|
8638
|
+
|
|
8639
|
+
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; }
|
|
8640
|
+
|
|
8641
|
+
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; }
|
|
8642
|
+
|
|
8643
|
+
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; }
|
|
8644
|
+
var DEFAULT_CONNECTION_RECOVERY_THROTTLE_DURATION = 1000;
|
|
8645
|
+
var MAX_QUERY_THREADS_LIMIT = 25;
|
|
8646
|
+
var ThreadManager = /*#__PURE__*/function () {
|
|
8647
|
+
function ThreadManager(_ref) {
|
|
8648
|
+
var _this = this;
|
|
8432
8649
|
|
|
8433
8650
|
var client = _ref.client;
|
|
8434
8651
|
|
|
@@ -8567,7 +8784,7 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
8567
8784
|
var unsubscribeConnectionDropped = _this.client.on('connection.changed', function (event) {
|
|
8568
8785
|
if (event.online === false) {
|
|
8569
8786
|
_this.state.next(function (current) {
|
|
8570
|
-
return current.lastConnectionDropAt ? current : _objectSpread$
|
|
8787
|
+
return current.lastConnectionDropAt ? current : _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8571
8788
|
lastConnectionDropAt: new Date()
|
|
8572
8789
|
});
|
|
8573
8790
|
});
|
|
@@ -8654,213 +8871,1219 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
8654
8871
|
_context.prev = 7;
|
|
8655
8872
|
|
|
8656
8873
|
_this.state.next(function (current) {
|
|
8657
|
-
return _objectSpread$
|
|
8658
|
-
pagination: _objectSpread$
|
|
8874
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8875
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
8659
8876
|
isLoading: true
|
|
8660
8877
|
})
|
|
8661
8878
|
});
|
|
8662
8879
|
});
|
|
8663
8880
|
|
|
8664
|
-
_context.next = 11;
|
|
8665
|
-
return _this.queryThreads({
|
|
8666
|
-
limit: Math.min(limit, MAX_QUERY_THREADS_LIMIT) || MAX_QUERY_THREADS_LIMIT
|
|
8667
|
-
});
|
|
8881
|
+
_context.next = 11;
|
|
8882
|
+
return _this.queryThreads({
|
|
8883
|
+
limit: Math.min(limit, MAX_QUERY_THREADS_LIMIT) || MAX_QUERY_THREADS_LIMIT
|
|
8884
|
+
});
|
|
8885
|
+
|
|
8886
|
+
case 11:
|
|
8887
|
+
response = _context.sent;
|
|
8888
|
+
currentThreads = _this.threadsById;
|
|
8889
|
+
nextThreads = [];
|
|
8890
|
+
_iterator = _createForOfIteratorHelper$2(response.threads);
|
|
8891
|
+
|
|
8892
|
+
try {
|
|
8893
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
8894
|
+
incomingThread = _step.value;
|
|
8895
|
+
existingThread = currentThreads[incomingThread.id];
|
|
8896
|
+
|
|
8897
|
+
if (existingThread) {
|
|
8898
|
+
// Reuse thread instances if possible
|
|
8899
|
+
nextThreads.push(existingThread);
|
|
8900
|
+
|
|
8901
|
+
if (existingThread.hasStaleState) {
|
|
8902
|
+
existingThread.hydrateState(incomingThread);
|
|
8903
|
+
}
|
|
8904
|
+
} else {
|
|
8905
|
+
nextThreads.push(incomingThread);
|
|
8906
|
+
}
|
|
8907
|
+
}
|
|
8908
|
+
} catch (err) {
|
|
8909
|
+
_iterator.e(err);
|
|
8910
|
+
} finally {
|
|
8911
|
+
_iterator.f();
|
|
8912
|
+
}
|
|
8913
|
+
|
|
8914
|
+
_this.state.next(function (current) {
|
|
8915
|
+
var _response$next;
|
|
8916
|
+
|
|
8917
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8918
|
+
threads: nextThreads,
|
|
8919
|
+
unseenThreadIds: [],
|
|
8920
|
+
isThreadOrderStale: false,
|
|
8921
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
8922
|
+
isLoading: false,
|
|
8923
|
+
nextCursor: (_response$next = response.next) !== null && _response$next !== void 0 ? _response$next : null
|
|
8924
|
+
}),
|
|
8925
|
+
ready: true
|
|
8926
|
+
});
|
|
8927
|
+
});
|
|
8928
|
+
|
|
8929
|
+
_context.next = 23;
|
|
8930
|
+
break;
|
|
8931
|
+
|
|
8932
|
+
case 19:
|
|
8933
|
+
_context.prev = 19;
|
|
8934
|
+
_context.t0 = _context["catch"](7);
|
|
8935
|
+
|
|
8936
|
+
_this.client.logger('error', _context.t0.message);
|
|
8937
|
+
|
|
8938
|
+
_this.state.next(function (current) {
|
|
8939
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
8940
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
8941
|
+
isLoading: false
|
|
8942
|
+
})
|
|
8943
|
+
});
|
|
8944
|
+
});
|
|
8945
|
+
|
|
8946
|
+
case 23:
|
|
8947
|
+
case "end":
|
|
8948
|
+
return _context.stop();
|
|
8949
|
+
}
|
|
8950
|
+
}
|
|
8951
|
+
}, _callee, null, [[7, 19]]);
|
|
8952
|
+
})));
|
|
8953
|
+
|
|
8954
|
+
_defineProperty(this, "queryThreads", function () {
|
|
8955
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8956
|
+
return _this.client.queryThreads(_objectSpread$2({
|
|
8957
|
+
limit: 25,
|
|
8958
|
+
participant_limit: 10,
|
|
8959
|
+
reply_limit: 10,
|
|
8960
|
+
watch: true
|
|
8961
|
+
}, options));
|
|
8962
|
+
});
|
|
8963
|
+
|
|
8964
|
+
_defineProperty(this, "loadNextPage", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
8965
|
+
var options,
|
|
8966
|
+
_this$state$getLatest4,
|
|
8967
|
+
pagination,
|
|
8968
|
+
response,
|
|
8969
|
+
_args2 = arguments;
|
|
8970
|
+
|
|
8971
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
8972
|
+
while (1) {
|
|
8973
|
+
switch (_context2.prev = _context2.next) {
|
|
8974
|
+
case 0:
|
|
8975
|
+
options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
8976
|
+
_this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
|
|
8977
|
+
|
|
8978
|
+
if (!(pagination.isLoadingNext || !pagination.nextCursor)) {
|
|
8979
|
+
_context2.next = 4;
|
|
8980
|
+
break;
|
|
8981
|
+
}
|
|
8982
|
+
|
|
8983
|
+
return _context2.abrupt("return");
|
|
8984
|
+
|
|
8985
|
+
case 4:
|
|
8986
|
+
_context2.prev = 4;
|
|
8987
|
+
|
|
8988
|
+
_this.state.partialNext({
|
|
8989
|
+
pagination: _objectSpread$2(_objectSpread$2({}, pagination), {}, {
|
|
8990
|
+
isLoadingNext: true
|
|
8991
|
+
})
|
|
8992
|
+
});
|
|
8993
|
+
|
|
8994
|
+
_context2.next = 8;
|
|
8995
|
+
return _this.queryThreads(_objectSpread$2(_objectSpread$2({}, options), {}, {
|
|
8996
|
+
next: pagination.nextCursor
|
|
8997
|
+
}));
|
|
8998
|
+
|
|
8999
|
+
case 8:
|
|
9000
|
+
response = _context2.sent;
|
|
9001
|
+
|
|
9002
|
+
_this.state.next(function (current) {
|
|
9003
|
+
var _response$next2;
|
|
9004
|
+
|
|
9005
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
9006
|
+
threads: response.threads.length ? current.threads.concat(response.threads) : current.threads,
|
|
9007
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
9008
|
+
nextCursor: (_response$next2 = response.next) !== null && _response$next2 !== void 0 ? _response$next2 : null,
|
|
9009
|
+
isLoadingNext: false
|
|
9010
|
+
})
|
|
9011
|
+
});
|
|
9012
|
+
});
|
|
9013
|
+
|
|
9014
|
+
_context2.next = 16;
|
|
9015
|
+
break;
|
|
9016
|
+
|
|
9017
|
+
case 12:
|
|
9018
|
+
_context2.prev = 12;
|
|
9019
|
+
_context2.t0 = _context2["catch"](4);
|
|
9020
|
+
|
|
9021
|
+
_this.client.logger('error', _context2.t0.message);
|
|
9022
|
+
|
|
9023
|
+
_this.state.next(function (current) {
|
|
9024
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
9025
|
+
pagination: _objectSpread$2(_objectSpread$2({}, current.pagination), {}, {
|
|
9026
|
+
isLoadingNext: false
|
|
9027
|
+
})
|
|
9028
|
+
});
|
|
9029
|
+
});
|
|
9030
|
+
|
|
9031
|
+
case 16:
|
|
9032
|
+
case "end":
|
|
9033
|
+
return _context2.stop();
|
|
9034
|
+
}
|
|
9035
|
+
}
|
|
9036
|
+
}, _callee2, null, [[4, 12]]);
|
|
9037
|
+
})));
|
|
9038
|
+
|
|
9039
|
+
this.client = client;
|
|
9040
|
+
this.state = new StateStore({
|
|
9041
|
+
active: false,
|
|
9042
|
+
isThreadOrderStale: false,
|
|
9043
|
+
threads: [],
|
|
9044
|
+
unreadThreadCount: 0,
|
|
9045
|
+
unseenThreadIds: [],
|
|
9046
|
+
lastConnectionDropAt: null,
|
|
9047
|
+
pagination: {
|
|
9048
|
+
isLoading: false,
|
|
9049
|
+
isLoadingNext: false,
|
|
9050
|
+
nextCursor: null
|
|
9051
|
+
},
|
|
9052
|
+
ready: false
|
|
9053
|
+
});
|
|
9054
|
+
this.threadsByIdGetterCache = {
|
|
9055
|
+
threads: [],
|
|
9056
|
+
threadsById: {}
|
|
9057
|
+
};
|
|
9058
|
+
}
|
|
9059
|
+
|
|
9060
|
+
_createClass(ThreadManager, [{
|
|
9061
|
+
key: "threadsById",
|
|
9062
|
+
get: function get() {
|
|
9063
|
+
var _this$state$getLatest5 = this.state.getLatestValue(),
|
|
9064
|
+
threads = _this$state$getLatest5.threads;
|
|
9065
|
+
|
|
9066
|
+
if (threads === this.threadsByIdGetterCache.threads) {
|
|
9067
|
+
return this.threadsByIdGetterCache.threadsById;
|
|
9068
|
+
}
|
|
9069
|
+
|
|
9070
|
+
var threadsById = threads.reduce(function (newThreadsById, thread) {
|
|
9071
|
+
newThreadsById[thread.id] = thread;
|
|
9072
|
+
return newThreadsById;
|
|
9073
|
+
}, {});
|
|
9074
|
+
this.threadsByIdGetterCache.threads = threads;
|
|
9075
|
+
this.threadsByIdGetterCache.threadsById = threadsById;
|
|
9076
|
+
return threadsById;
|
|
9077
|
+
}
|
|
9078
|
+
}]);
|
|
9079
|
+
|
|
9080
|
+
return ThreadManager;
|
|
9081
|
+
}();
|
|
9082
|
+
|
|
9083
|
+
var _excluded$1 = ["own_votes", "id"],
|
|
9084
|
+
_excluded2$1 = ["id"];
|
|
9085
|
+
|
|
9086
|
+
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; }
|
|
9087
|
+
|
|
9088
|
+
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; }
|
|
9089
|
+
|
|
9090
|
+
var isPollUpdatedEvent = function isPollUpdatedEvent(e) {
|
|
9091
|
+
return e.type === 'poll.updated';
|
|
9092
|
+
};
|
|
9093
|
+
|
|
9094
|
+
var isPollClosedEventEvent = function isPollClosedEventEvent(e) {
|
|
9095
|
+
return e.type === 'poll.closed';
|
|
9096
|
+
};
|
|
9097
|
+
|
|
9098
|
+
var isPollVoteCastedEvent = function isPollVoteCastedEvent(e) {
|
|
9099
|
+
return e.type === 'poll.vote_casted';
|
|
9100
|
+
};
|
|
9101
|
+
|
|
9102
|
+
var isPollVoteChangedEvent = function isPollVoteChangedEvent(e) {
|
|
9103
|
+
return e.type === 'poll.vote_changed';
|
|
9104
|
+
};
|
|
9105
|
+
|
|
9106
|
+
var isPollVoteRemovedEvent = function isPollVoteRemovedEvent(e) {
|
|
9107
|
+
return e.type === 'poll.vote_removed';
|
|
9108
|
+
};
|
|
9109
|
+
|
|
9110
|
+
var isVoteAnswer = function isVoteAnswer(vote) {
|
|
9111
|
+
return !!(vote !== null && vote !== void 0 && vote.answer_text);
|
|
9112
|
+
};
|
|
9113
|
+
var Poll = /*#__PURE__*/function () {
|
|
9114
|
+
function Poll(_ref) {
|
|
9115
|
+
var _this = this;
|
|
9116
|
+
|
|
9117
|
+
var client = _ref.client,
|
|
9118
|
+
_poll = _ref.poll;
|
|
9119
|
+
|
|
9120
|
+
_classCallCheck(this, Poll);
|
|
9121
|
+
|
|
9122
|
+
_defineProperty(this, "state", void 0);
|
|
9123
|
+
|
|
9124
|
+
_defineProperty(this, "id", void 0);
|
|
9125
|
+
|
|
9126
|
+
_defineProperty(this, "client", void 0);
|
|
9127
|
+
|
|
9128
|
+
_defineProperty(this, "unsubscribeFunctions", new Set());
|
|
9129
|
+
|
|
9130
|
+
_defineProperty(this, "getInitialStateFromPollResponse", function (poll) {
|
|
9131
|
+
var _own_votes$reduce;
|
|
9132
|
+
|
|
9133
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9134
|
+
var own_votes = poll.own_votes;
|
|
9135
|
+
poll.id;
|
|
9136
|
+
var pollResponseForState = _objectWithoutProperties(poll, _excluded$1);
|
|
9137
|
+
|
|
9138
|
+
var _ref2 = (_own_votes$reduce = own_votes === null || own_votes === void 0 ? void 0 : own_votes.reduce(function (acc, voteOrAnswer) {
|
|
9139
|
+
if (isVoteAnswer(voteOrAnswer)) {
|
|
9140
|
+
acc.ownAnswer = voteOrAnswer;
|
|
9141
|
+
} else {
|
|
9142
|
+
acc.ownVotes.push(voteOrAnswer);
|
|
9143
|
+
}
|
|
9144
|
+
|
|
9145
|
+
return acc;
|
|
9146
|
+
}, {
|
|
9147
|
+
ownVotes: []
|
|
9148
|
+
})) !== null && _own_votes$reduce !== void 0 ? _own_votes$reduce : {
|
|
9149
|
+
ownVotes: []
|
|
9150
|
+
},
|
|
9151
|
+
ownAnswer = _ref2.ownAnswer,
|
|
9152
|
+
ownVotes = _ref2.ownVotes;
|
|
9153
|
+
|
|
9154
|
+
return _objectSpread$1(_objectSpread$1({}, pollResponseForState), {}, {
|
|
9155
|
+
lastActivityAt: new Date(),
|
|
9156
|
+
maxVotedOptionIds: getMaxVotedOptionIds(pollResponseForState.vote_counts_by_option),
|
|
9157
|
+
ownAnswer: ownAnswer,
|
|
9158
|
+
ownVotesByOptionId: getOwnVotesByOptionId(ownVotes)
|
|
9159
|
+
});
|
|
9160
|
+
});
|
|
9161
|
+
|
|
9162
|
+
_defineProperty(this, "reinitializeState", function (poll) {
|
|
9163
|
+
_this.state.partialNext(_this.getInitialStateFromPollResponse(poll));
|
|
9164
|
+
});
|
|
9165
|
+
|
|
9166
|
+
_defineProperty(this, "handlePollUpdated", function (event) {
|
|
9167
|
+
var _event$poll;
|
|
9168
|
+
|
|
9169
|
+
if ((_event$poll = event.poll) !== null && _event$poll !== void 0 && _event$poll.id && event.poll.id !== _this.id) return;
|
|
9170
|
+
if (!isPollUpdatedEvent(event)) return; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9171
|
+
|
|
9172
|
+
var _extractPollData = extractPollData(event.poll),
|
|
9173
|
+
pollData = _objectWithoutProperties(_extractPollData, _excluded2$1); // @ts-ignore
|
|
9174
|
+
|
|
9175
|
+
|
|
9176
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, pollData), {}, {
|
|
9177
|
+
lastActivityAt: new Date(event.created_at)
|
|
9178
|
+
}));
|
|
9179
|
+
});
|
|
9180
|
+
|
|
9181
|
+
_defineProperty(this, "handlePollClosed", function (event) {
|
|
9182
|
+
var _event$poll2;
|
|
9183
|
+
|
|
9184
|
+
if ((_event$poll2 = event.poll) !== null && _event$poll2 !== void 0 && _event$poll2.id && event.poll.id !== _this.id) return;
|
|
9185
|
+
if (!isPollClosedEventEvent(event)) return; // @ts-ignore
|
|
9186
|
+
|
|
9187
|
+
_this.state.partialNext({
|
|
9188
|
+
is_closed: true,
|
|
9189
|
+
lastActivityAt: new Date(event.created_at)
|
|
9190
|
+
});
|
|
9191
|
+
});
|
|
9192
|
+
|
|
9193
|
+
_defineProperty(this, "handleVoteCasted", function (event) {
|
|
9194
|
+
var _event$poll3;
|
|
9195
|
+
|
|
9196
|
+
if ((_event$poll3 = event.poll) !== null && _event$poll3 !== void 0 && _event$poll3.id && event.poll.id !== _this.id) return;
|
|
9197
|
+
if (!isPollVoteCastedEvent(event)) return;
|
|
9198
|
+
var currentState = _this.data;
|
|
9199
|
+
var isOwnVote = event.poll_vote.user_id === _this.client.userID;
|
|
9200
|
+
|
|
9201
|
+
var latestAnswers = _toConsumableArray(currentState.latest_answers);
|
|
9202
|
+
|
|
9203
|
+
var ownAnswer = currentState.ownAnswer;
|
|
9204
|
+
var ownVotesByOptionId = currentState.ownVotesByOptionId;
|
|
9205
|
+
var maxVotedOptionIds = currentState.maxVotedOptionIds;
|
|
9206
|
+
|
|
9207
|
+
if (isOwnVote) {
|
|
9208
|
+
if (isVoteAnswer(event.poll_vote)) {
|
|
9209
|
+
ownAnswer = event.poll_vote;
|
|
9210
|
+
} else if (event.poll_vote.option_id) {
|
|
9211
|
+
ownVotesByOptionId[event.poll_vote.option_id] = event.poll_vote;
|
|
9212
|
+
}
|
|
9213
|
+
}
|
|
9214
|
+
|
|
9215
|
+
if (isVoteAnswer(event.poll_vote)) {
|
|
9216
|
+
latestAnswers = [event.poll_vote].concat(_toConsumableArray(latestAnswers));
|
|
9217
|
+
} else {
|
|
9218
|
+
maxVotedOptionIds = getMaxVotedOptionIds(event.poll.vote_counts_by_option);
|
|
9219
|
+
}
|
|
9220
|
+
|
|
9221
|
+
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
9222
|
+
|
|
9223
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, pollEnrichData), {}, {
|
|
9224
|
+
latest_answers: latestAnswers,
|
|
9225
|
+
lastActivityAt: new Date(event.created_at),
|
|
9226
|
+
ownAnswer: ownAnswer,
|
|
9227
|
+
ownVotesByOptionId: ownVotesByOptionId,
|
|
9228
|
+
maxVotedOptionIds: maxVotedOptionIds
|
|
9229
|
+
}));
|
|
9230
|
+
});
|
|
9231
|
+
|
|
9232
|
+
_defineProperty(this, "handleVoteChanged", function (event) {
|
|
9233
|
+
var _event$poll4;
|
|
9234
|
+
|
|
9235
|
+
// this event is triggered only when event.poll.enforce_unique_vote === true
|
|
9236
|
+
if ((_event$poll4 = event.poll) !== null && _event$poll4 !== void 0 && _event$poll4.id && event.poll.id !== _this.id) return;
|
|
9237
|
+
if (!isPollVoteChangedEvent(event)) return;
|
|
9238
|
+
var currentState = _this.data;
|
|
9239
|
+
var isOwnVote = event.poll_vote.user_id === _this.client.userID;
|
|
9240
|
+
|
|
9241
|
+
var latestAnswers = _toConsumableArray(currentState.latest_answers);
|
|
9242
|
+
|
|
9243
|
+
var ownAnswer = currentState.ownAnswer;
|
|
9244
|
+
var ownVotesByOptionId = currentState.ownVotesByOptionId;
|
|
9245
|
+
var maxVotedOptionIds = currentState.maxVotedOptionIds;
|
|
9246
|
+
|
|
9247
|
+
if (isOwnVote) {
|
|
9248
|
+
if (isVoteAnswer(event.poll_vote)) {
|
|
9249
|
+
latestAnswers = [event.poll_vote].concat(_toConsumableArray(latestAnswers.filter(function (answer) {
|
|
9250
|
+
return answer.id !== event.poll_vote.id;
|
|
9251
|
+
})));
|
|
9252
|
+
ownAnswer = event.poll_vote;
|
|
9253
|
+
} else if (event.poll_vote.option_id) {
|
|
9254
|
+
var _ownAnswer;
|
|
9255
|
+
|
|
9256
|
+
if (event.poll.enforce_unique_votes) {
|
|
9257
|
+
ownVotesByOptionId = _defineProperty({}, event.poll_vote.option_id, event.poll_vote);
|
|
9258
|
+
} else {
|
|
9259
|
+
ownVotesByOptionId = Object.entries(ownVotesByOptionId).reduce(function (acc, _ref3) {
|
|
9260
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
9261
|
+
optionId = _ref4[0],
|
|
9262
|
+
vote = _ref4[1];
|
|
9263
|
+
|
|
9264
|
+
if (optionId !== event.poll_vote.option_id && vote.id === event.poll_vote.id) {
|
|
9265
|
+
return acc;
|
|
9266
|
+
}
|
|
9267
|
+
|
|
9268
|
+
acc[optionId] = vote;
|
|
9269
|
+
return acc;
|
|
9270
|
+
}, {});
|
|
9271
|
+
ownVotesByOptionId[event.poll_vote.option_id] = event.poll_vote;
|
|
9272
|
+
}
|
|
9273
|
+
|
|
9274
|
+
if (((_ownAnswer = ownAnswer) === null || _ownAnswer === void 0 ? void 0 : _ownAnswer.id) === event.poll_vote.id) {
|
|
9275
|
+
ownAnswer = undefined;
|
|
9276
|
+
}
|
|
9277
|
+
|
|
9278
|
+
maxVotedOptionIds = getMaxVotedOptionIds(event.poll.vote_counts_by_option);
|
|
9279
|
+
}
|
|
9280
|
+
} else if (isVoteAnswer(event.poll_vote)) {
|
|
9281
|
+
latestAnswers = [event.poll_vote].concat(_toConsumableArray(latestAnswers));
|
|
9282
|
+
} else {
|
|
9283
|
+
maxVotedOptionIds = getMaxVotedOptionIds(event.poll.vote_counts_by_option);
|
|
9284
|
+
}
|
|
9285
|
+
|
|
9286
|
+
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
9287
|
+
|
|
9288
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, pollEnrichData), {}, {
|
|
9289
|
+
latest_answers: latestAnswers,
|
|
9290
|
+
lastActivityAt: new Date(event.created_at),
|
|
9291
|
+
ownAnswer: ownAnswer,
|
|
9292
|
+
ownVotesByOptionId: ownVotesByOptionId,
|
|
9293
|
+
maxVotedOptionIds: maxVotedOptionIds
|
|
9294
|
+
}));
|
|
9295
|
+
});
|
|
9296
|
+
|
|
9297
|
+
_defineProperty(this, "handleVoteRemoved", function (event) {
|
|
9298
|
+
var _event$poll5;
|
|
9299
|
+
|
|
9300
|
+
if ((_event$poll5 = event.poll) !== null && _event$poll5 !== void 0 && _event$poll5.id && event.poll.id !== _this.id) return;
|
|
9301
|
+
if (!isPollVoteRemovedEvent(event)) return;
|
|
9302
|
+
var currentState = _this.data;
|
|
9303
|
+
var isOwnVote = event.poll_vote.user_id === _this.client.userID;
|
|
9304
|
+
|
|
9305
|
+
var latestAnswers = _toConsumableArray(currentState.latest_answers);
|
|
9306
|
+
|
|
9307
|
+
var ownAnswer = currentState.ownAnswer;
|
|
9308
|
+
|
|
9309
|
+
var ownVotesByOptionId = _objectSpread$1({}, currentState.ownVotesByOptionId);
|
|
9310
|
+
|
|
9311
|
+
var maxVotedOptionIds = currentState.maxVotedOptionIds;
|
|
9312
|
+
|
|
9313
|
+
if (isVoteAnswer(event.poll_vote)) {
|
|
9314
|
+
latestAnswers = latestAnswers.filter(function (answer) {
|
|
9315
|
+
return answer.id !== event.poll_vote.id;
|
|
9316
|
+
});
|
|
9317
|
+
|
|
9318
|
+
if (isOwnVote) {
|
|
9319
|
+
ownAnswer = undefined;
|
|
9320
|
+
}
|
|
9321
|
+
} else {
|
|
9322
|
+
maxVotedOptionIds = getMaxVotedOptionIds(event.poll.vote_counts_by_option);
|
|
9323
|
+
|
|
9324
|
+
if (isOwnVote && event.poll_vote.option_id) {
|
|
9325
|
+
delete ownVotesByOptionId[event.poll_vote.option_id];
|
|
9326
|
+
}
|
|
9327
|
+
}
|
|
9328
|
+
|
|
9329
|
+
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
9330
|
+
|
|
9331
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, pollEnrichData), {}, {
|
|
9332
|
+
latest_answers: latestAnswers,
|
|
9333
|
+
lastActivityAt: new Date(event.created_at),
|
|
9334
|
+
ownAnswer: ownAnswer,
|
|
9335
|
+
ownVotesByOptionId: ownVotesByOptionId,
|
|
9336
|
+
maxVotedOptionIds: maxVotedOptionIds
|
|
9337
|
+
}));
|
|
9338
|
+
});
|
|
9339
|
+
|
|
9340
|
+
_defineProperty(this, "query", /*#__PURE__*/function () {
|
|
9341
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id) {
|
|
9342
|
+
var _yield$_this$client$g, poll;
|
|
9343
|
+
|
|
9344
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
9345
|
+
while (1) {
|
|
9346
|
+
switch (_context.prev = _context.next) {
|
|
9347
|
+
case 0:
|
|
9348
|
+
_context.next = 2;
|
|
9349
|
+
return _this.client.getPoll(id);
|
|
9350
|
+
|
|
9351
|
+
case 2:
|
|
9352
|
+
_yield$_this$client$g = _context.sent;
|
|
9353
|
+
poll = _yield$_this$client$g.poll;
|
|
9354
|
+
|
|
9355
|
+
// @ts-ignore
|
|
9356
|
+
_this.state.partialNext(_objectSpread$1(_objectSpread$1({}, poll), {}, {
|
|
9357
|
+
lastActivityAt: new Date()
|
|
9358
|
+
}));
|
|
9359
|
+
|
|
9360
|
+
return _context.abrupt("return", poll);
|
|
9361
|
+
|
|
9362
|
+
case 6:
|
|
9363
|
+
case "end":
|
|
9364
|
+
return _context.stop();
|
|
9365
|
+
}
|
|
9366
|
+
}
|
|
9367
|
+
}, _callee);
|
|
9368
|
+
}));
|
|
9369
|
+
|
|
9370
|
+
return function (_x) {
|
|
9371
|
+
return _ref5.apply(this, arguments);
|
|
9372
|
+
};
|
|
9373
|
+
}());
|
|
9374
|
+
|
|
9375
|
+
_defineProperty(this, "update", /*#__PURE__*/function () {
|
|
9376
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
|
|
9377
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
9378
|
+
while (1) {
|
|
9379
|
+
switch (_context2.prev = _context2.next) {
|
|
9380
|
+
case 0:
|
|
9381
|
+
_context2.next = 2;
|
|
9382
|
+
return _this.client.updatePoll(_objectSpread$1(_objectSpread$1({}, data), {}, {
|
|
9383
|
+
id: _this.id
|
|
9384
|
+
}));
|
|
9385
|
+
|
|
9386
|
+
case 2:
|
|
9387
|
+
return _context2.abrupt("return", _context2.sent);
|
|
9388
|
+
|
|
9389
|
+
case 3:
|
|
9390
|
+
case "end":
|
|
9391
|
+
return _context2.stop();
|
|
9392
|
+
}
|
|
9393
|
+
}
|
|
9394
|
+
}, _callee2);
|
|
9395
|
+
}));
|
|
9396
|
+
|
|
9397
|
+
return function (_x2) {
|
|
9398
|
+
return _ref6.apply(this, arguments);
|
|
9399
|
+
};
|
|
9400
|
+
}());
|
|
9401
|
+
|
|
9402
|
+
_defineProperty(this, "partialUpdate", /*#__PURE__*/function () {
|
|
9403
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(partialPollObject) {
|
|
9404
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
9405
|
+
while (1) {
|
|
9406
|
+
switch (_context3.prev = _context3.next) {
|
|
9407
|
+
case 0:
|
|
9408
|
+
_context3.next = 2;
|
|
9409
|
+
return _this.client.partialUpdatePoll(_this.id, partialPollObject);
|
|
9410
|
+
|
|
9411
|
+
case 2:
|
|
9412
|
+
return _context3.abrupt("return", _context3.sent);
|
|
9413
|
+
|
|
9414
|
+
case 3:
|
|
9415
|
+
case "end":
|
|
9416
|
+
return _context3.stop();
|
|
9417
|
+
}
|
|
9418
|
+
}
|
|
9419
|
+
}, _callee3);
|
|
9420
|
+
}));
|
|
9421
|
+
|
|
9422
|
+
return function (_x3) {
|
|
9423
|
+
return _ref7.apply(this, arguments);
|
|
9424
|
+
};
|
|
9425
|
+
}());
|
|
9426
|
+
|
|
9427
|
+
_defineProperty(this, "close", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
9428
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
9429
|
+
while (1) {
|
|
9430
|
+
switch (_context4.prev = _context4.next) {
|
|
9431
|
+
case 0:
|
|
9432
|
+
_context4.next = 2;
|
|
9433
|
+
return _this.client.closePoll(_this.id);
|
|
9434
|
+
|
|
9435
|
+
case 2:
|
|
9436
|
+
return _context4.abrupt("return", _context4.sent);
|
|
9437
|
+
|
|
9438
|
+
case 3:
|
|
9439
|
+
case "end":
|
|
9440
|
+
return _context4.stop();
|
|
9441
|
+
}
|
|
9442
|
+
}
|
|
9443
|
+
}, _callee4);
|
|
9444
|
+
})));
|
|
9445
|
+
|
|
9446
|
+
_defineProperty(this, "delete", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
9447
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
9448
|
+
while (1) {
|
|
9449
|
+
switch (_context5.prev = _context5.next) {
|
|
9450
|
+
case 0:
|
|
9451
|
+
_context5.next = 2;
|
|
9452
|
+
return _this.client.deletePoll(_this.id);
|
|
9453
|
+
|
|
9454
|
+
case 2:
|
|
9455
|
+
return _context5.abrupt("return", _context5.sent);
|
|
9456
|
+
|
|
9457
|
+
case 3:
|
|
9458
|
+
case "end":
|
|
9459
|
+
return _context5.stop();
|
|
9460
|
+
}
|
|
9461
|
+
}
|
|
9462
|
+
}, _callee5);
|
|
9463
|
+
})));
|
|
9464
|
+
|
|
9465
|
+
_defineProperty(this, "createOption", /*#__PURE__*/function () {
|
|
9466
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(option) {
|
|
9467
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
9468
|
+
while (1) {
|
|
9469
|
+
switch (_context6.prev = _context6.next) {
|
|
9470
|
+
case 0:
|
|
9471
|
+
_context6.next = 2;
|
|
9472
|
+
return _this.client.createPollOption(_this.id, option);
|
|
9473
|
+
|
|
9474
|
+
case 2:
|
|
9475
|
+
return _context6.abrupt("return", _context6.sent);
|
|
9476
|
+
|
|
9477
|
+
case 3:
|
|
9478
|
+
case "end":
|
|
9479
|
+
return _context6.stop();
|
|
9480
|
+
}
|
|
9481
|
+
}
|
|
9482
|
+
}, _callee6);
|
|
9483
|
+
}));
|
|
9484
|
+
|
|
9485
|
+
return function (_x4) {
|
|
9486
|
+
return _ref10.apply(this, arguments);
|
|
9487
|
+
};
|
|
9488
|
+
}());
|
|
9489
|
+
|
|
9490
|
+
_defineProperty(this, "updateOption", /*#__PURE__*/function () {
|
|
9491
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(option) {
|
|
9492
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
9493
|
+
while (1) {
|
|
9494
|
+
switch (_context7.prev = _context7.next) {
|
|
9495
|
+
case 0:
|
|
9496
|
+
_context7.next = 2;
|
|
9497
|
+
return _this.client.updatePollOption(_this.id, option);
|
|
9498
|
+
|
|
9499
|
+
case 2:
|
|
9500
|
+
return _context7.abrupt("return", _context7.sent);
|
|
9501
|
+
|
|
9502
|
+
case 3:
|
|
9503
|
+
case "end":
|
|
9504
|
+
return _context7.stop();
|
|
9505
|
+
}
|
|
9506
|
+
}
|
|
9507
|
+
}, _callee7);
|
|
9508
|
+
}));
|
|
9509
|
+
|
|
9510
|
+
return function (_x5) {
|
|
9511
|
+
return _ref11.apply(this, arguments);
|
|
9512
|
+
};
|
|
9513
|
+
}());
|
|
9514
|
+
|
|
9515
|
+
_defineProperty(this, "deleteOption", /*#__PURE__*/function () {
|
|
9516
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(optionId) {
|
|
9517
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
9518
|
+
while (1) {
|
|
9519
|
+
switch (_context8.prev = _context8.next) {
|
|
9520
|
+
case 0:
|
|
9521
|
+
_context8.next = 2;
|
|
9522
|
+
return _this.client.deletePollOption(_this.id, optionId);
|
|
9523
|
+
|
|
9524
|
+
case 2:
|
|
9525
|
+
return _context8.abrupt("return", _context8.sent);
|
|
9526
|
+
|
|
9527
|
+
case 3:
|
|
9528
|
+
case "end":
|
|
9529
|
+
return _context8.stop();
|
|
9530
|
+
}
|
|
9531
|
+
}
|
|
9532
|
+
}, _callee8);
|
|
9533
|
+
}));
|
|
9534
|
+
|
|
9535
|
+
return function (_x6) {
|
|
9536
|
+
return _ref12.apply(this, arguments);
|
|
9537
|
+
};
|
|
9538
|
+
}());
|
|
9539
|
+
|
|
9540
|
+
_defineProperty(this, "castVote", /*#__PURE__*/function () {
|
|
9541
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(optionId, messageId) {
|
|
9542
|
+
var _this$data, max_votes_allowed, ownVotesByOptionId, reachedVoteLimit, _oldestVote2, oldestVote;
|
|
9543
|
+
|
|
9544
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
9545
|
+
while (1) {
|
|
9546
|
+
switch (_context9.prev = _context9.next) {
|
|
9547
|
+
case 0:
|
|
9548
|
+
_this$data = _this.data, max_votes_allowed = _this$data.max_votes_allowed, ownVotesByOptionId = _this$data.ownVotesByOptionId;
|
|
9549
|
+
reachedVoteLimit = max_votes_allowed && max_votes_allowed === Object.keys(ownVotesByOptionId).length;
|
|
9550
|
+
|
|
9551
|
+
if (!reachedVoteLimit) {
|
|
9552
|
+
_context9.next = 8;
|
|
9553
|
+
break;
|
|
9554
|
+
}
|
|
9555
|
+
|
|
9556
|
+
oldestVote = Object.values(ownVotesByOptionId)[0];
|
|
9557
|
+
Object.values(ownVotesByOptionId).slice(1).forEach(function (vote) {
|
|
9558
|
+
var _oldestVote;
|
|
9559
|
+
|
|
9560
|
+
if (!((_oldestVote = oldestVote) !== null && _oldestVote !== void 0 && _oldestVote.created_at) || new Date(vote.created_at) < new Date(oldestVote.created_at)) {
|
|
9561
|
+
oldestVote = vote;
|
|
9562
|
+
}
|
|
9563
|
+
});
|
|
9564
|
+
|
|
9565
|
+
if (!((_oldestVote2 = oldestVote) !== null && _oldestVote2 !== void 0 && _oldestVote2.id)) {
|
|
9566
|
+
_context9.next = 8;
|
|
9567
|
+
break;
|
|
9568
|
+
}
|
|
9569
|
+
|
|
9570
|
+
_context9.next = 8;
|
|
9571
|
+
return _this.removeVote(oldestVote.id, messageId);
|
|
9572
|
+
|
|
9573
|
+
case 8:
|
|
9574
|
+
_context9.next = 10;
|
|
9575
|
+
return _this.client.castPollVote(messageId, _this.id, {
|
|
9576
|
+
option_id: optionId
|
|
9577
|
+
});
|
|
9578
|
+
|
|
9579
|
+
case 10:
|
|
9580
|
+
return _context9.abrupt("return", _context9.sent);
|
|
9581
|
+
|
|
9582
|
+
case 11:
|
|
9583
|
+
case "end":
|
|
9584
|
+
return _context9.stop();
|
|
9585
|
+
}
|
|
9586
|
+
}
|
|
9587
|
+
}, _callee9);
|
|
9588
|
+
}));
|
|
9589
|
+
|
|
9590
|
+
return function (_x7, _x8) {
|
|
9591
|
+
return _ref13.apply(this, arguments);
|
|
9592
|
+
};
|
|
9593
|
+
}());
|
|
9594
|
+
|
|
9595
|
+
_defineProperty(this, "removeVote", /*#__PURE__*/function () {
|
|
9596
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(voteId, messageId) {
|
|
9597
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
9598
|
+
while (1) {
|
|
9599
|
+
switch (_context10.prev = _context10.next) {
|
|
9600
|
+
case 0:
|
|
9601
|
+
_context10.next = 2;
|
|
9602
|
+
return _this.client.removePollVote(messageId, _this.id, voteId);
|
|
9603
|
+
|
|
9604
|
+
case 2:
|
|
9605
|
+
return _context10.abrupt("return", _context10.sent);
|
|
9606
|
+
|
|
9607
|
+
case 3:
|
|
9608
|
+
case "end":
|
|
9609
|
+
return _context10.stop();
|
|
9610
|
+
}
|
|
9611
|
+
}
|
|
9612
|
+
}, _callee10);
|
|
9613
|
+
}));
|
|
9614
|
+
|
|
9615
|
+
return function (_x9, _x10) {
|
|
9616
|
+
return _ref14.apply(this, arguments);
|
|
9617
|
+
};
|
|
9618
|
+
}());
|
|
9619
|
+
|
|
9620
|
+
_defineProperty(this, "addAnswer", /*#__PURE__*/function () {
|
|
9621
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(answerText, messageId) {
|
|
9622
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
9623
|
+
while (1) {
|
|
9624
|
+
switch (_context11.prev = _context11.next) {
|
|
9625
|
+
case 0:
|
|
9626
|
+
_context11.next = 2;
|
|
9627
|
+
return _this.client.addPollAnswer(messageId, _this.id, answerText);
|
|
9628
|
+
|
|
9629
|
+
case 2:
|
|
9630
|
+
return _context11.abrupt("return", _context11.sent);
|
|
9631
|
+
|
|
9632
|
+
case 3:
|
|
9633
|
+
case "end":
|
|
9634
|
+
return _context11.stop();
|
|
9635
|
+
}
|
|
9636
|
+
}
|
|
9637
|
+
}, _callee11);
|
|
9638
|
+
}));
|
|
9639
|
+
|
|
9640
|
+
return function (_x11, _x12) {
|
|
9641
|
+
return _ref15.apply(this, arguments);
|
|
9642
|
+
};
|
|
9643
|
+
}());
|
|
9644
|
+
|
|
9645
|
+
_defineProperty(this, "removeAnswer", /*#__PURE__*/function () {
|
|
9646
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(answerId, messageId) {
|
|
9647
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
9648
|
+
while (1) {
|
|
9649
|
+
switch (_context12.prev = _context12.next) {
|
|
9650
|
+
case 0:
|
|
9651
|
+
_context12.next = 2;
|
|
9652
|
+
return _this.client.removePollVote(messageId, _this.id, answerId);
|
|
9653
|
+
|
|
9654
|
+
case 2:
|
|
9655
|
+
return _context12.abrupt("return", _context12.sent);
|
|
9656
|
+
|
|
9657
|
+
case 3:
|
|
9658
|
+
case "end":
|
|
9659
|
+
return _context12.stop();
|
|
9660
|
+
}
|
|
9661
|
+
}
|
|
9662
|
+
}, _callee12);
|
|
9663
|
+
}));
|
|
9664
|
+
|
|
9665
|
+
return function (_x13, _x14) {
|
|
9666
|
+
return _ref16.apply(this, arguments);
|
|
9667
|
+
};
|
|
9668
|
+
}());
|
|
9669
|
+
|
|
9670
|
+
_defineProperty(this, "queryAnswers", /*#__PURE__*/function () {
|
|
9671
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(params) {
|
|
9672
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
9673
|
+
while (1) {
|
|
9674
|
+
switch (_context13.prev = _context13.next) {
|
|
9675
|
+
case 0:
|
|
9676
|
+
_context13.next = 2;
|
|
9677
|
+
return _this.client.queryPollAnswers(_this.id, params.filter, params.sort, params.options);
|
|
9678
|
+
|
|
9679
|
+
case 2:
|
|
9680
|
+
return _context13.abrupt("return", _context13.sent);
|
|
9681
|
+
|
|
9682
|
+
case 3:
|
|
9683
|
+
case "end":
|
|
9684
|
+
return _context13.stop();
|
|
9685
|
+
}
|
|
9686
|
+
}
|
|
9687
|
+
}, _callee13);
|
|
9688
|
+
}));
|
|
9689
|
+
|
|
9690
|
+
return function (_x15) {
|
|
9691
|
+
return _ref17.apply(this, arguments);
|
|
9692
|
+
};
|
|
9693
|
+
}());
|
|
9694
|
+
|
|
9695
|
+
_defineProperty(this, "queryOptionVotes", /*#__PURE__*/function () {
|
|
9696
|
+
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(params) {
|
|
9697
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
9698
|
+
while (1) {
|
|
9699
|
+
switch (_context14.prev = _context14.next) {
|
|
9700
|
+
case 0:
|
|
9701
|
+
_context14.next = 2;
|
|
9702
|
+
return _this.client.queryPollVotes(_this.id, params.filter, params.sort, params.options);
|
|
9703
|
+
|
|
9704
|
+
case 2:
|
|
9705
|
+
return _context14.abrupt("return", _context14.sent);
|
|
9706
|
+
|
|
9707
|
+
case 3:
|
|
9708
|
+
case "end":
|
|
9709
|
+
return _context14.stop();
|
|
9710
|
+
}
|
|
9711
|
+
}
|
|
9712
|
+
}, _callee14);
|
|
9713
|
+
}));
|
|
9714
|
+
|
|
9715
|
+
return function (_x16) {
|
|
9716
|
+
return _ref18.apply(this, arguments);
|
|
9717
|
+
};
|
|
9718
|
+
}());
|
|
9719
|
+
|
|
9720
|
+
this.client = client;
|
|
9721
|
+
this.id = _poll.id;
|
|
9722
|
+
this.state = new StateStore(this.getInitialStateFromPollResponse(_poll));
|
|
9723
|
+
}
|
|
9724
|
+
|
|
9725
|
+
_createClass(Poll, [{
|
|
9726
|
+
key: "data",
|
|
9727
|
+
get: function get() {
|
|
9728
|
+
return this.state.getLatestValue();
|
|
9729
|
+
}
|
|
9730
|
+
}]);
|
|
9731
|
+
|
|
9732
|
+
return Poll;
|
|
9733
|
+
}();
|
|
9734
|
+
|
|
9735
|
+
function getMaxVotedOptionIds(voteCountsByOption) {
|
|
9736
|
+
var maxVotes = 0;
|
|
9737
|
+
var winningOptions = [];
|
|
9738
|
+
|
|
9739
|
+
for (var _i = 0, _Object$entries = Object.entries(voteCountsByOption !== null && voteCountsByOption !== void 0 ? voteCountsByOption : {}); _i < _Object$entries.length; _i++) {
|
|
9740
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
9741
|
+
id = _Object$entries$_i[0],
|
|
9742
|
+
count = _Object$entries$_i[1];
|
|
9743
|
+
|
|
9744
|
+
if (count > maxVotes) {
|
|
9745
|
+
winningOptions = [id];
|
|
9746
|
+
maxVotes = count;
|
|
9747
|
+
} else if (count === maxVotes) {
|
|
9748
|
+
winningOptions.push(id);
|
|
9749
|
+
}
|
|
9750
|
+
}
|
|
9751
|
+
|
|
9752
|
+
return winningOptions;
|
|
9753
|
+
}
|
|
9754
|
+
|
|
9755
|
+
function getOwnVotesByOptionId(ownVotes) {
|
|
9756
|
+
return !ownVotes ? {} : ownVotes.reduce(function (acc, vote) {
|
|
9757
|
+
if (isVoteAnswer(vote) || !vote.option_id) return acc;
|
|
9758
|
+
acc[vote.option_id] = vote;
|
|
9759
|
+
return acc;
|
|
9760
|
+
}, {});
|
|
9761
|
+
}
|
|
9762
|
+
|
|
9763
|
+
function extractPollData(pollResponse) {
|
|
9764
|
+
return {
|
|
9765
|
+
allow_answers: pollResponse.allow_answers,
|
|
9766
|
+
allow_user_suggested_options: pollResponse.allow_user_suggested_options,
|
|
9767
|
+
description: pollResponse.description,
|
|
9768
|
+
enforce_unique_vote: pollResponse.enforce_unique_vote,
|
|
9769
|
+
id: pollResponse.id,
|
|
9770
|
+
is_closed: pollResponse.is_closed,
|
|
9771
|
+
max_votes_allowed: pollResponse.max_votes_allowed,
|
|
9772
|
+
name: pollResponse.name,
|
|
9773
|
+
options: pollResponse.options,
|
|
9774
|
+
voting_visibility: pollResponse.voting_visibility
|
|
9775
|
+
};
|
|
9776
|
+
}
|
|
9777
|
+
function extractPollEnrichedData(pollResponse) {
|
|
9778
|
+
return {
|
|
9779
|
+
answers_count: pollResponse.answers_count,
|
|
9780
|
+
latest_votes_by_option: pollResponse.latest_votes_by_option,
|
|
9781
|
+
vote_count: pollResponse.vote_count,
|
|
9782
|
+
vote_counts_by_option: pollResponse.vote_counts_by_option
|
|
9783
|
+
};
|
|
9784
|
+
}
|
|
9785
|
+
|
|
9786
|
+
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; } } }; }
|
|
9787
|
+
|
|
9788
|
+
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); }
|
|
9789
|
+
|
|
9790
|
+
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; }
|
|
9791
|
+
var PollManager = /*#__PURE__*/function () {
|
|
9792
|
+
// The pollCache contains only polls that have been created and sent as messages
|
|
9793
|
+
// (i.e only polls that are coupled with a message, can be voted on and require a
|
|
9794
|
+
// reactive state). It shall work as a basic look-up table for our SDK to be able
|
|
9795
|
+
// to quickly consume poll state that will be reactive even without the polls being
|
|
9796
|
+
// rendered within the UI.
|
|
9797
|
+
function PollManager(_ref) {
|
|
9798
|
+
var _this = this;
|
|
9799
|
+
|
|
9800
|
+
var client = _ref.client;
|
|
9801
|
+
|
|
9802
|
+
_classCallCheck(this, PollManager);
|
|
9803
|
+
|
|
9804
|
+
_defineProperty(this, "client", void 0);
|
|
9805
|
+
|
|
9806
|
+
_defineProperty(this, "pollCache", new Map());
|
|
9807
|
+
|
|
9808
|
+
_defineProperty(this, "unsubscribeFunctions", new Set());
|
|
9809
|
+
|
|
9810
|
+
_defineProperty(this, "fromState", function (id) {
|
|
9811
|
+
return _this.pollCache.get(id);
|
|
9812
|
+
});
|
|
9813
|
+
|
|
9814
|
+
_defineProperty(this, "registerSubscriptions", function () {
|
|
9815
|
+
if (_this.unsubscribeFunctions.size) {
|
|
9816
|
+
// Already listening for events and changes
|
|
9817
|
+
return;
|
|
9818
|
+
}
|
|
9819
|
+
|
|
9820
|
+
_this.unsubscribeFunctions.add(_this.subscribeMessageNew());
|
|
9821
|
+
|
|
9822
|
+
_this.unsubscribeFunctions.add(_this.subscribePollUpdated());
|
|
9823
|
+
|
|
9824
|
+
_this.unsubscribeFunctions.add(_this.subscribePollClosed());
|
|
9825
|
+
|
|
9826
|
+
_this.unsubscribeFunctions.add(_this.subscribeVoteCasted());
|
|
9827
|
+
|
|
9828
|
+
_this.unsubscribeFunctions.add(_this.subscribeVoteChanged());
|
|
9829
|
+
|
|
9830
|
+
_this.unsubscribeFunctions.add(_this.subscribeVoteRemoved());
|
|
9831
|
+
});
|
|
9832
|
+
|
|
9833
|
+
_defineProperty(this, "unregisterSubscriptions", function () {
|
|
9834
|
+
_this.unsubscribeFunctions.forEach(function (cleanupFunction) {
|
|
9835
|
+
return cleanupFunction();
|
|
9836
|
+
});
|
|
9837
|
+
|
|
9838
|
+
_this.unsubscribeFunctions.clear();
|
|
9839
|
+
});
|
|
9840
|
+
|
|
9841
|
+
_defineProperty(this, "createPoll", /*#__PURE__*/function () {
|
|
9842
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(poll) {
|
|
9843
|
+
var _yield$_this$client$c, createdPoll;
|
|
9844
|
+
|
|
9845
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
9846
|
+
while (1) {
|
|
9847
|
+
switch (_context.prev = _context.next) {
|
|
9848
|
+
case 0:
|
|
9849
|
+
_context.next = 2;
|
|
9850
|
+
return _this.client.createPoll(poll);
|
|
9851
|
+
|
|
9852
|
+
case 2:
|
|
9853
|
+
_yield$_this$client$c = _context.sent;
|
|
9854
|
+
createdPoll = _yield$_this$client$c.poll;
|
|
9855
|
+
return _context.abrupt("return", new Poll({
|
|
9856
|
+
client: _this.client,
|
|
9857
|
+
poll: createdPoll
|
|
9858
|
+
}));
|
|
9859
|
+
|
|
9860
|
+
case 5:
|
|
9861
|
+
case "end":
|
|
9862
|
+
return _context.stop();
|
|
9863
|
+
}
|
|
9864
|
+
}
|
|
9865
|
+
}, _callee);
|
|
9866
|
+
}));
|
|
9867
|
+
|
|
9868
|
+
return function (_x) {
|
|
9869
|
+
return _ref2.apply(this, arguments);
|
|
9870
|
+
};
|
|
9871
|
+
}());
|
|
9872
|
+
|
|
9873
|
+
_defineProperty(this, "getPoll", /*#__PURE__*/function () {
|
|
9874
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id) {
|
|
9875
|
+
var cachedPoll, _yield$_this$client$g, poll;
|
|
9876
|
+
|
|
9877
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
9878
|
+
while (1) {
|
|
9879
|
+
switch (_context2.prev = _context2.next) {
|
|
9880
|
+
case 0:
|
|
9881
|
+
cachedPoll = _this.fromState(id); // optimistically return the cached poll if it exists and update in the background
|
|
9882
|
+
|
|
9883
|
+
if (!cachedPoll) {
|
|
9884
|
+
_context2.next = 4;
|
|
9885
|
+
break;
|
|
9886
|
+
}
|
|
9887
|
+
|
|
9888
|
+
_this.client.getPoll(id).then(function (_ref4) {
|
|
9889
|
+
var poll = _ref4.poll;
|
|
9890
|
+
return _this.setOrOverwriteInCache(poll, true);
|
|
9891
|
+
});
|
|
9892
|
+
|
|
9893
|
+
return _context2.abrupt("return", cachedPoll);
|
|
9894
|
+
|
|
9895
|
+
case 4:
|
|
9896
|
+
_context2.next = 6;
|
|
9897
|
+
return _this.client.getPoll(id);
|
|
9898
|
+
|
|
9899
|
+
case 6:
|
|
9900
|
+
_yield$_this$client$g = _context2.sent;
|
|
9901
|
+
poll = _yield$_this$client$g.poll;
|
|
9902
|
+
|
|
9903
|
+
_this.setOrOverwriteInCache(poll);
|
|
9904
|
+
|
|
9905
|
+
return _context2.abrupt("return", _this.fromState(id));
|
|
9906
|
+
|
|
9907
|
+
case 10:
|
|
9908
|
+
case "end":
|
|
9909
|
+
return _context2.stop();
|
|
9910
|
+
}
|
|
9911
|
+
}
|
|
9912
|
+
}, _callee2);
|
|
9913
|
+
}));
|
|
9914
|
+
|
|
9915
|
+
return function (_x2) {
|
|
9916
|
+
return _ref3.apply(this, arguments);
|
|
9917
|
+
};
|
|
9918
|
+
}());
|
|
9919
|
+
|
|
9920
|
+
_defineProperty(this, "queryPolls", /*#__PURE__*/function () {
|
|
9921
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(filter) {
|
|
9922
|
+
var sort,
|
|
9923
|
+
options,
|
|
9924
|
+
_yield$_this$client$q,
|
|
9925
|
+
polls,
|
|
9926
|
+
next,
|
|
9927
|
+
pollInstances,
|
|
9928
|
+
_args3 = arguments;
|
|
9929
|
+
|
|
9930
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
9931
|
+
while (1) {
|
|
9932
|
+
switch (_context3.prev = _context3.next) {
|
|
9933
|
+
case 0:
|
|
9934
|
+
sort = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : [];
|
|
9935
|
+
options = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
|
|
9936
|
+
_context3.next = 4;
|
|
9937
|
+
return _this.client.queryPolls(filter, sort, options);
|
|
9938
|
+
|
|
9939
|
+
case 4:
|
|
9940
|
+
_yield$_this$client$q = _context3.sent;
|
|
9941
|
+
polls = _yield$_this$client$q.polls;
|
|
9942
|
+
next = _yield$_this$client$q.next;
|
|
9943
|
+
pollInstances = polls.map(function (poll) {
|
|
9944
|
+
_this.setOrOverwriteInCache(poll, true);
|
|
9945
|
+
|
|
9946
|
+
return _this.fromState(poll.id);
|
|
9947
|
+
});
|
|
9948
|
+
return _context3.abrupt("return", {
|
|
9949
|
+
polls: pollInstances,
|
|
9950
|
+
next: next
|
|
9951
|
+
});
|
|
9952
|
+
|
|
9953
|
+
case 9:
|
|
9954
|
+
case "end":
|
|
9955
|
+
return _context3.stop();
|
|
9956
|
+
}
|
|
9957
|
+
}
|
|
9958
|
+
}, _callee3);
|
|
9959
|
+
}));
|
|
9960
|
+
|
|
9961
|
+
return function (_x3) {
|
|
9962
|
+
return _ref5.apply(this, arguments);
|
|
9963
|
+
};
|
|
9964
|
+
}());
|
|
8668
9965
|
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
nextThreads = [];
|
|
8673
|
-
_iterator = _createForOfIteratorHelper$1(response.threads);
|
|
9966
|
+
_defineProperty(this, "hydratePollCache", function (messages, overwriteState) {
|
|
9967
|
+
var _iterator = _createForOfIteratorHelper$1(messages),
|
|
9968
|
+
_step;
|
|
8674
9969
|
|
|
8675
|
-
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
existingThread = currentThreads[incomingThread.id];
|
|
9970
|
+
try {
|
|
9971
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
9972
|
+
var message = _step.value;
|
|
8679
9973
|
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
9974
|
+
if (!message.poll) {
|
|
9975
|
+
continue;
|
|
9976
|
+
}
|
|
8683
9977
|
|
|
8684
|
-
|
|
8685
|
-
existingThread.hydrateState(incomingThread);
|
|
8686
|
-
}
|
|
8687
|
-
} else {
|
|
8688
|
-
nextThreads.push(incomingThread);
|
|
8689
|
-
}
|
|
8690
|
-
}
|
|
8691
|
-
} catch (err) {
|
|
8692
|
-
_iterator.e(err);
|
|
8693
|
-
} finally {
|
|
8694
|
-
_iterator.f();
|
|
8695
|
-
}
|
|
9978
|
+
var pollResponse = message.poll;
|
|
8696
9979
|
|
|
8697
|
-
|
|
8698
|
-
|
|
9980
|
+
_this.setOrOverwriteInCache(pollResponse, overwriteState);
|
|
9981
|
+
}
|
|
9982
|
+
} catch (err) {
|
|
9983
|
+
_iterator.e(err);
|
|
9984
|
+
} finally {
|
|
9985
|
+
_iterator.f();
|
|
9986
|
+
}
|
|
9987
|
+
});
|
|
8699
9988
|
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
unseenThreadIds: [],
|
|
8703
|
-
isThreadOrderStale: false,
|
|
8704
|
-
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8705
|
-
isLoading: false,
|
|
8706
|
-
nextCursor: (_response$next = response.next) !== null && _response$next !== void 0 ? _response$next : null
|
|
8707
|
-
}),
|
|
8708
|
-
ready: true
|
|
8709
|
-
});
|
|
8710
|
-
});
|
|
9989
|
+
_defineProperty(this, "setOrOverwriteInCache", function (pollResponse, overwriteState) {
|
|
9990
|
+
var pollFromCache = _this.fromState(pollResponse.id);
|
|
8711
9991
|
|
|
8712
|
-
|
|
8713
|
-
|
|
9992
|
+
if (!pollFromCache) {
|
|
9993
|
+
var poll = new Poll({
|
|
9994
|
+
client: _this.client,
|
|
9995
|
+
poll: pollResponse
|
|
9996
|
+
});
|
|
8714
9997
|
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
9998
|
+
_this.pollCache.set(poll.id, poll);
|
|
9999
|
+
} else if (overwriteState) {
|
|
10000
|
+
pollFromCache.reinitializeState(pollResponse);
|
|
10001
|
+
}
|
|
10002
|
+
});
|
|
8718
10003
|
|
|
8719
|
-
|
|
10004
|
+
_defineProperty(this, "subscribePollUpdated", function () {
|
|
10005
|
+
return _this.client.on('poll.updated', function (event) {
|
|
10006
|
+
var _event$poll;
|
|
8720
10007
|
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8724
|
-
isLoading: false
|
|
8725
|
-
})
|
|
8726
|
-
});
|
|
8727
|
-
});
|
|
10008
|
+
if ((_event$poll = event.poll) !== null && _event$poll !== void 0 && _event$poll.id) {
|
|
10009
|
+
var _this$fromState;
|
|
8728
10010
|
|
|
8729
|
-
|
|
8730
|
-
case "end":
|
|
8731
|
-
return _context.stop();
|
|
8732
|
-
}
|
|
10011
|
+
(_this$fromState = _this.fromState(event.poll.id)) === null || _this$fromState === void 0 ? void 0 : _this$fromState.handlePollUpdated(event);
|
|
8733
10012
|
}
|
|
8734
|
-
}
|
|
8735
|
-
})));
|
|
8736
|
-
|
|
8737
|
-
_defineProperty(this, "queryThreads", function () {
|
|
8738
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8739
|
-
return _this.client.queryThreads(_objectSpread$1({
|
|
8740
|
-
limit: 25,
|
|
8741
|
-
participant_limit: 10,
|
|
8742
|
-
reply_limit: 10,
|
|
8743
|
-
watch: true
|
|
8744
|
-
}, options));
|
|
10013
|
+
}).unsubscribe;
|
|
8745
10014
|
});
|
|
8746
10015
|
|
|
8747
|
-
_defineProperty(this, "
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
pagination,
|
|
8751
|
-
response,
|
|
8752
|
-
_args2 = arguments;
|
|
10016
|
+
_defineProperty(this, "subscribePollClosed", function () {
|
|
10017
|
+
return _this.client.on('poll.closed', function (event) {
|
|
10018
|
+
var _event$poll2;
|
|
8753
10019
|
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
switch (_context2.prev = _context2.next) {
|
|
8757
|
-
case 0:
|
|
8758
|
-
options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
8759
|
-
_this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
|
|
10020
|
+
if ((_event$poll2 = event.poll) !== null && _event$poll2 !== void 0 && _event$poll2.id) {
|
|
10021
|
+
var _this$fromState2;
|
|
8760
10022
|
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
10023
|
+
(_this$fromState2 = _this.fromState(event.poll.id)) === null || _this$fromState2 === void 0 ? void 0 : _this$fromState2.handlePollClosed(event);
|
|
10024
|
+
}
|
|
10025
|
+
}).unsubscribe;
|
|
10026
|
+
});
|
|
8765
10027
|
|
|
8766
|
-
|
|
10028
|
+
_defineProperty(this, "subscribeVoteCasted", function () {
|
|
10029
|
+
return _this.client.on('poll.vote_casted', function (event) {
|
|
10030
|
+
var _event$poll3;
|
|
8767
10031
|
|
|
8768
|
-
|
|
8769
|
-
|
|
10032
|
+
if ((_event$poll3 = event.poll) !== null && _event$poll3 !== void 0 && _event$poll3.id) {
|
|
10033
|
+
var _this$fromState3;
|
|
8770
10034
|
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
});
|
|
10035
|
+
(_this$fromState3 = _this.fromState(event.poll.id)) === null || _this$fromState3 === void 0 ? void 0 : _this$fromState3.handleVoteCasted(event);
|
|
10036
|
+
}
|
|
10037
|
+
}).unsubscribe;
|
|
10038
|
+
});
|
|
8776
10039
|
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
}));
|
|
10040
|
+
_defineProperty(this, "subscribeVoteChanged", function () {
|
|
10041
|
+
return _this.client.on('poll.vote_changed', function (event) {
|
|
10042
|
+
var _event$poll4;
|
|
8781
10043
|
|
|
8782
|
-
|
|
8783
|
-
|
|
10044
|
+
if ((_event$poll4 = event.poll) !== null && _event$poll4 !== void 0 && _event$poll4.id) {
|
|
10045
|
+
var _this$fromState4;
|
|
8784
10046
|
|
|
8785
|
-
|
|
8786
|
-
|
|
10047
|
+
(_this$fromState4 = _this.fromState(event.poll.id)) === null || _this$fromState4 === void 0 ? void 0 : _this$fromState4.handleVoteChanged(event);
|
|
10048
|
+
}
|
|
10049
|
+
}).unsubscribe;
|
|
10050
|
+
});
|
|
8787
10051
|
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
nextCursor: (_response$next2 = response.next) !== null && _response$next2 !== void 0 ? _response$next2 : null,
|
|
8792
|
-
isLoadingNext: false
|
|
8793
|
-
})
|
|
8794
|
-
});
|
|
8795
|
-
});
|
|
10052
|
+
_defineProperty(this, "subscribeVoteRemoved", function () {
|
|
10053
|
+
return _this.client.on('poll.vote_removed', function (event) {
|
|
10054
|
+
var _event$poll5;
|
|
8796
10055
|
|
|
8797
|
-
|
|
8798
|
-
|
|
10056
|
+
if ((_event$poll5 = event.poll) !== null && _event$poll5 !== void 0 && _event$poll5.id) {
|
|
10057
|
+
var _this$fromState5;
|
|
8799
10058
|
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
10059
|
+
(_this$fromState5 = _this.fromState(event.poll.id)) === null || _this$fromState5 === void 0 ? void 0 : _this$fromState5.handleVoteRemoved(event);
|
|
10060
|
+
}
|
|
10061
|
+
}).unsubscribe;
|
|
10062
|
+
});
|
|
8803
10063
|
|
|
8804
|
-
|
|
10064
|
+
_defineProperty(this, "subscribeMessageNew", function () {
|
|
10065
|
+
return _this.client.on('message.new', function (event) {
|
|
10066
|
+
var message = event.message;
|
|
8805
10067
|
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8809
|
-
isLoadingNext: false
|
|
8810
|
-
})
|
|
8811
|
-
});
|
|
8812
|
-
});
|
|
10068
|
+
if (message) {
|
|
10069
|
+
var formattedMessage = formatMessage(message);
|
|
8813
10070
|
|
|
8814
|
-
|
|
8815
|
-
case "end":
|
|
8816
|
-
return _context2.stop();
|
|
8817
|
-
}
|
|
10071
|
+
_this.hydratePollCache([formattedMessage]);
|
|
8818
10072
|
}
|
|
8819
|
-
}
|
|
8820
|
-
})
|
|
10073
|
+
}).unsubscribe;
|
|
10074
|
+
});
|
|
8821
10075
|
|
|
8822
10076
|
this.client = client;
|
|
8823
|
-
this.state = new StateStore({
|
|
8824
|
-
active: false,
|
|
8825
|
-
isThreadOrderStale: false,
|
|
8826
|
-
threads: [],
|
|
8827
|
-
unreadThreadCount: 0,
|
|
8828
|
-
unseenThreadIds: [],
|
|
8829
|
-
lastConnectionDropAt: null,
|
|
8830
|
-
pagination: {
|
|
8831
|
-
isLoading: false,
|
|
8832
|
-
isLoadingNext: false,
|
|
8833
|
-
nextCursor: null
|
|
8834
|
-
},
|
|
8835
|
-
ready: false
|
|
8836
|
-
});
|
|
8837
|
-
this.threadsByIdGetterCache = {
|
|
8838
|
-
threads: [],
|
|
8839
|
-
threadsById: {}
|
|
8840
|
-
};
|
|
8841
10077
|
}
|
|
8842
10078
|
|
|
8843
|
-
_createClass(
|
|
8844
|
-
key: "
|
|
10079
|
+
_createClass(PollManager, [{
|
|
10080
|
+
key: "data",
|
|
8845
10081
|
get: function get() {
|
|
8846
|
-
|
|
8847
|
-
threads = _this$state$getLatest5.threads;
|
|
8848
|
-
|
|
8849
|
-
if (threads === this.threadsByIdGetterCache.threads) {
|
|
8850
|
-
return this.threadsByIdGetterCache.threadsById;
|
|
8851
|
-
}
|
|
8852
|
-
|
|
8853
|
-
var threadsById = threads.reduce(function (newThreadsById, thread) {
|
|
8854
|
-
newThreadsById[thread.id] = thread;
|
|
8855
|
-
return newThreadsById;
|
|
8856
|
-
}, {});
|
|
8857
|
-
this.threadsByIdGetterCache.threads = threads;
|
|
8858
|
-
this.threadsByIdGetterCache.threadsById = threadsById;
|
|
8859
|
-
return threadsById;
|
|
10082
|
+
return this.pollCache;
|
|
8860
10083
|
}
|
|
8861
10084
|
}]);
|
|
8862
10085
|
|
|
8863
|
-
return
|
|
10086
|
+
return PollManager;
|
|
8864
10087
|
}();
|
|
8865
10088
|
|
|
8866
10089
|
var _excluded = ["created_at", "updated_at", "last_active", "online"],
|
|
@@ -8893,6 +10116,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8893
10116
|
|
|
8894
10117
|
_defineProperty(this, "threads", void 0);
|
|
8895
10118
|
|
|
10119
|
+
_defineProperty(this, "polls", void 0);
|
|
10120
|
+
|
|
8896
10121
|
_defineProperty(this, "anonymous", void 0);
|
|
8897
10122
|
|
|
8898
10123
|
_defineProperty(this, "persistUserOnConnectionFailure", void 0);
|
|
@@ -9791,6 +11016,9 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9791
11016
|
this.threads = new ThreadManager({
|
|
9792
11017
|
client: this
|
|
9793
11018
|
});
|
|
11019
|
+
this.polls = new PollManager({
|
|
11020
|
+
client: this
|
|
11021
|
+
});
|
|
9794
11022
|
}
|
|
9795
11023
|
/**
|
|
9796
11024
|
* Get a client instance
|
|
@@ -11057,6 +12285,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11057
12285
|
returnedPage: channelState.messages,
|
|
11058
12286
|
logger: this.logger
|
|
11059
12287
|
}));
|
|
12288
|
+
this.polls.hydratePollCache(updatedMessagesSet.messages, true);
|
|
11060
12289
|
}
|
|
11061
12290
|
|
|
11062
12291
|
channels.push(c);
|
|
@@ -13358,7 +14587,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13358
14587
|
}, {
|
|
13359
14588
|
key: "getUserAgent",
|
|
13360
14589
|
value: function getUserAgent() {
|
|
13361
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.
|
|
14590
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.43.0");
|
|
13362
14591
|
}
|
|
13363
14592
|
}, {
|
|
13364
14593
|
key: "setUserAgent",
|
|
@@ -14802,7 +16031,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
14802
16031
|
}()
|
|
14803
16032
|
/**
|
|
14804
16033
|
* Creates a poll
|
|
14805
|
-
* @param
|
|
16034
|
+
* @param poll PollData The poll that will be created
|
|
14806
16035
|
* @param userId string The user id (only serverside)
|
|
14807
16036
|
* @returns {APIResponse & CreatePollAPIResponse} The poll
|
|
14808
16037
|
*/
|
|
@@ -15002,13 +16231,11 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15002
16231
|
while (1) {
|
|
15003
16232
|
switch (_context103.prev = _context103.next) {
|
|
15004
16233
|
case 0:
|
|
15005
|
-
return _context103.abrupt("return", this.partialUpdatePoll(id,
|
|
16234
|
+
return _context103.abrupt("return", this.partialUpdatePoll(id, {
|
|
15006
16235
|
set: {
|
|
15007
16236
|
is_closed: true
|
|
15008
16237
|
}
|
|
15009
|
-
}, userId
|
|
15010
|
-
user_id: userId
|
|
15011
|
-
} : {})));
|
|
16238
|
+
}, userId));
|
|
15012
16239
|
|
|
15013
16240
|
case 1:
|
|
15014
16241
|
case "end":
|
|
@@ -15384,6 +16611,60 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15384
16611
|
|
|
15385
16612
|
return queryPollVotes;
|
|
15386
16613
|
}()
|
|
16614
|
+
/**
|
|
16615
|
+
* Queries poll answers
|
|
16616
|
+
* @param pollId
|
|
16617
|
+
* @param filter
|
|
16618
|
+
* @param sort
|
|
16619
|
+
* @param options Option object, {limit: 10, offset:0}
|
|
16620
|
+
* @param userId string The user id (only serverside)
|
|
16621
|
+
* @returns {APIResponse & PollAnswersAPIResponse} The poll votes
|
|
16622
|
+
*/
|
|
16623
|
+
|
|
16624
|
+
}, {
|
|
16625
|
+
key: "queryPollAnswers",
|
|
16626
|
+
value: function () {
|
|
16627
|
+
var _queryPollAnswers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee113(pollId) {
|
|
16628
|
+
var filter,
|
|
16629
|
+
sort,
|
|
16630
|
+
options,
|
|
16631
|
+
userId,
|
|
16632
|
+
q,
|
|
16633
|
+
_args113 = arguments;
|
|
16634
|
+
return _regeneratorRuntime.wrap(function _callee113$(_context113) {
|
|
16635
|
+
while (1) {
|
|
16636
|
+
switch (_context113.prev = _context113.next) {
|
|
16637
|
+
case 0:
|
|
16638
|
+
filter = _args113.length > 1 && _args113[1] !== undefined ? _args113[1] : {};
|
|
16639
|
+
sort = _args113.length > 2 && _args113[2] !== undefined ? _args113[2] : [];
|
|
16640
|
+
options = _args113.length > 3 && _args113[3] !== undefined ? _args113[3] : {};
|
|
16641
|
+
userId = _args113.length > 4 ? _args113[4] : undefined;
|
|
16642
|
+
q = userId ? "?user_id=".concat(userId) : '';
|
|
16643
|
+
_context113.next = 7;
|
|
16644
|
+
return this.post(this.baseURL + "/polls/".concat(encodeURIComponent(pollId), "/votes").concat(q), _objectSpread({
|
|
16645
|
+
filter: _objectSpread(_objectSpread({}, filter), {}, {
|
|
16646
|
+
is_answer: true
|
|
16647
|
+
}),
|
|
16648
|
+
sort: normalizeQuerySort(sort)
|
|
16649
|
+
}, options));
|
|
16650
|
+
|
|
16651
|
+
case 7:
|
|
16652
|
+
return _context113.abrupt("return", _context113.sent);
|
|
16653
|
+
|
|
16654
|
+
case 8:
|
|
16655
|
+
case "end":
|
|
16656
|
+
return _context113.stop();
|
|
16657
|
+
}
|
|
16658
|
+
}
|
|
16659
|
+
}, _callee113, this);
|
|
16660
|
+
}));
|
|
16661
|
+
|
|
16662
|
+
function queryPollAnswers(_x174) {
|
|
16663
|
+
return _queryPollAnswers.apply(this, arguments);
|
|
16664
|
+
}
|
|
16665
|
+
|
|
16666
|
+
return queryPollAnswers;
|
|
16667
|
+
}()
|
|
15387
16668
|
/**
|
|
15388
16669
|
* Query message history
|
|
15389
16670
|
* @param filter
|
|
@@ -15395,33 +16676,33 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15395
16676
|
}, {
|
|
15396
16677
|
key: "queryMessageHistory",
|
|
15397
16678
|
value: function () {
|
|
15398
|
-
var _queryMessageHistory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
16679
|
+
var _queryMessageHistory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee114() {
|
|
15399
16680
|
var filter,
|
|
15400
16681
|
sort,
|
|
15401
16682
|
options,
|
|
15402
|
-
|
|
15403
|
-
return _regeneratorRuntime.wrap(function
|
|
16683
|
+
_args114 = arguments;
|
|
16684
|
+
return _regeneratorRuntime.wrap(function _callee114$(_context114) {
|
|
15404
16685
|
while (1) {
|
|
15405
|
-
switch (
|
|
16686
|
+
switch (_context114.prev = _context114.next) {
|
|
15406
16687
|
case 0:
|
|
15407
|
-
filter =
|
|
15408
|
-
sort =
|
|
15409
|
-
options =
|
|
15410
|
-
|
|
16688
|
+
filter = _args114.length > 0 && _args114[0] !== undefined ? _args114[0] : {};
|
|
16689
|
+
sort = _args114.length > 1 && _args114[1] !== undefined ? _args114[1] : [];
|
|
16690
|
+
options = _args114.length > 2 && _args114[2] !== undefined ? _args114[2] : {};
|
|
16691
|
+
_context114.next = 5;
|
|
15411
16692
|
return this.post(this.baseURL + '/messages/history', _objectSpread({
|
|
15412
16693
|
filter: filter,
|
|
15413
16694
|
sort: normalizeQuerySort(sort)
|
|
15414
16695
|
}, options));
|
|
15415
16696
|
|
|
15416
16697
|
case 5:
|
|
15417
|
-
return
|
|
16698
|
+
return _context114.abrupt("return", _context114.sent);
|
|
15418
16699
|
|
|
15419
16700
|
case 6:
|
|
15420
16701
|
case "end":
|
|
15421
|
-
return
|
|
16702
|
+
return _context114.stop();
|
|
15422
16703
|
}
|
|
15423
16704
|
}
|
|
15424
|
-
},
|
|
16705
|
+
}, _callee114, this);
|
|
15425
16706
|
}));
|
|
15426
16707
|
|
|
15427
16708
|
function queryMessageHistory() {
|
|
@@ -15442,32 +16723,32 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15442
16723
|
}, {
|
|
15443
16724
|
key: "updateFlags",
|
|
15444
16725
|
value: function () {
|
|
15445
|
-
var _updateFlags = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
16726
|
+
var _updateFlags = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee115(message_ids, reviewed_by) {
|
|
15446
16727
|
var options,
|
|
15447
|
-
|
|
15448
|
-
return _regeneratorRuntime.wrap(function
|
|
16728
|
+
_args115 = arguments;
|
|
16729
|
+
return _regeneratorRuntime.wrap(function _callee115$(_context115) {
|
|
15449
16730
|
while (1) {
|
|
15450
|
-
switch (
|
|
16731
|
+
switch (_context115.prev = _context115.next) {
|
|
15451
16732
|
case 0:
|
|
15452
|
-
options =
|
|
15453
|
-
|
|
16733
|
+
options = _args115.length > 2 && _args115[2] !== undefined ? _args115[2] : {};
|
|
16734
|
+
_context115.next = 3;
|
|
15454
16735
|
return this.post(this.baseURL + '/automod/v1/moderation/update_flags', _objectSpread({
|
|
15455
16736
|
message_ids: message_ids,
|
|
15456
16737
|
reviewed_by: reviewed_by
|
|
15457
16738
|
}, options));
|
|
15458
16739
|
|
|
15459
16740
|
case 3:
|
|
15460
|
-
return
|
|
16741
|
+
return _context115.abrupt("return", _context115.sent);
|
|
15461
16742
|
|
|
15462
16743
|
case 4:
|
|
15463
16744
|
case "end":
|
|
15464
|
-
return
|
|
16745
|
+
return _context115.stop();
|
|
15465
16746
|
}
|
|
15466
16747
|
}
|
|
15467
|
-
},
|
|
16748
|
+
}, _callee115, this);
|
|
15468
16749
|
}));
|
|
15469
16750
|
|
|
15470
|
-
function updateFlags(
|
|
16751
|
+
function updateFlags(_x175, _x176) {
|
|
15471
16752
|
return _updateFlags.apply(this, arguments);
|
|
15472
16753
|
}
|
|
15473
16754
|
|
|
@@ -15625,5 +16906,5 @@ var BuiltinPermissions = {
|
|
|
15625
16906
|
UseFrozenChannel: 'Send messages and reactions to frozen channels'
|
|
15626
16907
|
};
|
|
15627
16908
|
|
|
15628
|
-
export { Allow, AllowAll, AnyResource, AnyRole, BuiltinPermissions, BuiltinRoles, Campaign, Channel, ChannelState, CheckSignature, ClientState, Deny, DenyAll, DevToken, EVENT_MAP, ErrorFromResponse, InsightMetrics, JWTServerToken, JWTUserToken, MODERATION_ENTITY_TYPES, MaxPriority, MinPriority, Moderation, Permission, Segment, StableWSConnection, StateStore, StreamChat, Thread, ThreadManager, TokenManager, UserFromToken, VotingVisibility, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, formatMessage, isOwnUser, logChatPromiseExecution, postInsights };
|
|
16909
|
+
export { Allow, AllowAll, AnyResource, AnyRole, BuiltinPermissions, BuiltinRoles, Campaign, Channel, ChannelState, CheckSignature, ClientState, Deny, DenyAll, DevToken, EVENT_MAP, ErrorFromResponse, InsightMetrics, JWTServerToken, JWTUserToken, MODERATION_ENTITY_TYPES, MaxPriority, MinPriority, Moderation, Permission, Poll, PollManager, Segment, StableWSConnection, StateStore, StreamChat, Thread, ThreadManager, TokenManager, UserFromToken, VotingVisibility, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, extractPollData, extractPollEnrichedData, formatMessage, isOwnUser, isVoteAnswer, logChatPromiseExecution, postInsights };
|
|
15629
16910
|
//# sourceMappingURL=index.es.js.map
|