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