stream-chat 8.38.0 → 8.40.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/README.md +15 -2
- package/dist/browser.es.js +1667 -372
- 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 +1668 -371
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +1667 -372
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1668 -371
- package/dist/index.js.map +1 -1
- package/dist/types/channel.d.ts +6 -8
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +14 -22
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +3 -1
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/constants.d.ts +7 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/store.d.ts +14 -0
- package/dist/types/store.d.ts.map +1 -0
- package/dist/types/thread.d.ts +93 -29
- package/dist/types/thread.d.ts.map +1 -1
- package/dist/types/thread_manager.d.ts +51 -0
- package/dist/types/thread_manager.d.ts.map +1 -0
- package/dist/types/types.d.ts +35 -18
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +48 -7
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/channel.ts +28 -13
- package/src/channel_state.ts +30 -27
- package/src/client.ts +182 -104
- package/src/constants.ts +4 -0
- package/src/index.ts +2 -0
- package/src/store.ts +57 -0
- package/src/thread.ts +470 -107
- package/src/thread_manager.ts +297 -0
- package/src/types.ts +34 -19
- package/src/utils.ts +362 -43
package/dist/browser.es.js
CHANGED
|
@@ -93,9 +93,9 @@ var decodeBase64 = function decodeBase64(s) {
|
|
|
93
93
|
|
|
94
94
|
var https = null;
|
|
95
95
|
|
|
96
|
-
function ownKeys$
|
|
96
|
+
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; }
|
|
97
97
|
|
|
98
|
-
function _objectSpread$
|
|
98
|
+
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; }
|
|
99
99
|
|
|
100
100
|
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) { 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
101
|
|
|
@@ -349,89 +349,120 @@ var axiosParamsSerializer = function axiosParamsSerializer(params) {
|
|
|
349
349
|
return newParams.join('&');
|
|
350
350
|
};
|
|
351
351
|
/**
|
|
352
|
-
*
|
|
353
|
-
* and sets the status to received if missing
|
|
354
|
-
*
|
|
355
|
-
* @param {MessageResponse<StreamChatGenerics>} message a message object
|
|
352
|
+
* Takes the message object, parses the dates, sets `__html`
|
|
353
|
+
* and sets the status to `received` if missing; returns a new message object.
|
|
356
354
|
*
|
|
355
|
+
* @param {MessageResponse<StreamChatGenerics>} message `MessageResponse` object
|
|
357
356
|
*/
|
|
358
357
|
|
|
359
358
|
function formatMessage(message) {
|
|
360
|
-
return _objectSpread$
|
|
359
|
+
return _objectSpread$b(_objectSpread$b({}, message), {}, {
|
|
361
360
|
/**
|
|
362
361
|
* @deprecated please use `html`
|
|
363
362
|
*/
|
|
364
363
|
__html: message.html,
|
|
365
|
-
// parse the
|
|
364
|
+
// parse the dates
|
|
366
365
|
pinned_at: message.pinned_at ? new Date(message.pinned_at) : null,
|
|
367
366
|
created_at: message.created_at ? new Date(message.created_at) : new Date(),
|
|
368
367
|
updated_at: message.updated_at ? new Date(message.updated_at) : new Date(),
|
|
368
|
+
deleted_at: message.deleted_at ? new Date(message.deleted_at) : null,
|
|
369
369
|
status: message.status || 'received',
|
|
370
370
|
reaction_groups: maybeGetReactionGroupsFallback(message.reaction_groups, message.reaction_counts, message.reaction_scores)
|
|
371
371
|
});
|
|
372
372
|
}
|
|
373
|
-
function
|
|
373
|
+
var findIndexInSortedArray = function findIndexInSortedArray(_ref) {
|
|
374
|
+
var needle = _ref.needle,
|
|
375
|
+
sortedArray = _ref.sortedArray,
|
|
376
|
+
_ref$selectValueToCom = _ref.selectValueToCompare,
|
|
377
|
+
selectValueToCompare = _ref$selectValueToCom === void 0 ? function (e) {
|
|
378
|
+
return e;
|
|
379
|
+
} : _ref$selectValueToCom,
|
|
380
|
+
_ref$sortDirection = _ref.sortDirection,
|
|
381
|
+
sortDirection = _ref$sortDirection === void 0 ? 'ascending' : _ref$sortDirection;
|
|
382
|
+
if (!sortedArray.length) return 0;
|
|
383
|
+
var left = 0;
|
|
384
|
+
var right = sortedArray.length - 1;
|
|
385
|
+
var middle = 0;
|
|
386
|
+
|
|
387
|
+
var recalculateMiddle = function recalculateMiddle() {
|
|
388
|
+
middle = Math.round((left + right) / 2);
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
var actualNeedle = selectValueToCompare(needle);
|
|
392
|
+
recalculateMiddle();
|
|
393
|
+
|
|
394
|
+
while (left <= right) {
|
|
395
|
+
// if (actualNeedle === selectValueToCompare(sortedArray[middle])) return middle;
|
|
396
|
+
if (sortDirection === 'ascending' && actualNeedle < selectValueToCompare(sortedArray[middle]) || sortDirection === 'descending' && actualNeedle > selectValueToCompare(sortedArray[middle])) {
|
|
397
|
+
right = middle - 1;
|
|
398
|
+
} else {
|
|
399
|
+
left = middle + 1;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
recalculateMiddle();
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return left;
|
|
406
|
+
};
|
|
407
|
+
function addToMessageList(messages, newMessage) {
|
|
374
408
|
var timestampChanged = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
375
409
|
var sortBy = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'created_at';
|
|
376
410
|
var addIfDoesNotExist = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
377
411
|
var addMessageToList = addIfDoesNotExist || timestampChanged;
|
|
378
|
-
|
|
412
|
+
|
|
413
|
+
var newMessages = _toConsumableArray(messages); // if created_at has changed, message should be filtered and re-inserted in correct order
|
|
379
414
|
// slow op but usually this only happens for a message inserted to state before actual response with correct timestamp
|
|
380
415
|
|
|
416
|
+
|
|
381
417
|
if (timestampChanged) {
|
|
382
|
-
|
|
383
|
-
return !(
|
|
418
|
+
newMessages = newMessages.filter(function (message) {
|
|
419
|
+
return !(message.id && newMessage.id === message.id);
|
|
384
420
|
});
|
|
385
|
-
} //
|
|
421
|
+
} // for empty list just concat and return unless it's an update or deletion
|
|
386
422
|
|
|
387
423
|
|
|
388
|
-
|
|
424
|
+
if (!newMessages.length && addMessageToList) {
|
|
425
|
+
return newMessages.concat(newMessage);
|
|
426
|
+
} // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
389
427
|
|
|
390
|
-
if (messageArrayLength === 0 && addMessageToList) {
|
|
391
|
-
return messageArr.concat(message);
|
|
392
|
-
} else if (messageArrayLength === 0) {
|
|
393
|
-
return _toConsumableArray(messageArr);
|
|
394
|
-
}
|
|
395
428
|
|
|
396
|
-
var messageTime =
|
|
397
|
-
|
|
429
|
+
var messageTime = newMessage[sortBy].getTime(); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
430
|
+
|
|
431
|
+
var messageIsNewest = newMessages.at(-1)[sortBy].getTime() < messageTime; // if message is newer than last item in the list concat and return unless it's an update or deletion
|
|
398
432
|
|
|
399
433
|
if (messageIsNewest && addMessageToList) {
|
|
400
|
-
return
|
|
401
|
-
} else if (messageIsNewest) {
|
|
402
|
-
return _toConsumableArray(messageArr);
|
|
434
|
+
return newMessages.concat(newMessage);
|
|
403
435
|
} // find the closest index to push the new message
|
|
404
436
|
|
|
405
437
|
|
|
406
|
-
var
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
438
|
+
var insertionIndex = findIndexInSortedArray({
|
|
439
|
+
needle: newMessage,
|
|
440
|
+
sortedArray: messages,
|
|
441
|
+
sortDirection: 'ascending',
|
|
442
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
443
|
+
selectValueToCompare: function selectValueToCompare(m) {
|
|
444
|
+
return m[sortBy].getTime();
|
|
445
|
+
}
|
|
446
|
+
}); // message already exists and not filtered with timestampChanged, update and return
|
|
415
447
|
|
|
416
|
-
if (!timestampChanged &&
|
|
417
|
-
if (
|
|
418
|
-
|
|
419
|
-
return
|
|
448
|
+
if (!timestampChanged && newMessage.id) {
|
|
449
|
+
if (newMessages[insertionIndex] && newMessage.id === newMessages[insertionIndex].id) {
|
|
450
|
+
newMessages[insertionIndex] = newMessage;
|
|
451
|
+
return newMessages;
|
|
420
452
|
}
|
|
421
453
|
|
|
422
|
-
if (
|
|
423
|
-
|
|
424
|
-
return
|
|
454
|
+
if (newMessages[insertionIndex - 1] && newMessage.id === newMessages[insertionIndex - 1].id) {
|
|
455
|
+
newMessages[insertionIndex - 1] = newMessage;
|
|
456
|
+
return newMessages;
|
|
425
457
|
}
|
|
426
|
-
} //
|
|
427
|
-
// or have a timestamp change.
|
|
458
|
+
} // do not add updated or deleted messages to the list if they already exist or come with a timestamp change
|
|
428
459
|
|
|
429
460
|
|
|
430
461
|
if (addMessageToList) {
|
|
431
|
-
|
|
462
|
+
newMessages.splice(insertionIndex, 0, newMessage);
|
|
432
463
|
}
|
|
433
464
|
|
|
434
|
-
return
|
|
465
|
+
return newMessages;
|
|
435
466
|
}
|
|
436
467
|
|
|
437
468
|
function maybeGetReactionGroupsFallback(groups, counts, scores) {
|
|
@@ -454,11 +485,259 @@ function maybeGetReactionGroupsFallback(groups, counts, scores) {
|
|
|
454
485
|
}
|
|
455
486
|
|
|
456
487
|
return null;
|
|
488
|
+
} // works exactly the same as lodash.throttle
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
var throttle = function throttle(fn) {
|
|
492
|
+
var timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
|
|
493
|
+
|
|
494
|
+
var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
495
|
+
_ref2$leading = _ref2.leading,
|
|
496
|
+
leading = _ref2$leading === void 0 ? true : _ref2$leading,
|
|
497
|
+
_ref2$trailing = _ref2.trailing,
|
|
498
|
+
trailing = _ref2$trailing === void 0 ? false : _ref2$trailing;
|
|
499
|
+
|
|
500
|
+
var runningTimeout = null;
|
|
501
|
+
var storedArgs = null;
|
|
502
|
+
return function () {
|
|
503
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
504
|
+
args[_key] = arguments[_key];
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (runningTimeout) {
|
|
508
|
+
if (trailing) storedArgs = args;
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
if (leading) fn.apply(void 0, args);
|
|
513
|
+
|
|
514
|
+
var timeoutHandler = function timeoutHandler() {
|
|
515
|
+
if (storedArgs) {
|
|
516
|
+
fn.apply(void 0, _toConsumableArray(storedArgs));
|
|
517
|
+
storedArgs = null;
|
|
518
|
+
runningTimeout = setTimeout(timeoutHandler, timeout);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
runningTimeout = null;
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
runningTimeout = setTimeout(timeoutHandler, timeout);
|
|
526
|
+
};
|
|
527
|
+
};
|
|
528
|
+
function binarySearchByDateEqualOrNearestGreater(array, targetDate) {
|
|
529
|
+
var left = 0;
|
|
530
|
+
var right = array.length - 1;
|
|
531
|
+
|
|
532
|
+
while (left <= right) {
|
|
533
|
+
var mid = Math.floor((left + right) / 2);
|
|
534
|
+
var midCreatedAt = array[mid].created_at;
|
|
535
|
+
|
|
536
|
+
if (!midCreatedAt) {
|
|
537
|
+
left += 1;
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
var midDate = new Date(midCreatedAt);
|
|
542
|
+
|
|
543
|
+
if (midDate.getTime() === targetDate.getTime()) {
|
|
544
|
+
return mid;
|
|
545
|
+
} else if (midDate.getTime() < targetDate.getTime()) {
|
|
546
|
+
left = mid + 1;
|
|
547
|
+
} else {
|
|
548
|
+
right = mid - 1;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
return left;
|
|
457
553
|
}
|
|
458
554
|
|
|
459
|
-
|
|
555
|
+
var messagePaginationCreatedAtAround = function messagePaginationCreatedAtAround(_ref3) {
|
|
556
|
+
var parentSet = _ref3.parentSet,
|
|
557
|
+
requestedPageSize = _ref3.requestedPageSize,
|
|
558
|
+
returnedPage = _ref3.returnedPage,
|
|
559
|
+
messagePaginationOptions = _ref3.messagePaginationOptions;
|
|
560
|
+
|
|
561
|
+
var newPagination = _objectSpread$b({}, parentSet.pagination);
|
|
562
|
+
|
|
563
|
+
if (!(messagePaginationOptions !== null && messagePaginationOptions !== void 0 && messagePaginationOptions.created_at_around)) return newPagination;
|
|
564
|
+
var hasPrev;
|
|
565
|
+
var hasNext;
|
|
566
|
+
var updateHasPrev;
|
|
567
|
+
var updateHasNext;
|
|
568
|
+
var createdAtAroundDate = new Date(messagePaginationOptions.created_at_around);
|
|
569
|
+
var _ref4 = [returnedPage[0], returnedPage.slice(-1)[0]],
|
|
570
|
+
firstPageMsg = _ref4[0],
|
|
571
|
+
lastPageMsg = _ref4[1]; // expect ASC order (from oldest to newest)
|
|
572
|
+
|
|
573
|
+
var wholePageHasNewerMessages = !!(firstPageMsg !== null && firstPageMsg !== void 0 && firstPageMsg.created_at) && new Date(firstPageMsg.created_at) > createdAtAroundDate;
|
|
574
|
+
var wholePageHasOlderMessages = !!(lastPageMsg !== null && lastPageMsg !== void 0 && lastPageMsg.created_at) && new Date(lastPageMsg.created_at) < createdAtAroundDate;
|
|
575
|
+
var requestedPageSizeNotMet = requestedPageSize > parentSet.messages.length && requestedPageSize > returnedPage.length;
|
|
576
|
+
var noMoreMessages = (requestedPageSize > parentSet.messages.length || parentSet.messages.length >= returnedPage.length) && requestedPageSize > returnedPage.length;
|
|
577
|
+
|
|
578
|
+
if (wholePageHasNewerMessages) {
|
|
579
|
+
hasPrev = false;
|
|
580
|
+
updateHasPrev = true;
|
|
581
|
+
|
|
582
|
+
if (requestedPageSizeNotMet) {
|
|
583
|
+
hasNext = false;
|
|
584
|
+
updateHasNext = true;
|
|
585
|
+
}
|
|
586
|
+
} else if (wholePageHasOlderMessages) {
|
|
587
|
+
hasNext = false;
|
|
588
|
+
updateHasNext = true;
|
|
589
|
+
|
|
590
|
+
if (requestedPageSizeNotMet) {
|
|
591
|
+
hasPrev = false;
|
|
592
|
+
updateHasPrev = true;
|
|
593
|
+
}
|
|
594
|
+
} else if (noMoreMessages) {
|
|
595
|
+
hasNext = hasPrev = false;
|
|
596
|
+
updateHasPrev = updateHasNext = true;
|
|
597
|
+
} else {
|
|
598
|
+
var _parentSet$messages$, _parentSet$messages$s;
|
|
460
599
|
|
|
461
|
-
|
|
600
|
+
var firstPageMsgIsFirstInSet = (firstPageMsg === null || firstPageMsg === void 0 ? void 0 : firstPageMsg.id) && firstPageMsg.id === ((_parentSet$messages$ = parentSet.messages[0]) === null || _parentSet$messages$ === void 0 ? void 0 : _parentSet$messages$.id),
|
|
601
|
+
lastPageMsgIsLastInSet = (lastPageMsg === null || lastPageMsg === void 0 ? void 0 : lastPageMsg.id) && lastPageMsg.id === ((_parentSet$messages$s = parentSet.messages.slice(-1)[0]) === null || _parentSet$messages$s === void 0 ? void 0 : _parentSet$messages$s.id);
|
|
602
|
+
updateHasPrev = firstPageMsgIsFirstInSet;
|
|
603
|
+
updateHasNext = lastPageMsgIsLastInSet;
|
|
604
|
+
var midPointByCount = Math.floor(returnedPage.length / 2);
|
|
605
|
+
var midPointByCreationDate = binarySearchByDateEqualOrNearestGreater(returnedPage, createdAtAroundDate);
|
|
606
|
+
|
|
607
|
+
if (midPointByCreationDate !== -1) {
|
|
608
|
+
hasPrev = midPointByCount <= midPointByCreationDate;
|
|
609
|
+
hasNext = midPointByCount >= midPointByCreationDate;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
if (updateHasPrev && typeof hasPrev !== 'undefined') newPagination.hasPrev = hasPrev;
|
|
614
|
+
if (updateHasNext && typeof hasNext !== 'undefined') newPagination.hasNext = hasNext;
|
|
615
|
+
return newPagination;
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
var messagePaginationIdAround = function messagePaginationIdAround(_ref5) {
|
|
619
|
+
var _parentSet$messages$2, _parentSet$messages$s2;
|
|
620
|
+
|
|
621
|
+
var parentSet = _ref5.parentSet,
|
|
622
|
+
requestedPageSize = _ref5.requestedPageSize,
|
|
623
|
+
returnedPage = _ref5.returnedPage,
|
|
624
|
+
messagePaginationOptions = _ref5.messagePaginationOptions;
|
|
625
|
+
|
|
626
|
+
var newPagination = _objectSpread$b({}, parentSet.pagination);
|
|
627
|
+
|
|
628
|
+
var _ref6 = messagePaginationOptions || {},
|
|
629
|
+
id_around = _ref6.id_around;
|
|
630
|
+
|
|
631
|
+
if (!id_around) return newPagination;
|
|
632
|
+
var hasPrev;
|
|
633
|
+
var hasNext;
|
|
634
|
+
var _ref7 = [returnedPage[0], returnedPage.slice(-1)[0]],
|
|
635
|
+
firstPageMsg = _ref7[0],
|
|
636
|
+
lastPageMsg = _ref7[1];
|
|
637
|
+
var firstPageMsgIsFirstInSet = (firstPageMsg === null || firstPageMsg === void 0 ? void 0 : firstPageMsg.id) === ((_parentSet$messages$2 = parentSet.messages[0]) === null || _parentSet$messages$2 === void 0 ? void 0 : _parentSet$messages$2.id),
|
|
638
|
+
lastPageMsgIsLastInSet = (lastPageMsg === null || lastPageMsg === void 0 ? void 0 : lastPageMsg.id) === ((_parentSet$messages$s2 = parentSet.messages.slice(-1)[0]) === null || _parentSet$messages$s2 === void 0 ? void 0 : _parentSet$messages$s2.id);
|
|
639
|
+
var updateHasPrev = firstPageMsgIsFirstInSet;
|
|
640
|
+
var updateHasNext = lastPageMsgIsLastInSet;
|
|
641
|
+
var midPoint = Math.floor(returnedPage.length / 2);
|
|
642
|
+
var noMoreMessages = (requestedPageSize > parentSet.messages.length || parentSet.messages.length >= returnedPage.length) && requestedPageSize > returnedPage.length;
|
|
643
|
+
|
|
644
|
+
if (noMoreMessages) {
|
|
645
|
+
hasNext = hasPrev = false;
|
|
646
|
+
updateHasPrev = updateHasNext = true;
|
|
647
|
+
} else if (!returnedPage[midPoint]) {
|
|
648
|
+
return newPagination;
|
|
649
|
+
} else if (returnedPage[midPoint].id === id_around) {
|
|
650
|
+
hasPrev = hasNext = true;
|
|
651
|
+
} else {
|
|
652
|
+
var targetMsg;
|
|
653
|
+
var halves = [returnedPage.slice(0, midPoint), returnedPage.slice(midPoint)];
|
|
654
|
+
hasPrev = hasNext = true;
|
|
655
|
+
|
|
656
|
+
for (var i = 0; i < halves.length; i++) {
|
|
657
|
+
targetMsg = halves[i].find(function (message) {
|
|
658
|
+
return message.id === id_around;
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
if (targetMsg && i === 0) {
|
|
662
|
+
hasPrev = false;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
if (targetMsg && i === 1) {
|
|
666
|
+
hasNext = false;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
if (updateHasPrev && typeof hasPrev !== 'undefined') newPagination.hasPrev = hasPrev;
|
|
672
|
+
if (updateHasNext && typeof hasNext !== 'undefined') newPagination.hasNext = hasNext;
|
|
673
|
+
return newPagination;
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
var messagePaginationLinear = function messagePaginationLinear(_ref8) {
|
|
677
|
+
var _parentSet$messages$3, _parentSet$messages$s3;
|
|
678
|
+
|
|
679
|
+
var parentSet = _ref8.parentSet,
|
|
680
|
+
requestedPageSize = _ref8.requestedPageSize,
|
|
681
|
+
returnedPage = _ref8.returnedPage,
|
|
682
|
+
messagePaginationOptions = _ref8.messagePaginationOptions;
|
|
683
|
+
|
|
684
|
+
var newPagination = _objectSpread$b({}, parentSet.pagination);
|
|
685
|
+
|
|
686
|
+
var hasPrev;
|
|
687
|
+
var hasNext;
|
|
688
|
+
var _ref9 = [returnedPage[0], returnedPage.slice(-1)[0]],
|
|
689
|
+
firstPageMsg = _ref9[0],
|
|
690
|
+
lastPageMsg = _ref9[1];
|
|
691
|
+
var firstPageMsgIsFirstInSet = (firstPageMsg === null || firstPageMsg === void 0 ? void 0 : firstPageMsg.id) && firstPageMsg.id === ((_parentSet$messages$3 = parentSet.messages[0]) === null || _parentSet$messages$3 === void 0 ? void 0 : _parentSet$messages$3.id),
|
|
692
|
+
lastPageMsgIsLastInSet = (lastPageMsg === null || lastPageMsg === void 0 ? void 0 : lastPageMsg.id) && lastPageMsg.id === ((_parentSet$messages$s3 = parentSet.messages.slice(-1)[0]) === null || _parentSet$messages$s3 === void 0 ? void 0 : _parentSet$messages$s3.id);
|
|
693
|
+
var queriedNextMessages = messagePaginationOptions && (messagePaginationOptions.created_at_after_or_equal || messagePaginationOptions.created_at_after || messagePaginationOptions.id_gt || messagePaginationOptions.id_gte);
|
|
694
|
+
var queriedPrevMessages = typeof messagePaginationOptions === 'undefined' ? true : messagePaginationOptions.created_at_before_or_equal || messagePaginationOptions.created_at_before || messagePaginationOptions.id_lt || messagePaginationOptions.id_lte || messagePaginationOptions.offset;
|
|
695
|
+
var containsUnrecognizedOptionsOnly = !queriedNextMessages && !queriedPrevMessages && !(messagePaginationOptions !== null && messagePaginationOptions !== void 0 && messagePaginationOptions.id_around) && !(messagePaginationOptions !== null && messagePaginationOptions !== void 0 && messagePaginationOptions.created_at_around);
|
|
696
|
+
var hasMore = returnedPage.length >= requestedPageSize;
|
|
697
|
+
|
|
698
|
+
if (typeof queriedPrevMessages !== 'undefined' || containsUnrecognizedOptionsOnly) {
|
|
699
|
+
hasPrev = hasMore;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
if (typeof queriedNextMessages !== 'undefined') {
|
|
703
|
+
hasNext = hasMore;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
var returnedPageIsEmpty = returnedPage.length === 0;
|
|
707
|
+
if ((firstPageMsgIsFirstInSet || returnedPageIsEmpty) && typeof hasPrev !== 'undefined') newPagination.hasPrev = hasPrev;
|
|
708
|
+
if ((lastPageMsgIsLastInSet || returnedPageIsEmpty) && typeof hasNext !== 'undefined') newPagination.hasNext = hasNext;
|
|
709
|
+
return newPagination;
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
var messageSetPagination = function messageSetPagination(params) {
|
|
713
|
+
var _params$messagePagina, _params$messagePagina2;
|
|
714
|
+
|
|
715
|
+
if (params.parentSet.messages.length < params.returnedPage.length) {
|
|
716
|
+
var _params$logger;
|
|
717
|
+
|
|
718
|
+
(_params$logger = params.logger) === null || _params$logger === void 0 ? void 0 : _params$logger.call(params, 'error', 'Corrupted message set state: parent set size < returned page size');
|
|
719
|
+
return params.parentSet.pagination;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
if ((_params$messagePagina = params.messagePaginationOptions) !== null && _params$messagePagina !== void 0 && _params$messagePagina.created_at_around) {
|
|
723
|
+
return messagePaginationCreatedAtAround(params);
|
|
724
|
+
} else if ((_params$messagePagina2 = params.messagePaginationOptions) !== null && _params$messagePagina2 !== void 0 && _params$messagePagina2.id_around) {
|
|
725
|
+
return messagePaginationIdAround(params);
|
|
726
|
+
} else {
|
|
727
|
+
return messagePaginationLinear(params);
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
var DEFAULT_QUERY_CHANNELS_MESSAGE_LIST_PAGE_SIZE = 25;
|
|
732
|
+
var DEFAULT_QUERY_CHANNEL_MESSAGE_LIST_PAGE_SIZE = 100;
|
|
733
|
+
var DEFAULT_MESSAGE_SET_PAGINATION = {
|
|
734
|
+
hasNext: true,
|
|
735
|
+
hasPrev: true
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
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; }
|
|
739
|
+
|
|
740
|
+
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; }
|
|
462
741
|
|
|
463
742
|
/**
|
|
464
743
|
* ChannelState - A container class for the channel state.
|
|
@@ -513,6 +792,10 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
513
792
|
|
|
514
793
|
_defineProperty(this, "messageSets", []);
|
|
515
794
|
|
|
795
|
+
_defineProperty(this, "formatMessage", function (message) {
|
|
796
|
+
return formatMessage(message);
|
|
797
|
+
});
|
|
798
|
+
|
|
516
799
|
_defineProperty(this, "setIsUpToDate", function (isUpToDate) {
|
|
517
800
|
_this.isUpToDate = isUpToDate;
|
|
518
801
|
});
|
|
@@ -535,7 +818,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
535
818
|
if (!message) return;
|
|
536
819
|
if (message.poll_id !== pollVote.poll_id) return;
|
|
537
820
|
|
|
538
|
-
var updatedPoll = _objectSpread$
|
|
821
|
+
var updatedPoll = _objectSpread$a({}, poll);
|
|
539
822
|
|
|
540
823
|
var ownVotes = _toConsumableArray(((_message$poll = message.poll) === null || _message$poll === void 0 ? void 0 : _message$poll.own_votes) || []);
|
|
541
824
|
|
|
@@ -557,7 +840,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
557
840
|
|
|
558
841
|
updatedPoll.own_votes = ownVotes;
|
|
559
842
|
|
|
560
|
-
var newMessage = _objectSpread$
|
|
843
|
+
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
561
844
|
poll: updatedPoll
|
|
562
845
|
});
|
|
563
846
|
|
|
@@ -572,7 +855,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
572
855
|
if (!message) return;
|
|
573
856
|
if (message.poll_id !== pollVote.poll_id) return;
|
|
574
857
|
|
|
575
|
-
var updatedPoll = _objectSpread$
|
|
858
|
+
var updatedPoll = _objectSpread$a({}, poll);
|
|
576
859
|
|
|
577
860
|
var ownVotes = _toConsumableArray(((_message$poll2 = message.poll) === null || _message$poll2 === void 0 ? void 0 : _message$poll2.own_votes) || []);
|
|
578
861
|
|
|
@@ -582,7 +865,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
582
865
|
|
|
583
866
|
updatedPoll.own_votes = ownVotes;
|
|
584
867
|
|
|
585
|
-
var newMessage = _objectSpread$
|
|
868
|
+
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
586
869
|
poll: updatedPoll
|
|
587
870
|
});
|
|
588
871
|
|
|
@@ -597,7 +880,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
597
880
|
if (!message) return;
|
|
598
881
|
if (message.poll_id !== pollVote.poll_id) return;
|
|
599
882
|
|
|
600
|
-
var updatedPoll = _objectSpread$
|
|
883
|
+
var updatedPoll = _objectSpread$a({}, poll);
|
|
601
884
|
|
|
602
885
|
var ownVotes = _toConsumableArray(((_message$poll3 = message.poll) === null || _message$poll3 === void 0 ? void 0 : _message$poll3.own_votes) || []);
|
|
603
886
|
|
|
@@ -613,7 +896,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
613
896
|
|
|
614
897
|
updatedPoll.own_votes = ownVotes;
|
|
615
898
|
|
|
616
|
-
var newMessage = _objectSpread$
|
|
899
|
+
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
617
900
|
poll: updatedPoll
|
|
618
901
|
});
|
|
619
902
|
|
|
@@ -627,11 +910,11 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
627
910
|
|
|
628
911
|
if (!message) return;
|
|
629
912
|
|
|
630
|
-
var updatedPoll = _objectSpread$
|
|
913
|
+
var updatedPoll = _objectSpread$a(_objectSpread$a({}, poll), {}, {
|
|
631
914
|
own_votes: _toConsumableArray(((_message$poll4 = message.poll) === null || _message$poll4 === void 0 ? void 0 : _message$poll4.own_votes) || [])
|
|
632
915
|
});
|
|
633
916
|
|
|
634
|
-
var newMessage = _objectSpread$
|
|
917
|
+
var newMessage = _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
635
918
|
poll: updatedPoll
|
|
636
919
|
});
|
|
637
920
|
|
|
@@ -646,7 +929,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
646
929
|
var m = messages[i];
|
|
647
930
|
|
|
648
931
|
if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
|
|
649
|
-
messages[i] = _objectSpread$
|
|
932
|
+
messages[i] = _objectSpread$a(_objectSpread$a({}, m), {}, {
|
|
650
933
|
user: user
|
|
651
934
|
});
|
|
652
935
|
}
|
|
@@ -701,9 +984,9 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
701
984
|
user: m.user
|
|
702
985
|
};
|
|
703
986
|
} else {
|
|
704
|
-
messages[i] = _objectSpread$
|
|
987
|
+
messages[i] = _objectSpread$a(_objectSpread$a({}, m), {}, {
|
|
705
988
|
type: 'deleted',
|
|
706
|
-
deleted_at: user.deleted_at
|
|
989
|
+
deleted_at: user.deleted_at ? new Date(user.deleted_at) : null
|
|
707
990
|
});
|
|
708
991
|
}
|
|
709
992
|
}
|
|
@@ -780,6 +1063,15 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
780
1063
|
});
|
|
781
1064
|
this.messageSets[index].messages = messages;
|
|
782
1065
|
}
|
|
1066
|
+
}, {
|
|
1067
|
+
key: "messagePagination",
|
|
1068
|
+
get: function get() {
|
|
1069
|
+
var _this$messageSets$fin3;
|
|
1070
|
+
|
|
1071
|
+
return ((_this$messageSets$fin3 = this.messageSets.find(function (s) {
|
|
1072
|
+
return s.isCurrent;
|
|
1073
|
+
})) === null || _this$messageSets$fin3 === void 0 ? void 0 : _this$messageSets$fin3.pagination) || DEFAULT_MESSAGE_SET_PAGINATION;
|
|
1074
|
+
}
|
|
783
1075
|
/**
|
|
784
1076
|
* addMessageSorted - Add a message to the state
|
|
785
1077
|
*
|
|
@@ -798,28 +1090,15 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
798
1090
|
return this.addMessagesSorted([newMessage], timestampChanged, false, addIfDoesNotExist, messageSetToAddToIfDoesNotExist);
|
|
799
1091
|
}
|
|
800
1092
|
/**
|
|
801
|
-
*
|
|
802
|
-
* and sets the status to received if missing
|
|
803
|
-
*
|
|
804
|
-
* @param {MessageResponse<StreamChatGenerics>} message a message object
|
|
1093
|
+
* Takes the message object, parses the dates, sets `__html`
|
|
1094
|
+
* and sets the status to `received` if missing; returns a new message object.
|
|
805
1095
|
*
|
|
1096
|
+
* @param {MessageResponse<StreamChatGenerics>} message `MessageResponse` object
|
|
806
1097
|
*/
|
|
807
1098
|
|
|
808
1099
|
}, {
|
|
809
|
-
key: "
|
|
810
|
-
value:
|
|
811
|
-
return _objectSpread$8(_objectSpread$8({}, message), {}, {
|
|
812
|
-
/**
|
|
813
|
-
* @deprecated please use `html`
|
|
814
|
-
*/
|
|
815
|
-
__html: message.html,
|
|
816
|
-
// parse the date..
|
|
817
|
-
pinned_at: message.pinned_at ? new Date(message.pinned_at) : null,
|
|
818
|
-
created_at: message.created_at ? new Date(message.created_at) : new Date(),
|
|
819
|
-
updated_at: message.updated_at ? new Date(message.updated_at) : new Date(),
|
|
820
|
-
status: message.status || 'received'
|
|
821
|
-
});
|
|
822
|
-
}
|
|
1100
|
+
key: "addMessagesSorted",
|
|
1101
|
+
value:
|
|
823
1102
|
/**
|
|
824
1103
|
* addMessagesSorted - Add the list of messages to state and resorts the messages
|
|
825
1104
|
*
|
|
@@ -830,10 +1109,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
830
1109
|
* @param {MessageSetType} messageSetToAddToIfDoesNotExist Which message set to add to if messages are not in the list (only used if addIfDoesNotExist is true)
|
|
831
1110
|
*
|
|
832
1111
|
*/
|
|
833
|
-
|
|
834
|
-
}, {
|
|
835
|
-
key: "addMessagesSorted",
|
|
836
|
-
value: function addMessagesSorted(newMessages) {
|
|
1112
|
+
function addMessagesSorted(newMessages) {
|
|
837
1113
|
var timestampChanged = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
838
1114
|
var initializing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
839
1115
|
var addIfDoesNotExist = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
@@ -1026,7 +1302,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1026
1302
|
var parseMessage = function parseMessage(m) {
|
|
1027
1303
|
var _m$pinned_at, _m$updated_at;
|
|
1028
1304
|
|
|
1029
|
-
return _objectSpread$
|
|
1305
|
+
return _objectSpread$a(_objectSpread$a({}, m), {}, {
|
|
1030
1306
|
created_at: m.created_at.toISOString(),
|
|
1031
1307
|
pinned_at: (_m$pinned_at = m.pinned_at) === null || _m$pinned_at === void 0 ? void 0 : _m$pinned_at.toISOString(),
|
|
1032
1308
|
updated_at: (_m$updated_at = m.updated_at) === null || _m$updated_at === void 0 ? void 0 : _m$updated_at.toISOString()
|
|
@@ -1036,8 +1312,8 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1036
1312
|
var update = function update(messages) {
|
|
1037
1313
|
var updatedMessages = messages.reduce(function (acc, msg) {
|
|
1038
1314
|
if (msg.quoted_message_id === message.id) {
|
|
1039
|
-
acc.push(_objectSpread$
|
|
1040
|
-
quoted_message: remove ? _objectSpread$
|
|
1315
|
+
acc.push(_objectSpread$a(_objectSpread$a({}, parseMessage(msg)), {}, {
|
|
1316
|
+
quoted_message: remove ? _objectSpread$a(_objectSpread$a({}, message), {}, {
|
|
1041
1317
|
attachments: []
|
|
1042
1318
|
}) : message
|
|
1043
1319
|
}));
|
|
@@ -1233,7 +1509,8 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1233
1509
|
this.messageSets = [{
|
|
1234
1510
|
messages: [],
|
|
1235
1511
|
isLatest: true,
|
|
1236
|
-
isCurrent: true
|
|
1512
|
+
isCurrent: true,
|
|
1513
|
+
pagination: DEFAULT_MESSAGE_SET_PAGINATION
|
|
1237
1514
|
}];
|
|
1238
1515
|
}
|
|
1239
1516
|
/**
|
|
@@ -1241,6 +1518,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1241
1518
|
*
|
|
1242
1519
|
* @param {string} messageId The id of the message, or 'latest' to indicate switching to the latest messages
|
|
1243
1520
|
* @param {string} parentMessageId The id of the parent message, if we want load a thread reply
|
|
1521
|
+
* @param {number} limit The page size if the message has to be queried from the server
|
|
1244
1522
|
*/
|
|
1245
1523
|
|
|
1246
1524
|
}, {
|
|
@@ -1449,7 +1727,8 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1449
1727
|
this.messageSets.push({
|
|
1450
1728
|
messages: [],
|
|
1451
1729
|
isCurrent: false,
|
|
1452
|
-
isLatest: false
|
|
1730
|
+
isLatest: false,
|
|
1731
|
+
pagination: DEFAULT_MESSAGE_SET_PAGINATION
|
|
1453
1732
|
});
|
|
1454
1733
|
targetMessageSetIndex = this.messageSets.length - 1;
|
|
1455
1734
|
}
|
|
@@ -1490,6 +1769,8 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1490
1769
|
sources.forEach(function (messageSet) {
|
|
1491
1770
|
target.isLatest = target.isLatest || messageSet.isLatest;
|
|
1492
1771
|
target.isCurrent = target.isCurrent || messageSet.isCurrent;
|
|
1772
|
+
target.pagination.hasPrev = messageSet.messages[0].created_at < target.messages[0].created_at ? messageSet.pagination.hasPrev : target.pagination.hasPrev;
|
|
1773
|
+
target.pagination.hasNext = target.messages.slice(-1)[0].created_at < messageSet.messages.slice(-1)[0].created_at ? messageSet.pagination.hasNext : target.pagination.hasNext;
|
|
1493
1774
|
messagesToAdd = [].concat(_toConsumableArray(messagesToAdd), _toConsumableArray(messageSet.messages));
|
|
1494
1775
|
});
|
|
1495
1776
|
sources.forEach(function (s) {
|
|
@@ -1521,13 +1802,13 @@ function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o
|
|
|
1521
1802
|
|
|
1522
1803
|
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; }
|
|
1523
1804
|
|
|
1524
|
-
function ownKeys$
|
|
1525
|
-
|
|
1526
|
-
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; }
|
|
1805
|
+
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; }
|
|
1527
1806
|
|
|
1807
|
+
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; }
|
|
1528
1808
|
/**
|
|
1529
1809
|
* Channel - The Channel class manages it's own state.
|
|
1530
1810
|
*/
|
|
1811
|
+
|
|
1531
1812
|
var Channel = /*#__PURE__*/function () {
|
|
1532
1813
|
/** */
|
|
1533
1814
|
|
|
@@ -1596,7 +1877,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1596
1877
|
while (1) {
|
|
1597
1878
|
switch (_context.prev = _context.next) {
|
|
1598
1879
|
case 0:
|
|
1599
|
-
defaultOptions = _objectSpread$
|
|
1880
|
+
defaultOptions = _objectSpread$9(_objectSpread$9({}, options), {}, {
|
|
1600
1881
|
watch: false,
|
|
1601
1882
|
state: false,
|
|
1602
1883
|
presence: false
|
|
@@ -1648,7 +1929,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1648
1929
|
throw new Error('channel id is not defined');
|
|
1649
1930
|
}
|
|
1650
1931
|
|
|
1651
|
-
return "".concat(_this.getClient().baseURL, "/channels/").concat(_this.type, "/").concat(_this.id);
|
|
1932
|
+
return "".concat(_this.getClient().baseURL, "/channels/").concat(encodeURIComponent(_this.type), "/").concat(encodeURIComponent(_this.id));
|
|
1652
1933
|
});
|
|
1653
1934
|
|
|
1654
1935
|
var validTypeRe = /^[\w_-]+$/;
|
|
@@ -1668,7 +1949,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1668
1949
|
|
|
1669
1950
|
this.data = data; // this._data is used for the requests...
|
|
1670
1951
|
|
|
1671
|
-
this._data = _objectSpread$
|
|
1952
|
+
this._data = _objectSpread$9({}, data);
|
|
1672
1953
|
this.cid = "".concat(type, ":").concat(id);
|
|
1673
1954
|
this.listeners = {}; // perhaps the state variable should be private
|
|
1674
1955
|
|
|
@@ -1730,7 +2011,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1730
2011
|
switch (_context2.prev = _context2.next) {
|
|
1731
2012
|
case 0:
|
|
1732
2013
|
_context2.next = 2;
|
|
1733
|
-
return this.getClient().post(this._channelURL() + '/message', _objectSpread$
|
|
2014
|
+
return this.getClient().post(this._channelURL() + '/message', _objectSpread$9({
|
|
1734
2015
|
message: message
|
|
1735
2016
|
}, options));
|
|
1736
2017
|
|
|
@@ -1846,7 +2127,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1846
2127
|
|
|
1847
2128
|
case 3:
|
|
1848
2129
|
// Return a list of channels
|
|
1849
|
-
payload = _objectSpread$
|
|
2130
|
+
payload = _objectSpread$9(_objectSpread$9({
|
|
1850
2131
|
filter_conditions: {
|
|
1851
2132
|
cid: this.cid
|
|
1852
2133
|
}
|
|
@@ -1943,7 +2224,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1943
2224
|
|
|
1944
2225
|
_context5.next = 6;
|
|
1945
2226
|
return this.getClient().get(this.getClient().baseURL + '/members', {
|
|
1946
|
-
payload: _objectSpread$
|
|
2227
|
+
payload: _objectSpread$9({
|
|
1947
2228
|
type: type,
|
|
1948
2229
|
id: id,
|
|
1949
2230
|
members: members,
|
|
@@ -2004,7 +2285,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2004
2285
|
|
|
2005
2286
|
case 4:
|
|
2006
2287
|
_context6.next = 6;
|
|
2007
|
-
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$
|
|
2288
|
+
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(messageID), "/reaction"), _objectSpread$9({
|
|
2008
2289
|
reaction: reaction
|
|
2009
2290
|
}, options));
|
|
2010
2291
|
|
|
@@ -2044,7 +2325,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2044
2325
|
throw Error('Deleting a reaction requires specifying both the message and reaction type');
|
|
2045
2326
|
}
|
|
2046
2327
|
|
|
2047
|
-
var url = this.getClient().baseURL + "/messages/".concat(messageID, "/reaction/").concat(reactionType); //provided when server side request
|
|
2328
|
+
var url = this.getClient().baseURL + "/messages/".concat(encodeURIComponent(messageID), "/reaction/").concat(encodeURIComponent(reactionType)); //provided when server side request
|
|
2048
2329
|
|
|
2049
2330
|
if (user_id) {
|
|
2050
2331
|
return this.getClient().delete(url, {
|
|
@@ -2085,7 +2366,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2085
2366
|
delete channelData[key];
|
|
2086
2367
|
});
|
|
2087
2368
|
_context7.next = 7;
|
|
2088
|
-
return this._update(_objectSpread$
|
|
2369
|
+
return this._update(_objectSpread$9({
|
|
2089
2370
|
message: updateMessage,
|
|
2090
2371
|
data: channelData
|
|
2091
2372
|
}, options));
|
|
@@ -2257,7 +2538,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2257
2538
|
case 0:
|
|
2258
2539
|
options = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
|
|
2259
2540
|
_context11.next = 3;
|
|
2260
|
-
return this.getClient().delete(this._channelURL(), _objectSpread$
|
|
2541
|
+
return this.getClient().delete(this._channelURL(), _objectSpread$9({}, options));
|
|
2261
2542
|
|
|
2262
2543
|
case 3:
|
|
2263
2544
|
return _context11.abrupt("return", _context11.sent);
|
|
@@ -2333,7 +2614,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2333
2614
|
case 0:
|
|
2334
2615
|
options = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
2335
2616
|
_context13.next = 3;
|
|
2336
|
-
return this._update(_objectSpread$
|
|
2617
|
+
return this._update(_objectSpread$9({
|
|
2337
2618
|
accept_invite: true
|
|
2338
2619
|
}, options));
|
|
2339
2620
|
|
|
@@ -2374,7 +2655,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2374
2655
|
case 0:
|
|
2375
2656
|
options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
2376
2657
|
_context14.next = 3;
|
|
2377
|
-
return this._update(_objectSpread$
|
|
2658
|
+
return this._update(_objectSpread$9({
|
|
2378
2659
|
reject_invite: true
|
|
2379
2660
|
}, options));
|
|
2380
2661
|
|
|
@@ -2416,7 +2697,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2416
2697
|
case 0:
|
|
2417
2698
|
options = _args15.length > 2 && _args15[2] !== undefined ? _args15[2] : {};
|
|
2418
2699
|
_context15.next = 3;
|
|
2419
|
-
return this._update(_objectSpread$
|
|
2700
|
+
return this._update(_objectSpread$9({
|
|
2420
2701
|
add_members: members,
|
|
2421
2702
|
message: message
|
|
2422
2703
|
}, options));
|
|
@@ -2459,7 +2740,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2459
2740
|
case 0:
|
|
2460
2741
|
options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
|
|
2461
2742
|
_context16.next = 3;
|
|
2462
|
-
return this._update(_objectSpread$
|
|
2743
|
+
return this._update(_objectSpread$9({
|
|
2463
2744
|
add_moderators: members,
|
|
2464
2745
|
message: message
|
|
2465
2746
|
}, options));
|
|
@@ -2502,7 +2783,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2502
2783
|
case 0:
|
|
2503
2784
|
options = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
|
|
2504
2785
|
_context17.next = 3;
|
|
2505
|
-
return this._update(_objectSpread$
|
|
2786
|
+
return this._update(_objectSpread$9({
|
|
2506
2787
|
assign_roles: roles,
|
|
2507
2788
|
message: message
|
|
2508
2789
|
}, options));
|
|
@@ -2545,7 +2826,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2545
2826
|
case 0:
|
|
2546
2827
|
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
2547
2828
|
_context18.next = 3;
|
|
2548
|
-
return this._update(_objectSpread$
|
|
2829
|
+
return this._update(_objectSpread$9({
|
|
2549
2830
|
invites: members,
|
|
2550
2831
|
message: message
|
|
2551
2832
|
}, options));
|
|
@@ -2588,7 +2869,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2588
2869
|
case 0:
|
|
2589
2870
|
options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
|
2590
2871
|
_context19.next = 3;
|
|
2591
|
-
return this._update(_objectSpread$
|
|
2872
|
+
return this._update(_objectSpread$9({
|
|
2592
2873
|
remove_members: members,
|
|
2593
2874
|
message: message
|
|
2594
2875
|
}, options));
|
|
@@ -2631,7 +2912,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2631
2912
|
case 0:
|
|
2632
2913
|
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
|
2633
2914
|
_context20.next = 3;
|
|
2634
|
-
return this._update(_objectSpread$
|
|
2915
|
+
return this._update(_objectSpread$9({
|
|
2635
2916
|
demote_moderators: members,
|
|
2636
2917
|
message: message
|
|
2637
2918
|
}, options));
|
|
@@ -2716,7 +2997,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2716
2997
|
case 0:
|
|
2717
2998
|
opts = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
|
|
2718
2999
|
_context22.next = 3;
|
|
2719
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$
|
|
3000
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$9({
|
|
2720
3001
|
channel_cid: this.cid
|
|
2721
3002
|
}, opts));
|
|
2722
3003
|
|
|
@@ -2758,7 +3039,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2758
3039
|
case 0:
|
|
2759
3040
|
opts = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
|
|
2760
3041
|
_context23.next = 3;
|
|
2761
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$
|
|
3042
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$9({
|
|
2762
3043
|
channel_cid: this.cid
|
|
2763
3044
|
}, opts));
|
|
2764
3045
|
|
|
@@ -2800,7 +3081,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2800
3081
|
throw Error("Message id is missing");
|
|
2801
3082
|
}
|
|
2802
3083
|
|
|
2803
|
-
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/action"), {
|
|
3084
|
+
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(messageID), "/action"), {
|
|
2804
3085
|
message_id: messageID,
|
|
2805
3086
|
form_data: formData,
|
|
2806
3087
|
id: this.id,
|
|
@@ -2843,7 +3124,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2843
3124
|
|
|
2844
3125
|
this.lastTypingEvent = new Date();
|
|
2845
3126
|
_context24.next = 10;
|
|
2846
|
-
return this.sendEvent(_objectSpread$
|
|
3127
|
+
return this.sendEvent(_objectSpread$9({
|
|
2847
3128
|
type: 'typing.start',
|
|
2848
3129
|
parent_id: parent_id
|
|
2849
3130
|
}, options || {}));
|
|
@@ -2887,7 +3168,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2887
3168
|
this.lastTypingEvent = null;
|
|
2888
3169
|
this.isTyping = false;
|
|
2889
3170
|
_context25.next = 6;
|
|
2890
|
-
return this.sendEvent(_objectSpread$
|
|
3171
|
+
return this.sendEvent(_objectSpread$9({
|
|
2891
3172
|
type: 'typing.stop',
|
|
2892
3173
|
parent_id: parent_id
|
|
2893
3174
|
}, options || {}));
|
|
@@ -2974,7 +3255,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2974
3255
|
|
|
2975
3256
|
case 4:
|
|
2976
3257
|
_context26.next = 6;
|
|
2977
|
-
return this.getClient().post(this._channelURL() + '/read', _objectSpread$
|
|
3258
|
+
return this.getClient().post(this._channelURL() + '/read', _objectSpread$9({}, data));
|
|
2978
3259
|
|
|
2979
3260
|
case 6:
|
|
2980
3261
|
return _context26.abrupt("return", _context26.sent);
|
|
@@ -3021,7 +3302,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3021
3302
|
|
|
3022
3303
|
case 3:
|
|
3023
3304
|
_context27.next = 5;
|
|
3024
|
-
return this.getClient().post(this._channelURL() + '/unread', _objectSpread$
|
|
3305
|
+
return this.getClient().post(this._channelURL() + '/unread', _objectSpread$9({}, data));
|
|
3025
3306
|
|
|
3026
3307
|
case 5:
|
|
3027
3308
|
return _context27.abrupt("return", _context27.sent);
|
|
@@ -3089,7 +3370,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3089
3370
|
defaultOptions.watch = false;
|
|
3090
3371
|
}
|
|
3091
3372
|
|
|
3092
|
-
combined = _objectSpread$
|
|
3373
|
+
combined = _objectSpread$9(_objectSpread$9({}, defaultOptions), options);
|
|
3093
3374
|
_context28.next = 7;
|
|
3094
3375
|
return this.query(combined, 'latest');
|
|
3095
3376
|
|
|
@@ -3162,7 +3443,9 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3162
3443
|
return stopWatching;
|
|
3163
3444
|
}()
|
|
3164
3445
|
/**
|
|
3165
|
-
* getReplies - List the message replies for a parent message
|
|
3446
|
+
* getReplies - List the message replies for a parent message.
|
|
3447
|
+
*
|
|
3448
|
+
* The recommended way of working with threads is to use the Thread class.
|
|
3166
3449
|
*
|
|
3167
3450
|
* @param {string} parent_id The message parent id, ie the top of the thread
|
|
3168
3451
|
* @param {MessagePaginationOptions & { user?: UserResponse<StreamChatGenerics>; user_id?: string }} options Pagination params, ie {limit:10, id_lte: 10}
|
|
@@ -3181,7 +3464,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3181
3464
|
case 0:
|
|
3182
3465
|
normalizedSort = sort ? normalizeQuerySort(sort) : undefined;
|
|
3183
3466
|
_context30.next = 3;
|
|
3184
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$
|
|
3467
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(parent_id), "/replies"), _objectSpread$9({
|
|
3185
3468
|
sort: normalizedSort
|
|
3186
3469
|
}, options));
|
|
3187
3470
|
|
|
@@ -3230,8 +3513,8 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3230
3513
|
case 0:
|
|
3231
3514
|
sort = _args31.length > 1 && _args31[1] !== undefined ? _args31[1] : [];
|
|
3232
3515
|
_context31.next = 3;
|
|
3233
|
-
return this.getClient().get(this.
|
|
3234
|
-
payload: _objectSpread$
|
|
3516
|
+
return this.getClient().get(this._channelURL() + '/pinned_messages', {
|
|
3517
|
+
payload: _objectSpread$9(_objectSpread$9({}, options), {}, {
|
|
3235
3518
|
sort: normalizeQuerySort(sort)
|
|
3236
3519
|
})
|
|
3237
3520
|
});
|
|
@@ -3265,7 +3548,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3265
3548
|
}, {
|
|
3266
3549
|
key: "getReactions",
|
|
3267
3550
|
value: function getReactions(message_id, options) {
|
|
3268
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$
|
|
3551
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(message_id), "/reactions"), _objectSpread$9({}, options));
|
|
3269
3552
|
}
|
|
3270
3553
|
/**
|
|
3271
3554
|
* getMessagesById - Retrieves a list of messages by ID
|
|
@@ -3385,7 +3668,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3385
3668
|
*/
|
|
3386
3669
|
function () {
|
|
3387
3670
|
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32(options) {
|
|
3388
|
-
var _this$data6, _this$data7;
|
|
3671
|
+
var _options$messages$lim, _options$messages, _this$data6, _this$data7;
|
|
3389
3672
|
|
|
3390
3673
|
var messageSetToAddToIfDoesNotExist,
|
|
3391
3674
|
queryURL,
|
|
@@ -3406,14 +3689,14 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3406
3689
|
return this.getClient().wsPromise;
|
|
3407
3690
|
|
|
3408
3691
|
case 3:
|
|
3409
|
-
queryURL = "".concat(this.getClient().baseURL, "/channels/").concat(this.type);
|
|
3692
|
+
queryURL = "".concat(this.getClient().baseURL, "/channels/").concat(encodeURIComponent(this.type));
|
|
3410
3693
|
|
|
3411
3694
|
if (this.id) {
|
|
3412
|
-
queryURL += "/".concat(this.id);
|
|
3695
|
+
queryURL += "/".concat(encodeURIComponent(this.id));
|
|
3413
3696
|
}
|
|
3414
3697
|
|
|
3415
3698
|
_context32.next = 7;
|
|
3416
|
-
return this.getClient().post(queryURL + '/query', _objectSpread$
|
|
3699
|
+
return this.getClient().post(queryURL + '/query', _objectSpread$9({
|
|
3417
3700
|
data: this._data,
|
|
3418
3701
|
state: true
|
|
3419
3702
|
}, options));
|
|
@@ -3448,6 +3731,13 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3448
3731
|
|
|
3449
3732
|
|
|
3450
3733
|
_this$_initializeStat = this._initializeState(state, messageSetToAddToIfDoesNotExist), messageSet = _this$_initializeStat.messageSet;
|
|
3734
|
+
messageSet.pagination = _objectSpread$9(_objectSpread$9({}, messageSet.pagination), messageSetPagination({
|
|
3735
|
+
parentSet: messageSet,
|
|
3736
|
+
messagePaginationOptions: options === null || options === void 0 ? void 0 : options.messages,
|
|
3737
|
+
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,
|
|
3738
|
+
returnedPage: state.messages,
|
|
3739
|
+
logger: this.getClient().logger
|
|
3740
|
+
}));
|
|
3451
3741
|
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();
|
|
3452
3742
|
this.data = state.channel;
|
|
3453
3743
|
this.offlineMode = false;
|
|
@@ -3469,7 +3759,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3469
3759
|
});
|
|
3470
3760
|
return _context32.abrupt("return", state);
|
|
3471
3761
|
|
|
3472
|
-
case
|
|
3762
|
+
case 18:
|
|
3473
3763
|
case "end":
|
|
3474
3764
|
return _context32.stop();
|
|
3475
3765
|
}
|
|
@@ -3502,7 +3792,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3502
3792
|
this._checkInitialized();
|
|
3503
3793
|
|
|
3504
3794
|
_context33.next = 3;
|
|
3505
|
-
return this.getClient().banUser(targetUserID, _objectSpread$
|
|
3795
|
+
return this.getClient().banUser(targetUserID, _objectSpread$9(_objectSpread$9({}, options), {}, {
|
|
3506
3796
|
type: this.type,
|
|
3507
3797
|
id: this.id
|
|
3508
3798
|
}));
|
|
@@ -3674,7 +3964,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3674
3964
|
this._checkInitialized();
|
|
3675
3965
|
|
|
3676
3966
|
_context37.next = 3;
|
|
3677
|
-
return this.getClient().shadowBan(targetUserID, _objectSpread$
|
|
3967
|
+
return this.getClient().shadowBan(targetUserID, _objectSpread$9(_objectSpread$9({}, options), {}, {
|
|
3678
3968
|
type: this.type,
|
|
3679
3969
|
id: this.id
|
|
3680
3970
|
}));
|
|
@@ -4128,7 +4418,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4128
4418
|
});
|
|
4129
4419
|
}
|
|
4130
4420
|
|
|
4131
|
-
channel.data = _objectSpread$
|
|
4421
|
+
channel.data = _objectSpread$9(_objectSpread$9({}, event.channel), {}, {
|
|
4132
4422
|
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,
|
|
4133
4423
|
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
|
|
4134
4424
|
});
|
|
@@ -4202,7 +4492,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4202
4492
|
break;
|
|
4203
4493
|
|
|
4204
4494
|
case 'channel.hidden':
|
|
4205
|
-
channel.data = _objectSpread$
|
|
4495
|
+
channel.data = _objectSpread$9(_objectSpread$9({}, channel.data), {}, {
|
|
4206
4496
|
hidden: true
|
|
4207
4497
|
});
|
|
4208
4498
|
|
|
@@ -4213,26 +4503,26 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4213
4503
|
break;
|
|
4214
4504
|
|
|
4215
4505
|
case 'channel.visible':
|
|
4216
|
-
channel.data = _objectSpread$
|
|
4506
|
+
channel.data = _objectSpread$9(_objectSpread$9({}, channel.data), {}, {
|
|
4217
4507
|
hidden: false
|
|
4218
4508
|
});
|
|
4219
4509
|
break;
|
|
4220
4510
|
|
|
4221
4511
|
case 'user.banned':
|
|
4222
4512
|
if (!((_event$user11 = event.user) !== null && _event$user11 !== void 0 && _event$user11.id)) break;
|
|
4223
|
-
channelState.members[event.user.id] = _objectSpread$
|
|
4513
|
+
channelState.members[event.user.id] = _objectSpread$9(_objectSpread$9({}, channelState.members[event.user.id] || {}), {}, {
|
|
4224
4514
|
shadow_banned: !!event.shadow,
|
|
4225
4515
|
banned: !event.shadow,
|
|
4226
|
-
user: _objectSpread$
|
|
4516
|
+
user: _objectSpread$9(_objectSpread$9({}, ((_channelState$members = channelState.members[event.user.id]) === null || _channelState$members === void 0 ? void 0 : _channelState$members.user) || {}), event.user)
|
|
4227
4517
|
});
|
|
4228
4518
|
break;
|
|
4229
4519
|
|
|
4230
4520
|
case 'user.unbanned':
|
|
4231
4521
|
if (!((_event$user12 = event.user) !== null && _event$user12 !== void 0 && _event$user12.id)) break;
|
|
4232
|
-
channelState.members[event.user.id] = _objectSpread$
|
|
4522
|
+
channelState.members[event.user.id] = _objectSpread$9(_objectSpread$9({}, channelState.members[event.user.id] || {}), {}, {
|
|
4233
4523
|
shadow_banned: false,
|
|
4234
4524
|
banned: false,
|
|
4235
|
-
user: _objectSpread$
|
|
4525
|
+
user: _objectSpread$9(_objectSpread$9({}, ((_channelState$members2 = channelState.members[event.user.id]) === null || _channelState$members2 === void 0 ? void 0 : _channelState$members2.user) || {}), event.user)
|
|
4236
4526
|
});
|
|
4237
4527
|
break;
|
|
4238
4528
|
} // any event can send over the online count
|
|
@@ -4486,9 +4776,9 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
4486
4776
|
return ClientState;
|
|
4487
4777
|
}();
|
|
4488
4778
|
|
|
4489
|
-
function ownKeys$
|
|
4779
|
+
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; }
|
|
4490
4780
|
|
|
4491
|
-
function _objectSpread$
|
|
4781
|
+
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; }
|
|
4492
4782
|
var InsightMetrics = function InsightMetrics() {
|
|
4493
4783
|
_classCallCheck(this, InsightMetrics);
|
|
4494
4784
|
|
|
@@ -4567,7 +4857,7 @@ var postInsights = /*#__PURE__*/function () {
|
|
|
4567
4857
|
};
|
|
4568
4858
|
}();
|
|
4569
4859
|
function buildWsFatalInsight(connection, event) {
|
|
4570
|
-
return _objectSpread$
|
|
4860
|
+
return _objectSpread$8(_objectSpread$8({}, event), buildWsBaseInsight(connection));
|
|
4571
4861
|
}
|
|
4572
4862
|
|
|
4573
4863
|
function buildWsBaseInsight(connection) {
|
|
@@ -4600,9 +4890,9 @@ function buildWsSuccessAfterFailureInsight(connection) {
|
|
|
4600
4890
|
return buildWsBaseInsight(connection);
|
|
4601
4891
|
}
|
|
4602
4892
|
|
|
4603
|
-
function ownKeys$
|
|
4893
|
+
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; }
|
|
4604
4894
|
|
|
4605
|
-
function _objectSpread$
|
|
4895
|
+
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; }
|
|
4606
4896
|
|
|
4607
4897
|
// Type guards to check WebSocket error type
|
|
4608
4898
|
var isCloseEvent = function isCloseEvent(res) {
|
|
@@ -4966,7 +5256,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4966
5256
|
value: function _log(msg) {
|
|
4967
5257
|
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4968
5258
|
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
4969
|
-
this.client.logger(level, 'connection:' + msg, _objectSpread$
|
|
5259
|
+
this.client.logger(level, 'connection:' + msg, _objectSpread$7({
|
|
4970
5260
|
tags: ['connection']
|
|
4971
5261
|
}, extra));
|
|
4972
5262
|
}
|
|
@@ -5561,9 +5851,9 @@ var jwt = null;
|
|
|
5561
5851
|
|
|
5562
5852
|
var crypto$1 = null;
|
|
5563
5853
|
|
|
5564
|
-
function ownKeys$
|
|
5854
|
+
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; }
|
|
5565
5855
|
|
|
5566
|
-
function _objectSpread$
|
|
5856
|
+
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; }
|
|
5567
5857
|
|
|
5568
5858
|
/**
|
|
5569
5859
|
* Creates the JWT token that can be used for a UserSession
|
|
@@ -5584,7 +5874,7 @@ function JWTUserToken(apiSecret, userId) {
|
|
|
5584
5874
|
throw new TypeError('userId should be a string');
|
|
5585
5875
|
}
|
|
5586
5876
|
|
|
5587
|
-
var payload = _objectSpread$
|
|
5877
|
+
var payload = _objectSpread$6({
|
|
5588
5878
|
user_id: userId
|
|
5589
5879
|
}, extraData); // make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
5590
5880
|
|
|
@@ -5988,9 +6278,9 @@ function isErrorResponse(res) {
|
|
|
5988
6278
|
return !res.status || res.status < 200 || 300 <= res.status;
|
|
5989
6279
|
}
|
|
5990
6280
|
|
|
5991
|
-
function ownKeys$
|
|
6281
|
+
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; }
|
|
5992
6282
|
|
|
5993
|
-
function _objectSpread$
|
|
6283
|
+
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; }
|
|
5994
6284
|
var ConnectionState;
|
|
5995
6285
|
|
|
5996
6286
|
(function (ConnectionState) {
|
|
@@ -6053,7 +6343,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
6053
6343
|
_context.next = 4;
|
|
6054
6344
|
return _this.client.doAxiosRequest('get', _this.client.baseURL.replace(':3030', ':8900') + '/longpoll', // replace port if present for testing with local API
|
|
6055
6345
|
undefined, {
|
|
6056
|
-
config: _objectSpread$
|
|
6346
|
+
config: _objectSpread$5(_objectSpread$5({}, config), {}, {
|
|
6057
6347
|
cancelToken: (_this$cancelToken2 = _this.cancelToken) === null || _this$cancelToken2 === void 0 ? void 0 : _this$cancelToken2.token
|
|
6058
6348
|
}),
|
|
6059
6349
|
params: params
|
|
@@ -6331,7 +6621,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
6331
6621
|
value: function _log(msg) {
|
|
6332
6622
|
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6333
6623
|
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
6334
|
-
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$
|
|
6624
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$5({
|
|
6335
6625
|
tags: ['connection_fallback', 'connection']
|
|
6336
6626
|
}, extra));
|
|
6337
6627
|
}
|
|
@@ -6911,168 +7201,710 @@ var VotingVisibility;
|
|
|
6911
7201
|
VotingVisibility["public"] = "public";
|
|
6912
7202
|
})(VotingVisibility || (VotingVisibility = {}));
|
|
6913
7203
|
|
|
6914
|
-
|
|
7204
|
+
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; }
|
|
6915
7205
|
|
|
6916
|
-
function
|
|
7206
|
+
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; }
|
|
6917
7207
|
|
|
6918
|
-
function
|
|
7208
|
+
function isPatch(value) {
|
|
7209
|
+
return typeof value === 'function';
|
|
7210
|
+
}
|
|
6919
7211
|
|
|
6920
|
-
|
|
7212
|
+
var StateStore = function StateStore(value) {
|
|
7213
|
+
var _this = this;
|
|
6921
7214
|
|
|
6922
|
-
|
|
7215
|
+
_classCallCheck(this, StateStore);
|
|
6923
7216
|
|
|
6924
|
-
|
|
7217
|
+
this.value = value;
|
|
7218
|
+
|
|
7219
|
+
_defineProperty(this, "handlerSet", new Set());
|
|
7220
|
+
|
|
7221
|
+
_defineProperty(this, "next", function (newValueOrPatch) {
|
|
7222
|
+
// newValue (or patch output) should never be mutated previous value
|
|
7223
|
+
var newValue = isPatch(newValueOrPatch) ? newValueOrPatch(_this.value) : newValueOrPatch; // do not notify subscribers if the value hasn't changed
|
|
7224
|
+
|
|
7225
|
+
if (newValue === _this.value) return;
|
|
7226
|
+
var oldValue = _this.value;
|
|
7227
|
+
_this.value = newValue;
|
|
7228
|
+
|
|
7229
|
+
_this.handlerSet.forEach(function (handler) {
|
|
7230
|
+
return handler(_this.value, oldValue);
|
|
7231
|
+
});
|
|
7232
|
+
});
|
|
7233
|
+
|
|
7234
|
+
_defineProperty(this, "partialNext", function (partial) {
|
|
7235
|
+
return _this.next(function (current) {
|
|
7236
|
+
return _objectSpread$4(_objectSpread$4({}, current), partial);
|
|
7237
|
+
});
|
|
7238
|
+
});
|
|
7239
|
+
|
|
7240
|
+
_defineProperty(this, "getLatestValue", function () {
|
|
7241
|
+
return _this.value;
|
|
7242
|
+
});
|
|
7243
|
+
|
|
7244
|
+
_defineProperty(this, "subscribe", function (handler) {
|
|
7245
|
+
handler(_this.value, undefined);
|
|
7246
|
+
|
|
7247
|
+
_this.handlerSet.add(handler);
|
|
7248
|
+
|
|
7249
|
+
return function () {
|
|
7250
|
+
_this.handlerSet.delete(handler);
|
|
7251
|
+
};
|
|
7252
|
+
});
|
|
7253
|
+
|
|
7254
|
+
_defineProperty(this, "subscribeWithSelector", function (selector, handler) {
|
|
7255
|
+
// begin with undefined to reduce amount of selector calls
|
|
7256
|
+
var selectedValues;
|
|
7257
|
+
|
|
7258
|
+
var wrappedHandler = function wrappedHandler(nextValue) {
|
|
7259
|
+
var _selectedValues$some, _selectedValues;
|
|
7260
|
+
|
|
7261
|
+
var newlySelectedValues = selector(nextValue);
|
|
7262
|
+
var hasUpdatedValues = (_selectedValues$some = (_selectedValues = selectedValues) === null || _selectedValues === void 0 ? void 0 : _selectedValues.some(function (value, index) {
|
|
7263
|
+
return value !== newlySelectedValues[index];
|
|
7264
|
+
})) !== null && _selectedValues$some !== void 0 ? _selectedValues$some : true;
|
|
7265
|
+
if (!hasUpdatedValues) return;
|
|
7266
|
+
var oldSelectedValues = selectedValues;
|
|
7267
|
+
selectedValues = newlySelectedValues;
|
|
7268
|
+
handler(newlySelectedValues, oldSelectedValues);
|
|
7269
|
+
};
|
|
7270
|
+
|
|
7271
|
+
return _this.subscribe(wrappedHandler);
|
|
7272
|
+
});
|
|
7273
|
+
};
|
|
7274
|
+
|
|
7275
|
+
var _excluded$1 = ["limit", "sort"];
|
|
7276
|
+
|
|
7277
|
+
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; }
|
|
7278
|
+
|
|
7279
|
+
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; }
|
|
7280
|
+
var DEFAULT_PAGE_LIMIT = 50;
|
|
7281
|
+
var DEFAULT_SORT = [{
|
|
7282
|
+
created_at: -1
|
|
7283
|
+
}];
|
|
7284
|
+
var MARK_AS_READ_THROTTLE_TIMEOUT = 1000;
|
|
6925
7285
|
var Thread = /*#__PURE__*/function () {
|
|
6926
|
-
|
|
6927
|
-
|
|
7286
|
+
function Thread(_ref) {
|
|
7287
|
+
var _this = this,
|
|
7288
|
+
_threadData$read,
|
|
7289
|
+
_threadData$reply_cou;
|
|
7290
|
+
|
|
7291
|
+
var client = _ref.client,
|
|
7292
|
+
threadData = _ref.threadData;
|
|
7293
|
+
|
|
6928
7294
|
_classCallCheck(this, Thread);
|
|
6929
7295
|
|
|
7296
|
+
_defineProperty(this, "state", void 0);
|
|
7297
|
+
|
|
6930
7298
|
_defineProperty(this, "id", void 0);
|
|
6931
7299
|
|
|
6932
|
-
_defineProperty(this, "
|
|
7300
|
+
_defineProperty(this, "client", void 0);
|
|
6933
7301
|
|
|
6934
|
-
_defineProperty(this, "
|
|
7302
|
+
_defineProperty(this, "unsubscribeFunctions", new Set());
|
|
6935
7303
|
|
|
6936
|
-
_defineProperty(this, "
|
|
7304
|
+
_defineProperty(this, "failedRepliesMap", new Map());
|
|
6937
7305
|
|
|
6938
|
-
_defineProperty(this, "
|
|
7306
|
+
_defineProperty(this, "activate", function () {
|
|
7307
|
+
_this.state.partialNext({
|
|
7308
|
+
active: true
|
|
7309
|
+
});
|
|
7310
|
+
});
|
|
6939
7311
|
|
|
6940
|
-
_defineProperty(this, "
|
|
7312
|
+
_defineProperty(this, "deactivate", function () {
|
|
7313
|
+
_this.state.partialNext({
|
|
7314
|
+
active: false
|
|
7315
|
+
});
|
|
7316
|
+
});
|
|
6941
7317
|
|
|
6942
|
-
_defineProperty(this, "
|
|
7318
|
+
_defineProperty(this, "reload", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
7319
|
+
var thread;
|
|
7320
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
7321
|
+
while (1) {
|
|
7322
|
+
switch (_context.prev = _context.next) {
|
|
7323
|
+
case 0:
|
|
7324
|
+
if (!_this.state.getLatestValue().isLoading) {
|
|
7325
|
+
_context.next = 2;
|
|
7326
|
+
break;
|
|
7327
|
+
}
|
|
6943
7328
|
|
|
6944
|
-
|
|
7329
|
+
return _context.abrupt("return");
|
|
6945
7330
|
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
var parent_message_id = t.parent_message_id,
|
|
6951
|
-
parent_message = t.parent_message,
|
|
6952
|
-
latest_replies = t.latest_replies,
|
|
6953
|
-
thread_participants = t.thread_participants,
|
|
6954
|
-
reply_count = t.reply_count,
|
|
6955
|
-
channel = t.channel,
|
|
6956
|
-
read = t.read,
|
|
6957
|
-
data = _objectWithoutProperties(t, _excluded$1);
|
|
6958
|
-
|
|
6959
|
-
this.id = parent_message_id;
|
|
6960
|
-
this.message = formatMessage(parent_message);
|
|
6961
|
-
this.latestReplies = latest_replies.map(formatMessage);
|
|
6962
|
-
this.participants = thread_participants;
|
|
6963
|
-
this.replyCount = reply_count;
|
|
6964
|
-
this.channel = channel;
|
|
6965
|
-
this._channel = client.channel(t.channel.type, t.channel.id);
|
|
6966
|
-
this._client = client;
|
|
7331
|
+
case 2:
|
|
7332
|
+
_this.state.partialNext({
|
|
7333
|
+
isLoading: true
|
|
7334
|
+
});
|
|
6967
7335
|
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
7336
|
+
_context.prev = 3;
|
|
7337
|
+
_context.next = 6;
|
|
7338
|
+
return _this.client.getThread(_this.id, {
|
|
7339
|
+
watch: true
|
|
7340
|
+
});
|
|
6971
7341
|
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
var r = _step.value;
|
|
6975
|
-
this.read[r.user.id] = _objectSpread$2(_objectSpread$2({}, r), {}, {
|
|
6976
|
-
last_read: new Date(r.last_read)
|
|
6977
|
-
});
|
|
6978
|
-
}
|
|
6979
|
-
} catch (err) {
|
|
6980
|
-
_iterator.e(err);
|
|
6981
|
-
} finally {
|
|
6982
|
-
_iterator.f();
|
|
6983
|
-
}
|
|
6984
|
-
}
|
|
7342
|
+
case 6:
|
|
7343
|
+
thread = _context.sent;
|
|
6985
7344
|
|
|
6986
|
-
|
|
6987
|
-
}
|
|
7345
|
+
_this.hydrateState(thread);
|
|
6988
7346
|
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
value: function getClient() {
|
|
6992
|
-
return this._client;
|
|
6993
|
-
}
|
|
6994
|
-
/**
|
|
6995
|
-
* addReply - Adds or updates a latestReplies to the thread
|
|
6996
|
-
*
|
|
6997
|
-
* @param {MessageResponse<StreamChatGenerics>} message reply message to be added.
|
|
6998
|
-
*/
|
|
7347
|
+
case 8:
|
|
7348
|
+
_context.prev = 8;
|
|
6999
7349
|
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
if (message.parent_id !== this.message.id) {
|
|
7004
|
-
throw new Error('Message does not belong to this thread');
|
|
7005
|
-
}
|
|
7350
|
+
_this.state.partialNext({
|
|
7351
|
+
isLoading: false
|
|
7352
|
+
});
|
|
7006
7353
|
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
if (m.id === message.id) {
|
|
7014
|
-
return formatMessage(message);
|
|
7354
|
+
return _context.finish(8);
|
|
7355
|
+
|
|
7356
|
+
case 11:
|
|
7357
|
+
case "end":
|
|
7358
|
+
return _context.stop();
|
|
7359
|
+
}
|
|
7015
7360
|
}
|
|
7361
|
+
}, _callee, null, [[3,, 8, 11]]);
|
|
7362
|
+
})));
|
|
7016
7363
|
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
}, {
|
|
7021
|
-
key: "updateMessageOrReplyIfExists",
|
|
7022
|
-
value: function updateMessageOrReplyIfExists(message) {
|
|
7023
|
-
if (!message.parent_id && message.id !== this.message.id) {
|
|
7364
|
+
_defineProperty(this, "hydrateState", function (thread) {
|
|
7365
|
+
if (thread === _this) {
|
|
7366
|
+
// skip if the instances are the same
|
|
7024
7367
|
return;
|
|
7025
7368
|
}
|
|
7026
7369
|
|
|
7027
|
-
if (
|
|
7028
|
-
|
|
7370
|
+
if (thread.id !== _this.id) {
|
|
7371
|
+
throw new Error("Cannot hydrate thread state with using thread's state");
|
|
7029
7372
|
}
|
|
7030
7373
|
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7374
|
+
var _thread$state$getLate = thread.state.getLatestValue(),
|
|
7375
|
+
read = _thread$state$getLate.read,
|
|
7376
|
+
replyCount = _thread$state$getLate.replyCount,
|
|
7377
|
+
replies = _thread$state$getLate.replies,
|
|
7378
|
+
parentMessage = _thread$state$getLate.parentMessage,
|
|
7379
|
+
participants = _thread$state$getLate.participants,
|
|
7380
|
+
createdAt = _thread$state$getLate.createdAt,
|
|
7381
|
+
deletedAt = _thread$state$getLate.deletedAt,
|
|
7382
|
+
updatedAt = _thread$state$getLate.updatedAt; // Preserve pending replies and append them to the updated list of replies
|
|
7035
7383
|
|
|
7036
|
-
if (!message.parent_id && message.id === this.message.id) {
|
|
7037
|
-
this.message = formatMessage(message);
|
|
7038
|
-
}
|
|
7039
|
-
}
|
|
7040
|
-
}, {
|
|
7041
|
-
key: "addReaction",
|
|
7042
|
-
value: function addReaction(reaction, message, enforce_unique) {
|
|
7043
|
-
var _this = this;
|
|
7044
7384
|
|
|
7045
|
-
|
|
7046
|
-
this.latestReplies = this.latestReplies.map(function (m) {
|
|
7047
|
-
if (m.id === message.id) {
|
|
7048
|
-
return formatMessage(_this._channel.state.addReaction(reaction, message, enforce_unique));
|
|
7049
|
-
}
|
|
7385
|
+
var pendingReplies = Array.from(_this.failedRepliesMap.values());
|
|
7050
7386
|
|
|
7051
|
-
|
|
7387
|
+
_this.state.partialNext({
|
|
7388
|
+
read: read,
|
|
7389
|
+
replyCount: replyCount,
|
|
7390
|
+
replies: pendingReplies.length ? replies.concat(pendingReplies) : replies,
|
|
7391
|
+
parentMessage: parentMessage,
|
|
7392
|
+
participants: participants,
|
|
7393
|
+
createdAt: createdAt,
|
|
7394
|
+
deletedAt: deletedAt,
|
|
7395
|
+
updatedAt: updatedAt,
|
|
7396
|
+
isStateStale: false
|
|
7052
7397
|
});
|
|
7053
|
-
}
|
|
7054
|
-
}, {
|
|
7055
|
-
key: "removeReaction",
|
|
7056
|
-
value: function removeReaction(reaction, message) {
|
|
7057
|
-
var _this2 = this;
|
|
7398
|
+
});
|
|
7058
7399
|
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7400
|
+
_defineProperty(this, "registerSubscriptions", function () {
|
|
7401
|
+
if (_this.unsubscribeFunctions.size) {
|
|
7402
|
+
// Thread is already listening for events and changes
|
|
7403
|
+
return;
|
|
7404
|
+
}
|
|
7064
7405
|
|
|
7065
|
-
|
|
7066
|
-
});
|
|
7067
|
-
}
|
|
7068
|
-
}]);
|
|
7406
|
+
_this.unsubscribeFunctions.add(_this.subscribeMarkActiveThreadRead());
|
|
7069
7407
|
|
|
7070
|
-
|
|
7071
|
-
}();
|
|
7408
|
+
_this.unsubscribeFunctions.add(_this.subscribeReloadActiveStaleThread());
|
|
7072
7409
|
|
|
7073
|
-
|
|
7410
|
+
_this.unsubscribeFunctions.add(_this.subscribeMarkThreadStale());
|
|
7074
7411
|
|
|
7075
|
-
|
|
7412
|
+
_this.unsubscribeFunctions.add(_this.subscribeNewReplies());
|
|
7413
|
+
|
|
7414
|
+
_this.unsubscribeFunctions.add(_this.subscribeRepliesRead());
|
|
7415
|
+
|
|
7416
|
+
_this.unsubscribeFunctions.add(_this.subscribeReplyDeleted());
|
|
7417
|
+
|
|
7418
|
+
_this.unsubscribeFunctions.add(_this.subscribeMessageUpdated());
|
|
7419
|
+
});
|
|
7420
|
+
|
|
7421
|
+
_defineProperty(this, "subscribeMarkActiveThreadRead", function () {
|
|
7422
|
+
return _this.state.subscribeWithSelector(function (nextValue) {
|
|
7423
|
+
return [nextValue.active, ownUnreadCountSelector(_this.client.userID)(nextValue)];
|
|
7424
|
+
}, function (_ref3) {
|
|
7425
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
7426
|
+
active = _ref4[0],
|
|
7427
|
+
unreadMessageCount = _ref4[1];
|
|
7428
|
+
|
|
7429
|
+
if (!active || !unreadMessageCount) return;
|
|
7430
|
+
|
|
7431
|
+
_this.throttledMarkAsRead();
|
|
7432
|
+
});
|
|
7433
|
+
});
|
|
7434
|
+
|
|
7435
|
+
_defineProperty(this, "subscribeReloadActiveStaleThread", function () {
|
|
7436
|
+
return _this.state.subscribeWithSelector(function (nextValue) {
|
|
7437
|
+
return [nextValue.active, nextValue.isStateStale];
|
|
7438
|
+
}, function (_ref5) {
|
|
7439
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
7440
|
+
active = _ref6[0],
|
|
7441
|
+
isStateStale = _ref6[1];
|
|
7442
|
+
|
|
7443
|
+
if (active && isStateStale) {
|
|
7444
|
+
_this.reload();
|
|
7445
|
+
}
|
|
7446
|
+
});
|
|
7447
|
+
});
|
|
7448
|
+
|
|
7449
|
+
_defineProperty(this, "subscribeMarkThreadStale", function () {
|
|
7450
|
+
return _this.client.on('user.watching.stop', function (event) {
|
|
7451
|
+
var _event$user, _event$channel;
|
|
7452
|
+
|
|
7453
|
+
var _this$state$getLatest = _this.state.getLatestValue(),
|
|
7454
|
+
channel = _this$state$getLatest.channel;
|
|
7455
|
+
|
|
7456
|
+
if (!_this.client.userID || _this.client.userID !== ((_event$user = event.user) === null || _event$user === void 0 ? void 0 : _event$user.id) || ((_event$channel = event.channel) === null || _event$channel === void 0 ? void 0 : _event$channel.cid) !== channel.cid) {
|
|
7457
|
+
return;
|
|
7458
|
+
}
|
|
7459
|
+
|
|
7460
|
+
_this.state.partialNext({
|
|
7461
|
+
isStateStale: true
|
|
7462
|
+
});
|
|
7463
|
+
}).unsubscribe;
|
|
7464
|
+
});
|
|
7465
|
+
|
|
7466
|
+
_defineProperty(this, "subscribeNewReplies", function () {
|
|
7467
|
+
return _this.client.on('message.new', function (event) {
|
|
7468
|
+
var _event$message, _event$message$user;
|
|
7469
|
+
|
|
7470
|
+
if (!_this.client.userID || ((_event$message = event.message) === null || _event$message === void 0 ? void 0 : _event$message.parent_id) !== _this.id) {
|
|
7471
|
+
return;
|
|
7472
|
+
}
|
|
7473
|
+
|
|
7474
|
+
var isOwnMessage = ((_event$message$user = event.message.user) === null || _event$message$user === void 0 ? void 0 : _event$message$user.id) === _this.client.userID;
|
|
7475
|
+
|
|
7476
|
+
var _this$state$getLatest2 = _this.state.getLatestValue(),
|
|
7477
|
+
active = _this$state$getLatest2.active,
|
|
7478
|
+
read = _this$state$getLatest2.read;
|
|
7479
|
+
|
|
7480
|
+
_this.upsertReplyLocally({
|
|
7481
|
+
message: event.message,
|
|
7482
|
+
// Message from current user could have been added optimistically,
|
|
7483
|
+
// so the actual timestamp might differ in the event
|
|
7484
|
+
timestampChanged: isOwnMessage
|
|
7485
|
+
});
|
|
7486
|
+
|
|
7487
|
+
if (active) {
|
|
7488
|
+
_this.throttledMarkAsRead();
|
|
7489
|
+
}
|
|
7490
|
+
|
|
7491
|
+
var nextRead = {};
|
|
7492
|
+
|
|
7493
|
+
for (var _i = 0, _Object$keys = Object.keys(read); _i < _Object$keys.length; _i++) {
|
|
7494
|
+
var userId = _Object$keys[_i];
|
|
7495
|
+
var userRead = read[userId];
|
|
7496
|
+
|
|
7497
|
+
if (userRead) {
|
|
7498
|
+
var _event$user2;
|
|
7499
|
+
|
|
7500
|
+
var nextUserRead = userRead;
|
|
7501
|
+
|
|
7502
|
+
if (userId === ((_event$user2 = event.user) === null || _event$user2 === void 0 ? void 0 : _event$user2.id)) {
|
|
7503
|
+
// The user who just sent a message to the thread has no unread messages
|
|
7504
|
+
// in that thread
|
|
7505
|
+
nextUserRead = _objectSpread$3(_objectSpread$3({}, nextUserRead), {}, {
|
|
7506
|
+
lastReadAt: event.created_at ? new Date(event.created_at) : new Date(),
|
|
7507
|
+
user: event.user,
|
|
7508
|
+
unreadMessageCount: 0
|
|
7509
|
+
});
|
|
7510
|
+
} else if (active && userId === _this.client.userID) ; else {
|
|
7511
|
+
// Increment unread count for all users except the author of the new message
|
|
7512
|
+
nextUserRead = _objectSpread$3(_objectSpread$3({}, nextUserRead), {}, {
|
|
7513
|
+
unreadMessageCount: userRead.unreadMessageCount + 1
|
|
7514
|
+
});
|
|
7515
|
+
}
|
|
7516
|
+
|
|
7517
|
+
nextRead[userId] = nextUserRead;
|
|
7518
|
+
}
|
|
7519
|
+
}
|
|
7520
|
+
|
|
7521
|
+
_this.state.partialNext({
|
|
7522
|
+
read: nextRead
|
|
7523
|
+
});
|
|
7524
|
+
}).unsubscribe;
|
|
7525
|
+
});
|
|
7526
|
+
|
|
7527
|
+
_defineProperty(this, "subscribeRepliesRead", function () {
|
|
7528
|
+
return _this.client.on('message.read', function (event) {
|
|
7529
|
+
if (!event.user || !event.created_at || !event.thread) return;
|
|
7530
|
+
if (event.thread.parent_message_id !== _this.id) return;
|
|
7531
|
+
var userId = event.user.id;
|
|
7532
|
+
var createdAt = event.created_at;
|
|
7533
|
+
var user = event.user;
|
|
7534
|
+
|
|
7535
|
+
_this.state.next(function (current) {
|
|
7536
|
+
return _objectSpread$3(_objectSpread$3({}, current), {}, {
|
|
7537
|
+
read: _objectSpread$3(_objectSpread$3({}, current.read), {}, _defineProperty({}, userId, {
|
|
7538
|
+
lastReadAt: new Date(createdAt),
|
|
7539
|
+
user: user,
|
|
7540
|
+
lastReadMessageId: event.last_read_message_id,
|
|
7541
|
+
unreadMessageCount: 0
|
|
7542
|
+
}))
|
|
7543
|
+
});
|
|
7544
|
+
});
|
|
7545
|
+
}).unsubscribe;
|
|
7546
|
+
});
|
|
7547
|
+
|
|
7548
|
+
_defineProperty(this, "subscribeReplyDeleted", function () {
|
|
7549
|
+
return _this.client.on('message.deleted', function (event) {
|
|
7550
|
+
var _event$message2;
|
|
7551
|
+
|
|
7552
|
+
if (((_event$message2 = event.message) === null || _event$message2 === void 0 ? void 0 : _event$message2.parent_id) === _this.id && event.hard_delete) {
|
|
7553
|
+
return _this.deleteReplyLocally({
|
|
7554
|
+
message: event.message
|
|
7555
|
+
});
|
|
7556
|
+
}
|
|
7557
|
+
}).unsubscribe;
|
|
7558
|
+
});
|
|
7559
|
+
|
|
7560
|
+
_defineProperty(this, "subscribeMessageUpdated", function () {
|
|
7561
|
+
var unsubscribeFunctions = ['message.updated', 'reaction.new', 'reaction.deleted'].map(function (eventType) {
|
|
7562
|
+
return _this.client.on(eventType, function (event) {
|
|
7563
|
+
if (event.message) {
|
|
7564
|
+
_this.updateParentMessageOrReplyLocally(event.message);
|
|
7565
|
+
}
|
|
7566
|
+
}).unsubscribe;
|
|
7567
|
+
});
|
|
7568
|
+
return function () {
|
|
7569
|
+
return unsubscribeFunctions.forEach(function (unsubscribe) {
|
|
7570
|
+
return unsubscribe();
|
|
7571
|
+
});
|
|
7572
|
+
};
|
|
7573
|
+
});
|
|
7574
|
+
|
|
7575
|
+
_defineProperty(this, "unregisterSubscriptions", function () {
|
|
7576
|
+
_this.unsubscribeFunctions.forEach(function (cleanupFunction) {
|
|
7577
|
+
return cleanupFunction();
|
|
7578
|
+
});
|
|
7579
|
+
|
|
7580
|
+
_this.unsubscribeFunctions.clear();
|
|
7581
|
+
});
|
|
7582
|
+
|
|
7583
|
+
_defineProperty(this, "deleteReplyLocally", function (_ref7) {
|
|
7584
|
+
var _replies$index, _replies;
|
|
7585
|
+
|
|
7586
|
+
var message = _ref7.message;
|
|
7587
|
+
|
|
7588
|
+
var _this$state$getLatest3 = _this.state.getLatestValue(),
|
|
7589
|
+
replies = _this$state$getLatest3.replies;
|
|
7590
|
+
|
|
7591
|
+
var index = findIndexInSortedArray({
|
|
7592
|
+
needle: formatMessage(message),
|
|
7593
|
+
sortedArray: replies,
|
|
7594
|
+
sortDirection: 'ascending',
|
|
7595
|
+
selectValueToCompare: function selectValueToCompare(reply) {
|
|
7596
|
+
return reply.created_at.getTime();
|
|
7597
|
+
}
|
|
7598
|
+
});
|
|
7599
|
+
var actualIndex = ((_replies$index = replies[index]) === null || _replies$index === void 0 ? void 0 : _replies$index.id) === message.id ? index : ((_replies = replies[index - 1]) === null || _replies === void 0 ? void 0 : _replies.id) === message.id ? index - 1 : null;
|
|
7600
|
+
|
|
7601
|
+
if (actualIndex === null) {
|
|
7602
|
+
return;
|
|
7603
|
+
}
|
|
7604
|
+
|
|
7605
|
+
var updatedReplies = _toConsumableArray(replies);
|
|
7606
|
+
|
|
7607
|
+
updatedReplies.splice(actualIndex, 1);
|
|
7608
|
+
|
|
7609
|
+
_this.state.partialNext({
|
|
7610
|
+
replies: updatedReplies
|
|
7611
|
+
});
|
|
7612
|
+
});
|
|
7613
|
+
|
|
7614
|
+
_defineProperty(this, "upsertReplyLocally", function (_ref8) {
|
|
7615
|
+
var message = _ref8.message,
|
|
7616
|
+
_ref8$timestampChange = _ref8.timestampChanged,
|
|
7617
|
+
timestampChanged = _ref8$timestampChange === void 0 ? false : _ref8$timestampChange;
|
|
7618
|
+
|
|
7619
|
+
if (message.parent_id !== _this.id) {
|
|
7620
|
+
throw new Error('Reply does not belong to this thread');
|
|
7621
|
+
}
|
|
7622
|
+
|
|
7623
|
+
var formattedMessage = formatMessage(message);
|
|
7624
|
+
|
|
7625
|
+
if (message.status === 'failed') {
|
|
7626
|
+
// store failed reply so that it's not lost when reloading or hydrating
|
|
7627
|
+
_this.failedRepliesMap.set(formattedMessage.id, formattedMessage);
|
|
7628
|
+
} else if (_this.failedRepliesMap.has(message.id)) {
|
|
7629
|
+
_this.failedRepliesMap.delete(message.id);
|
|
7630
|
+
}
|
|
7631
|
+
|
|
7632
|
+
_this.state.next(function (current) {
|
|
7633
|
+
return _objectSpread$3(_objectSpread$3({}, current), {}, {
|
|
7634
|
+
replies: addToMessageList(current.replies, formattedMessage, timestampChanged)
|
|
7635
|
+
});
|
|
7636
|
+
});
|
|
7637
|
+
});
|
|
7638
|
+
|
|
7639
|
+
_defineProperty(this, "updateParentMessageLocally", function (message) {
|
|
7640
|
+
if (message.id !== _this.id) {
|
|
7641
|
+
throw new Error('Message does not belong to this thread');
|
|
7642
|
+
}
|
|
7643
|
+
|
|
7644
|
+
_this.state.next(function (current) {
|
|
7645
|
+
var _message$reply_count;
|
|
7646
|
+
|
|
7647
|
+
var formattedMessage = formatMessage(message);
|
|
7648
|
+
|
|
7649
|
+
var newData = _objectSpread$3(_objectSpread$3({}, current), {}, {
|
|
7650
|
+
deletedAt: formattedMessage.deleted_at,
|
|
7651
|
+
parentMessage: formattedMessage,
|
|
7652
|
+
replyCount: (_message$reply_count = message.reply_count) !== null && _message$reply_count !== void 0 ? _message$reply_count : current.replyCount
|
|
7653
|
+
}); // update channel on channelData change (unlikely but handled anyway)
|
|
7654
|
+
|
|
7655
|
+
|
|
7656
|
+
if (message.channel) {
|
|
7657
|
+
newData['channel'] = _this.client.channel(message.channel.type, message.channel.id, message.channel);
|
|
7658
|
+
}
|
|
7659
|
+
|
|
7660
|
+
return newData;
|
|
7661
|
+
});
|
|
7662
|
+
});
|
|
7663
|
+
|
|
7664
|
+
_defineProperty(this, "updateParentMessageOrReplyLocally", function (message) {
|
|
7665
|
+
if (message.parent_id === _this.id) {
|
|
7666
|
+
_this.upsertReplyLocally({
|
|
7667
|
+
message: message
|
|
7668
|
+
});
|
|
7669
|
+
}
|
|
7670
|
+
|
|
7671
|
+
if (!message.parent_id && message.id === _this.id) {
|
|
7672
|
+
_this.updateParentMessageLocally(message);
|
|
7673
|
+
}
|
|
7674
|
+
});
|
|
7675
|
+
|
|
7676
|
+
_defineProperty(this, "markAsRead", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
7677
|
+
var _ref10,
|
|
7678
|
+
_ref10$force,
|
|
7679
|
+
force,
|
|
7680
|
+
_args2 = arguments;
|
|
7681
|
+
|
|
7682
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
7683
|
+
while (1) {
|
|
7684
|
+
switch (_context2.prev = _context2.next) {
|
|
7685
|
+
case 0:
|
|
7686
|
+
_ref10 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref10$force = _ref10.force, force = _ref10$force === void 0 ? false : _ref10$force;
|
|
7687
|
+
|
|
7688
|
+
if (!(_this.ownUnreadCount === 0 && !force)) {
|
|
7689
|
+
_context2.next = 3;
|
|
7690
|
+
break;
|
|
7691
|
+
}
|
|
7692
|
+
|
|
7693
|
+
return _context2.abrupt("return", null);
|
|
7694
|
+
|
|
7695
|
+
case 3:
|
|
7696
|
+
_context2.next = 5;
|
|
7697
|
+
return _this.channel.markRead({
|
|
7698
|
+
thread_id: _this.id
|
|
7699
|
+
});
|
|
7700
|
+
|
|
7701
|
+
case 5:
|
|
7702
|
+
return _context2.abrupt("return", _context2.sent);
|
|
7703
|
+
|
|
7704
|
+
case 6:
|
|
7705
|
+
case "end":
|
|
7706
|
+
return _context2.stop();
|
|
7707
|
+
}
|
|
7708
|
+
}
|
|
7709
|
+
}, _callee2);
|
|
7710
|
+
})));
|
|
7711
|
+
|
|
7712
|
+
_defineProperty(this, "throttledMarkAsRead", throttle(function () {
|
|
7713
|
+
return _this.markAsRead();
|
|
7714
|
+
}, MARK_AS_READ_THROTTLE_TIMEOUT, {
|
|
7715
|
+
trailing: true
|
|
7716
|
+
}));
|
|
7717
|
+
|
|
7718
|
+
_defineProperty(this, "queryReplies", function () {
|
|
7719
|
+
var _ref11 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7720
|
+
|
|
7721
|
+
var _ref11$limit = _ref11.limit,
|
|
7722
|
+
limit = _ref11$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref11$limit,
|
|
7723
|
+
_ref11$sort = _ref11.sort,
|
|
7724
|
+
sort = _ref11$sort === void 0 ? DEFAULT_SORT : _ref11$sort,
|
|
7725
|
+
otherOptions = _objectWithoutProperties(_ref11, _excluded$1);
|
|
7726
|
+
|
|
7727
|
+
return _this.channel.getReplies(_this.id, _objectSpread$3({
|
|
7728
|
+
limit: limit
|
|
7729
|
+
}, otherOptions), sort);
|
|
7730
|
+
});
|
|
7731
|
+
|
|
7732
|
+
_defineProperty(this, "loadNextPage", function () {
|
|
7733
|
+
var _ref12 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
7734
|
+
_ref12$limit = _ref12.limit,
|
|
7735
|
+
limit = _ref12$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref12$limit;
|
|
7736
|
+
|
|
7737
|
+
return _this.loadPage(limit);
|
|
7738
|
+
});
|
|
7739
|
+
|
|
7740
|
+
_defineProperty(this, "loadPrevPage", function () {
|
|
7741
|
+
var _ref13 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
7742
|
+
_ref13$limit = _ref13.limit,
|
|
7743
|
+
limit = _ref13$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref13$limit;
|
|
7744
|
+
|
|
7745
|
+
return _this.loadPage(-limit);
|
|
7746
|
+
});
|
|
7747
|
+
|
|
7748
|
+
_defineProperty(this, "loadPage", /*#__PURE__*/function () {
|
|
7749
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(count) {
|
|
7750
|
+
var _this$state$getLatest4, pagination, _ref15, _ref16, loadingKey, cursorKey, insertionMethodKey, queryOptions, limit, _replies$at$id, _replies$at, data, replies, maybeNextCursor;
|
|
7751
|
+
|
|
7752
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
7753
|
+
while (1) {
|
|
7754
|
+
switch (_context3.prev = _context3.next) {
|
|
7755
|
+
case 0:
|
|
7756
|
+
_this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
|
|
7757
|
+
_ref15 = count > 0 ? ['isLoadingNext', 'nextCursor', 'push'] : ['isLoadingPrev', 'prevCursor', 'unshift'], _ref16 = _slicedToArray(_ref15, 3), loadingKey = _ref16[0], cursorKey = _ref16[1], insertionMethodKey = _ref16[2];
|
|
7758
|
+
|
|
7759
|
+
if (!(pagination[loadingKey] || pagination[cursorKey] === null)) {
|
|
7760
|
+
_context3.next = 4;
|
|
7761
|
+
break;
|
|
7762
|
+
}
|
|
7763
|
+
|
|
7764
|
+
return _context3.abrupt("return");
|
|
7765
|
+
|
|
7766
|
+
case 4:
|
|
7767
|
+
queryOptions = _defineProperty({}, count > 0 ? 'id_gt' : 'id_lt', pagination[cursorKey]);
|
|
7768
|
+
limit = Math.abs(count);
|
|
7769
|
+
|
|
7770
|
+
_this.state.partialNext({
|
|
7771
|
+
pagination: _objectSpread$3(_objectSpread$3({}, pagination), {}, _defineProperty({}, loadingKey, true))
|
|
7772
|
+
});
|
|
7773
|
+
|
|
7774
|
+
_context3.prev = 7;
|
|
7775
|
+
_context3.next = 10;
|
|
7776
|
+
return _this.queryReplies(_objectSpread$3(_objectSpread$3({}, queryOptions), {}, {
|
|
7777
|
+
limit: limit
|
|
7778
|
+
}));
|
|
7779
|
+
|
|
7780
|
+
case 10:
|
|
7781
|
+
data = _context3.sent;
|
|
7782
|
+
replies = data.messages.map(formatMessage);
|
|
7783
|
+
maybeNextCursor = (_replies$at$id = (_replies$at = replies.at(count > 0 ? -1 : 0)) === null || _replies$at === void 0 ? void 0 : _replies$at.id) !== null && _replies$at$id !== void 0 ? _replies$at$id : null;
|
|
7784
|
+
|
|
7785
|
+
_this.state.next(function (current) {
|
|
7786
|
+
var _objectSpread4;
|
|
7787
|
+
|
|
7788
|
+
var nextReplies = current.replies; // prevent re-creating array if there's nothing to add to the current one
|
|
7789
|
+
|
|
7790
|
+
if (replies.length > 0) {
|
|
7791
|
+
var _nextReplies;
|
|
7792
|
+
|
|
7793
|
+
nextReplies = _toConsumableArray(current.replies);
|
|
7794
|
+
|
|
7795
|
+
(_nextReplies = nextReplies)[insertionMethodKey].apply(_nextReplies, _toConsumableArray(replies));
|
|
7796
|
+
}
|
|
7797
|
+
|
|
7798
|
+
return _objectSpread$3(_objectSpread$3({}, current), {}, {
|
|
7799
|
+
replies: nextReplies,
|
|
7800
|
+
pagination: _objectSpread$3(_objectSpread$3({}, current.pagination), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, cursorKey, data.messages.length < limit ? null : maybeNextCursor), _defineProperty(_objectSpread4, loadingKey, false), _objectSpread4))
|
|
7801
|
+
});
|
|
7802
|
+
});
|
|
7803
|
+
|
|
7804
|
+
_context3.next = 20;
|
|
7805
|
+
break;
|
|
7806
|
+
|
|
7807
|
+
case 16:
|
|
7808
|
+
_context3.prev = 16;
|
|
7809
|
+
_context3.t0 = _context3["catch"](7);
|
|
7810
|
+
|
|
7811
|
+
_this.client.logger('error', _context3.t0.message);
|
|
7812
|
+
|
|
7813
|
+
_this.state.next(function (current) {
|
|
7814
|
+
return _objectSpread$3(_objectSpread$3({}, current), {}, {
|
|
7815
|
+
pagination: _objectSpread$3(_objectSpread$3({}, current.pagination), {}, _defineProperty({}, loadingKey, false))
|
|
7816
|
+
});
|
|
7817
|
+
});
|
|
7818
|
+
|
|
7819
|
+
case 20:
|
|
7820
|
+
case "end":
|
|
7821
|
+
return _context3.stop();
|
|
7822
|
+
}
|
|
7823
|
+
}
|
|
7824
|
+
}, _callee3, null, [[7, 16]]);
|
|
7825
|
+
}));
|
|
7826
|
+
|
|
7827
|
+
return function (_x) {
|
|
7828
|
+
return _ref14.apply(this, arguments);
|
|
7829
|
+
};
|
|
7830
|
+
}());
|
|
7831
|
+
|
|
7832
|
+
this.state = new StateStore({
|
|
7833
|
+
active: false,
|
|
7834
|
+
channel: client.channel(threadData.channel.type, threadData.channel.id),
|
|
7835
|
+
createdAt: new Date(threadData.created_at),
|
|
7836
|
+
deletedAt: threadData.deleted_at ? new Date(threadData.deleted_at) : null,
|
|
7837
|
+
isLoading: false,
|
|
7838
|
+
isStateStale: false,
|
|
7839
|
+
pagination: repliesPaginationFromInitialThread(threadData),
|
|
7840
|
+
parentMessage: formatMessage(threadData.parent_message),
|
|
7841
|
+
participants: threadData.thread_participants,
|
|
7842
|
+
read: formatReadState((_threadData$read = threadData.read) !== null && _threadData$read !== void 0 ? _threadData$read : []),
|
|
7843
|
+
replies: threadData.latest_replies.map(formatMessage),
|
|
7844
|
+
replyCount: (_threadData$reply_cou = threadData.reply_count) !== null && _threadData$reply_cou !== void 0 ? _threadData$reply_cou : 0,
|
|
7845
|
+
updatedAt: threadData.updated_at ? new Date(threadData.updated_at) : null
|
|
7846
|
+
});
|
|
7847
|
+
this.id = threadData.parent_message_id;
|
|
7848
|
+
this.client = client;
|
|
7849
|
+
}
|
|
7850
|
+
|
|
7851
|
+
_createClass(Thread, [{
|
|
7852
|
+
key: "channel",
|
|
7853
|
+
get: function get() {
|
|
7854
|
+
return this.state.getLatestValue().channel;
|
|
7855
|
+
}
|
|
7856
|
+
}, {
|
|
7857
|
+
key: "hasStaleState",
|
|
7858
|
+
get: function get() {
|
|
7859
|
+
return this.state.getLatestValue().isStateStale;
|
|
7860
|
+
}
|
|
7861
|
+
}, {
|
|
7862
|
+
key: "ownUnreadCount",
|
|
7863
|
+
get: function get() {
|
|
7864
|
+
return ownUnreadCountSelector(this.client.userID)(this.state.getLatestValue());
|
|
7865
|
+
}
|
|
7866
|
+
}]);
|
|
7867
|
+
|
|
7868
|
+
return Thread;
|
|
7869
|
+
}();
|
|
7870
|
+
|
|
7871
|
+
var formatReadState = function formatReadState(read) {
|
|
7872
|
+
return read.reduce(function (state, userRead) {
|
|
7873
|
+
var _userRead$unread_mess;
|
|
7874
|
+
|
|
7875
|
+
state[userRead.user.id] = {
|
|
7876
|
+
user: userRead.user,
|
|
7877
|
+
lastReadMessageId: userRead.last_read_message_id,
|
|
7878
|
+
unreadMessageCount: (_userRead$unread_mess = userRead.unread_messages) !== null && _userRead$unread_mess !== void 0 ? _userRead$unread_mess : 0,
|
|
7879
|
+
lastReadAt: new Date(userRead.last_read)
|
|
7880
|
+
};
|
|
7881
|
+
return state;
|
|
7882
|
+
}, {});
|
|
7883
|
+
};
|
|
7884
|
+
|
|
7885
|
+
var repliesPaginationFromInitialThread = function repliesPaginationFromInitialThread(thread) {
|
|
7886
|
+
var _thread$latest_replie, _thread$latest_replie2;
|
|
7887
|
+
|
|
7888
|
+
var latestRepliesContainsAllReplies = thread.latest_replies.length === thread.reply_count;
|
|
7889
|
+
return {
|
|
7890
|
+
nextCursor: null,
|
|
7891
|
+
prevCursor: latestRepliesContainsAllReplies ? null : (_thread$latest_replie = (_thread$latest_replie2 = thread.latest_replies.at(0)) === null || _thread$latest_replie2 === void 0 ? void 0 : _thread$latest_replie2.id) !== null && _thread$latest_replie !== void 0 ? _thread$latest_replie : null,
|
|
7892
|
+
isLoadingNext: false,
|
|
7893
|
+
isLoadingPrev: false
|
|
7894
|
+
};
|
|
7895
|
+
};
|
|
7896
|
+
|
|
7897
|
+
var ownUnreadCountSelector = function ownUnreadCountSelector(currentUserId) {
|
|
7898
|
+
return function (state) {
|
|
7899
|
+
var _state$read$currentUs;
|
|
7900
|
+
|
|
7901
|
+
return currentUserId && ((_state$read$currentUs = state.read[currentUserId]) === null || _state$read$currentUs === void 0 ? void 0 : _state$read$currentUs.unreadMessageCount) || 0;
|
|
7902
|
+
};
|
|
7903
|
+
};
|
|
7904
|
+
|
|
7905
|
+
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; }
|
|
7906
|
+
|
|
7907
|
+
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; }
|
|
7076
7908
|
var MODERATION_ENTITY_TYPES = {
|
|
7077
7909
|
user: 'stream:user',
|
|
7078
7910
|
message: 'stream:chat:v1:message'
|
|
@@ -7189,7 +8021,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
7189
8021
|
case 0:
|
|
7190
8022
|
options = _args3.length > 4 && _args3[4] !== undefined ? _args3[4] : {};
|
|
7191
8023
|
_context3.next = 3;
|
|
7192
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/flag', _objectSpread$
|
|
8024
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/flag', _objectSpread$2({
|
|
7193
8025
|
entity_type: entityType,
|
|
7194
8026
|
entity_id: entityId,
|
|
7195
8027
|
entity_creator_id: entityCreatorID,
|
|
@@ -7234,7 +8066,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
7234
8066
|
case 0:
|
|
7235
8067
|
options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
7236
8068
|
_context4.next = 3;
|
|
7237
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/mute', _objectSpread$
|
|
8069
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/mute', _objectSpread$2({
|
|
7238
8070
|
target_ids: [targetID]
|
|
7239
8071
|
}, options));
|
|
7240
8072
|
|
|
@@ -7272,7 +8104,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
7272
8104
|
switch (_context5.prev = _context5.next) {
|
|
7273
8105
|
case 0:
|
|
7274
8106
|
_context5.next = 2;
|
|
7275
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/unmute', _objectSpread$
|
|
8107
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/unmute', _objectSpread$2({
|
|
7276
8108
|
target_ids: [targetID]
|
|
7277
8109
|
}, options));
|
|
7278
8110
|
|
|
@@ -7314,7 +8146,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
7314
8146
|
case 0:
|
|
7315
8147
|
options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
7316
8148
|
_context6.next = 3;
|
|
7317
|
-
return this.client.get(this.client.baseURL + "/api/v2/moderation/user_report", _objectSpread$
|
|
8149
|
+
return this.client.get(this.client.baseURL + "/api/v2/moderation/user_report", _objectSpread$2({
|
|
7318
8150
|
user_id: userID
|
|
7319
8151
|
}, options));
|
|
7320
8152
|
|
|
@@ -7358,7 +8190,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
7358
8190
|
sort = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : [];
|
|
7359
8191
|
options = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : {};
|
|
7360
8192
|
_context7.next = 5;
|
|
7361
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/review_queue', _objectSpread$
|
|
8193
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/review_queue', _objectSpread$2({
|
|
7362
8194
|
filter: filterConditions,
|
|
7363
8195
|
sort: normalizeQuerySort(sort)
|
|
7364
8196
|
}, options));
|
|
@@ -7461,7 +8293,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
7461
8293
|
case 0:
|
|
7462
8294
|
options = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : {};
|
|
7463
8295
|
_context10.next = 3;
|
|
7464
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/submit_action', _objectSpread$
|
|
8296
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/submit_action', _objectSpread$2({
|
|
7465
8297
|
action_type: actionType,
|
|
7466
8298
|
item_id: itemID
|
|
7467
8299
|
}, options));
|
|
@@ -7488,6 +8320,454 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
7488
8320
|
return Moderation;
|
|
7489
8321
|
}();
|
|
7490
8322
|
|
|
8323
|
+
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; } } }; }
|
|
8324
|
+
|
|
8325
|
+
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); }
|
|
8326
|
+
|
|
8327
|
+
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; }
|
|
8328
|
+
|
|
8329
|
+
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; }
|
|
8330
|
+
|
|
8331
|
+
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; }
|
|
8332
|
+
var DEFAULT_CONNECTION_RECOVERY_THROTTLE_DURATION = 1000;
|
|
8333
|
+
var MAX_QUERY_THREADS_LIMIT = 25;
|
|
8334
|
+
var ThreadManager = /*#__PURE__*/function () {
|
|
8335
|
+
function ThreadManager(_ref) {
|
|
8336
|
+
var _this = this;
|
|
8337
|
+
|
|
8338
|
+
var client = _ref.client;
|
|
8339
|
+
|
|
8340
|
+
_classCallCheck(this, ThreadManager);
|
|
8341
|
+
|
|
8342
|
+
_defineProperty(this, "state", void 0);
|
|
8343
|
+
|
|
8344
|
+
_defineProperty(this, "client", void 0);
|
|
8345
|
+
|
|
8346
|
+
_defineProperty(this, "unsubscribeFunctions", new Set());
|
|
8347
|
+
|
|
8348
|
+
_defineProperty(this, "threadsByIdGetterCache", void 0);
|
|
8349
|
+
|
|
8350
|
+
_defineProperty(this, "activate", function () {
|
|
8351
|
+
_this.state.partialNext({
|
|
8352
|
+
active: true
|
|
8353
|
+
});
|
|
8354
|
+
});
|
|
8355
|
+
|
|
8356
|
+
_defineProperty(this, "deactivate", function () {
|
|
8357
|
+
_this.state.partialNext({
|
|
8358
|
+
active: false
|
|
8359
|
+
});
|
|
8360
|
+
});
|
|
8361
|
+
|
|
8362
|
+
_defineProperty(this, "registerSubscriptions", function () {
|
|
8363
|
+
if (_this.unsubscribeFunctions.size) return;
|
|
8364
|
+
|
|
8365
|
+
_this.unsubscribeFunctions.add(_this.subscribeUnreadThreadsCountChange());
|
|
8366
|
+
|
|
8367
|
+
_this.unsubscribeFunctions.add(_this.subscribeManageThreadSubscriptions());
|
|
8368
|
+
|
|
8369
|
+
_this.unsubscribeFunctions.add(_this.subscribeReloadOnActivation());
|
|
8370
|
+
|
|
8371
|
+
_this.unsubscribeFunctions.add(_this.subscribeNewReplies());
|
|
8372
|
+
|
|
8373
|
+
_this.unsubscribeFunctions.add(_this.subscribeRecoverAfterConnectionDrop());
|
|
8374
|
+
});
|
|
8375
|
+
|
|
8376
|
+
_defineProperty(this, "subscribeUnreadThreadsCountChange", function () {
|
|
8377
|
+
var _ref3;
|
|
8378
|
+
|
|
8379
|
+
// initiate
|
|
8380
|
+
var _ref2 = (_ref3 = _this.client.user) !== null && _ref3 !== void 0 ? _ref3 : {},
|
|
8381
|
+
_ref2$unread_threads = _ref2.unread_threads,
|
|
8382
|
+
unreadThreadCount = _ref2$unread_threads === void 0 ? 0 : _ref2$unread_threads;
|
|
8383
|
+
|
|
8384
|
+
_this.state.partialNext({
|
|
8385
|
+
unreadThreadCount: unreadThreadCount
|
|
8386
|
+
});
|
|
8387
|
+
|
|
8388
|
+
var unsubscribeFunctions = ['health.check', 'notification.mark_read', 'notification.thread_message_new', 'notification.channel_deleted'].map(function (eventType) {
|
|
8389
|
+
return _this.client.on(eventType, function (event) {
|
|
8390
|
+
var _event$me;
|
|
8391
|
+
|
|
8392
|
+
var _ref4 = (_event$me = event.me) !== null && _event$me !== void 0 ? _event$me : event,
|
|
8393
|
+
unreadThreadCount = _ref4.unread_threads;
|
|
8394
|
+
|
|
8395
|
+
if (typeof unreadThreadCount === 'number') {
|
|
8396
|
+
_this.state.partialNext({
|
|
8397
|
+
unreadThreadCount: unreadThreadCount
|
|
8398
|
+
});
|
|
8399
|
+
}
|
|
8400
|
+
}).unsubscribe;
|
|
8401
|
+
});
|
|
8402
|
+
return function () {
|
|
8403
|
+
return unsubscribeFunctions.forEach(function (unsubscribe) {
|
|
8404
|
+
return unsubscribe();
|
|
8405
|
+
});
|
|
8406
|
+
};
|
|
8407
|
+
});
|
|
8408
|
+
|
|
8409
|
+
_defineProperty(this, "subscribeManageThreadSubscriptions", function () {
|
|
8410
|
+
return _this.state.subscribeWithSelector(function (nextValue) {
|
|
8411
|
+
return [nextValue.threads];
|
|
8412
|
+
}, function (_ref5, prev) {
|
|
8413
|
+
var _ref6 = _slicedToArray(_ref5, 1),
|
|
8414
|
+
nextThreads = _ref6[0];
|
|
8415
|
+
|
|
8416
|
+
var _ref7 = prev !== null && prev !== void 0 ? prev : [],
|
|
8417
|
+
_ref8 = _slicedToArray(_ref7, 1),
|
|
8418
|
+
_ref8$ = _ref8[0],
|
|
8419
|
+
prevThreads = _ref8$ === void 0 ? [] : _ref8$; // Thread instance was removed if there's no thread with the given id at all,
|
|
8420
|
+
// or it was replaced with a new instance
|
|
8421
|
+
|
|
8422
|
+
|
|
8423
|
+
var removedThreads = prevThreads.filter(function (thread) {
|
|
8424
|
+
return thread !== _this.threadsById[thread.id];
|
|
8425
|
+
});
|
|
8426
|
+
nextThreads.forEach(function (thread) {
|
|
8427
|
+
return thread.registerSubscriptions();
|
|
8428
|
+
});
|
|
8429
|
+
removedThreads.forEach(function (thread) {
|
|
8430
|
+
return thread.unregisterSubscriptions();
|
|
8431
|
+
});
|
|
8432
|
+
});
|
|
8433
|
+
});
|
|
8434
|
+
|
|
8435
|
+
_defineProperty(this, "subscribeReloadOnActivation", function () {
|
|
8436
|
+
return _this.state.subscribeWithSelector(function (nextValue) {
|
|
8437
|
+
return [nextValue.active];
|
|
8438
|
+
}, function (_ref9) {
|
|
8439
|
+
var _ref10 = _slicedToArray(_ref9, 1),
|
|
8440
|
+
active = _ref10[0];
|
|
8441
|
+
|
|
8442
|
+
if (active) _this.reload();
|
|
8443
|
+
});
|
|
8444
|
+
});
|
|
8445
|
+
|
|
8446
|
+
_defineProperty(this, "subscribeNewReplies", function () {
|
|
8447
|
+
return _this.client.on('notification.thread_message_new', function (event) {
|
|
8448
|
+
var _event$message;
|
|
8449
|
+
|
|
8450
|
+
var parentId = (_event$message = event.message) === null || _event$message === void 0 ? void 0 : _event$message.parent_id;
|
|
8451
|
+
if (!parentId) return;
|
|
8452
|
+
|
|
8453
|
+
var _this$state$getLatest = _this.state.getLatestValue(),
|
|
8454
|
+
unseenThreadIds = _this$state$getLatest.unseenThreadIds,
|
|
8455
|
+
ready = _this$state$getLatest.ready;
|
|
8456
|
+
|
|
8457
|
+
if (!ready) return;
|
|
8458
|
+
|
|
8459
|
+
if (_this.threadsById[parentId]) {
|
|
8460
|
+
_this.state.partialNext({
|
|
8461
|
+
isThreadOrderStale: true
|
|
8462
|
+
});
|
|
8463
|
+
} else if (!unseenThreadIds.includes(parentId)) {
|
|
8464
|
+
_this.state.partialNext({
|
|
8465
|
+
unseenThreadIds: unseenThreadIds.concat(parentId)
|
|
8466
|
+
});
|
|
8467
|
+
}
|
|
8468
|
+
}).unsubscribe;
|
|
8469
|
+
});
|
|
8470
|
+
|
|
8471
|
+
_defineProperty(this, "subscribeRecoverAfterConnectionDrop", function () {
|
|
8472
|
+
var unsubscribeConnectionDropped = _this.client.on('connection.changed', function (event) {
|
|
8473
|
+
if (event.online === false) {
|
|
8474
|
+
_this.state.next(function (current) {
|
|
8475
|
+
return current.lastConnectionDropAt ? current : _objectSpread$1(_objectSpread$1({}, current), {}, {
|
|
8476
|
+
lastConnectionDropAt: new Date()
|
|
8477
|
+
});
|
|
8478
|
+
});
|
|
8479
|
+
}
|
|
8480
|
+
}).unsubscribe;
|
|
8481
|
+
|
|
8482
|
+
var throttledHandleConnectionRecovered = throttle(function () {
|
|
8483
|
+
var _this$state$getLatest2 = _this.state.getLatestValue(),
|
|
8484
|
+
lastConnectionDropAt = _this$state$getLatest2.lastConnectionDropAt;
|
|
8485
|
+
|
|
8486
|
+
if (!lastConnectionDropAt) return;
|
|
8487
|
+
|
|
8488
|
+
_this.reload({
|
|
8489
|
+
force: true
|
|
8490
|
+
});
|
|
8491
|
+
}, DEFAULT_CONNECTION_RECOVERY_THROTTLE_DURATION, {
|
|
8492
|
+
trailing: true
|
|
8493
|
+
});
|
|
8494
|
+
|
|
8495
|
+
var unsubscribeConnectionRecovered = _this.client.on('connection.recovered', throttledHandleConnectionRecovered).unsubscribe;
|
|
8496
|
+
|
|
8497
|
+
return function () {
|
|
8498
|
+
unsubscribeConnectionDropped();
|
|
8499
|
+
unsubscribeConnectionRecovered();
|
|
8500
|
+
};
|
|
8501
|
+
});
|
|
8502
|
+
|
|
8503
|
+
_defineProperty(this, "unregisterSubscriptions", function () {
|
|
8504
|
+
_this.state.getLatestValue().threads.forEach(function (thread) {
|
|
8505
|
+
return thread.unregisterSubscriptions();
|
|
8506
|
+
});
|
|
8507
|
+
|
|
8508
|
+
_this.unsubscribeFunctions.forEach(function (cleanupFunction) {
|
|
8509
|
+
return cleanupFunction();
|
|
8510
|
+
});
|
|
8511
|
+
|
|
8512
|
+
_this.unsubscribeFunctions.clear();
|
|
8513
|
+
});
|
|
8514
|
+
|
|
8515
|
+
_defineProperty(this, "reload", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
8516
|
+
var _ref12,
|
|
8517
|
+
_ref12$force,
|
|
8518
|
+
force,
|
|
8519
|
+
_this$state$getLatest3,
|
|
8520
|
+
threads,
|
|
8521
|
+
unseenThreadIds,
|
|
8522
|
+
isThreadOrderStale,
|
|
8523
|
+
pagination,
|
|
8524
|
+
ready,
|
|
8525
|
+
limit,
|
|
8526
|
+
response,
|
|
8527
|
+
currentThreads,
|
|
8528
|
+
nextThreads,
|
|
8529
|
+
_iterator,
|
|
8530
|
+
_step,
|
|
8531
|
+
incomingThread,
|
|
8532
|
+
existingThread,
|
|
8533
|
+
_args = arguments;
|
|
8534
|
+
|
|
8535
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
8536
|
+
while (1) {
|
|
8537
|
+
switch (_context.prev = _context.next) {
|
|
8538
|
+
case 0:
|
|
8539
|
+
_ref12 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, _ref12$force = _ref12.force, force = _ref12$force === void 0 ? false : _ref12$force;
|
|
8540
|
+
_this$state$getLatest3 = _this.state.getLatestValue(), threads = _this$state$getLatest3.threads, unseenThreadIds = _this$state$getLatest3.unseenThreadIds, isThreadOrderStale = _this$state$getLatest3.isThreadOrderStale, pagination = _this$state$getLatest3.pagination, ready = _this$state$getLatest3.ready;
|
|
8541
|
+
|
|
8542
|
+
if (!pagination.isLoading) {
|
|
8543
|
+
_context.next = 4;
|
|
8544
|
+
break;
|
|
8545
|
+
}
|
|
8546
|
+
|
|
8547
|
+
return _context.abrupt("return");
|
|
8548
|
+
|
|
8549
|
+
case 4:
|
|
8550
|
+
if (!(!force && ready && !unseenThreadIds.length && !isThreadOrderStale)) {
|
|
8551
|
+
_context.next = 6;
|
|
8552
|
+
break;
|
|
8553
|
+
}
|
|
8554
|
+
|
|
8555
|
+
return _context.abrupt("return");
|
|
8556
|
+
|
|
8557
|
+
case 6:
|
|
8558
|
+
limit = threads.length + unseenThreadIds.length;
|
|
8559
|
+
_context.prev = 7;
|
|
8560
|
+
|
|
8561
|
+
_this.state.next(function (current) {
|
|
8562
|
+
return _objectSpread$1(_objectSpread$1({}, current), {}, {
|
|
8563
|
+
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8564
|
+
isLoading: true
|
|
8565
|
+
})
|
|
8566
|
+
});
|
|
8567
|
+
});
|
|
8568
|
+
|
|
8569
|
+
_context.next = 11;
|
|
8570
|
+
return _this.queryThreads({
|
|
8571
|
+
limit: Math.min(limit, MAX_QUERY_THREADS_LIMIT)
|
|
8572
|
+
});
|
|
8573
|
+
|
|
8574
|
+
case 11:
|
|
8575
|
+
response = _context.sent;
|
|
8576
|
+
currentThreads = _this.threadsById;
|
|
8577
|
+
nextThreads = [];
|
|
8578
|
+
_iterator = _createForOfIteratorHelper$1(response.threads);
|
|
8579
|
+
|
|
8580
|
+
try {
|
|
8581
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
8582
|
+
incomingThread = _step.value;
|
|
8583
|
+
existingThread = currentThreads[incomingThread.id];
|
|
8584
|
+
|
|
8585
|
+
if (existingThread) {
|
|
8586
|
+
// Reuse thread instances if possible
|
|
8587
|
+
nextThreads.push(existingThread);
|
|
8588
|
+
|
|
8589
|
+
if (existingThread.hasStaleState) {
|
|
8590
|
+
existingThread.hydrateState(incomingThread);
|
|
8591
|
+
}
|
|
8592
|
+
} else {
|
|
8593
|
+
nextThreads.push(incomingThread);
|
|
8594
|
+
}
|
|
8595
|
+
}
|
|
8596
|
+
} catch (err) {
|
|
8597
|
+
_iterator.e(err);
|
|
8598
|
+
} finally {
|
|
8599
|
+
_iterator.f();
|
|
8600
|
+
}
|
|
8601
|
+
|
|
8602
|
+
_this.state.next(function (current) {
|
|
8603
|
+
var _response$next;
|
|
8604
|
+
|
|
8605
|
+
return _objectSpread$1(_objectSpread$1({}, current), {}, {
|
|
8606
|
+
threads: nextThreads,
|
|
8607
|
+
unseenThreadIds: [],
|
|
8608
|
+
isThreadOrderStale: false,
|
|
8609
|
+
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8610
|
+
isLoading: false,
|
|
8611
|
+
nextCursor: (_response$next = response.next) !== null && _response$next !== void 0 ? _response$next : null
|
|
8612
|
+
}),
|
|
8613
|
+
ready: true
|
|
8614
|
+
});
|
|
8615
|
+
});
|
|
8616
|
+
|
|
8617
|
+
_context.next = 23;
|
|
8618
|
+
break;
|
|
8619
|
+
|
|
8620
|
+
case 19:
|
|
8621
|
+
_context.prev = 19;
|
|
8622
|
+
_context.t0 = _context["catch"](7);
|
|
8623
|
+
|
|
8624
|
+
_this.client.logger('error', _context.t0.message);
|
|
8625
|
+
|
|
8626
|
+
_this.state.next(function (current) {
|
|
8627
|
+
return _objectSpread$1(_objectSpread$1({}, current), {}, {
|
|
8628
|
+
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8629
|
+
isLoading: false
|
|
8630
|
+
})
|
|
8631
|
+
});
|
|
8632
|
+
});
|
|
8633
|
+
|
|
8634
|
+
case 23:
|
|
8635
|
+
case "end":
|
|
8636
|
+
return _context.stop();
|
|
8637
|
+
}
|
|
8638
|
+
}
|
|
8639
|
+
}, _callee, null, [[7, 19]]);
|
|
8640
|
+
})));
|
|
8641
|
+
|
|
8642
|
+
_defineProperty(this, "queryThreads", function () {
|
|
8643
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8644
|
+
return _this.client.queryThreads(_objectSpread$1({
|
|
8645
|
+
limit: 25,
|
|
8646
|
+
participant_limit: 10,
|
|
8647
|
+
reply_limit: 10,
|
|
8648
|
+
watch: true
|
|
8649
|
+
}, options));
|
|
8650
|
+
});
|
|
8651
|
+
|
|
8652
|
+
_defineProperty(this, "loadNextPage", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
8653
|
+
var options,
|
|
8654
|
+
_this$state$getLatest4,
|
|
8655
|
+
pagination,
|
|
8656
|
+
response,
|
|
8657
|
+
_args2 = arguments;
|
|
8658
|
+
|
|
8659
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
8660
|
+
while (1) {
|
|
8661
|
+
switch (_context2.prev = _context2.next) {
|
|
8662
|
+
case 0:
|
|
8663
|
+
options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
8664
|
+
_this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
|
|
8665
|
+
|
|
8666
|
+
if (!(pagination.isLoadingNext || !pagination.nextCursor)) {
|
|
8667
|
+
_context2.next = 4;
|
|
8668
|
+
break;
|
|
8669
|
+
}
|
|
8670
|
+
|
|
8671
|
+
return _context2.abrupt("return");
|
|
8672
|
+
|
|
8673
|
+
case 4:
|
|
8674
|
+
_context2.prev = 4;
|
|
8675
|
+
|
|
8676
|
+
_this.state.partialNext({
|
|
8677
|
+
pagination: _objectSpread$1(_objectSpread$1({}, pagination), {}, {
|
|
8678
|
+
isLoadingNext: true
|
|
8679
|
+
})
|
|
8680
|
+
});
|
|
8681
|
+
|
|
8682
|
+
_context2.next = 8;
|
|
8683
|
+
return _this.queryThreads(_objectSpread$1(_objectSpread$1({}, options), {}, {
|
|
8684
|
+
next: pagination.nextCursor
|
|
8685
|
+
}));
|
|
8686
|
+
|
|
8687
|
+
case 8:
|
|
8688
|
+
response = _context2.sent;
|
|
8689
|
+
|
|
8690
|
+
_this.state.next(function (current) {
|
|
8691
|
+
var _response$next2;
|
|
8692
|
+
|
|
8693
|
+
return _objectSpread$1(_objectSpread$1({}, current), {}, {
|
|
8694
|
+
threads: response.threads.length ? current.threads.concat(response.threads) : current.threads,
|
|
8695
|
+
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8696
|
+
nextCursor: (_response$next2 = response.next) !== null && _response$next2 !== void 0 ? _response$next2 : null,
|
|
8697
|
+
isLoadingNext: false
|
|
8698
|
+
})
|
|
8699
|
+
});
|
|
8700
|
+
});
|
|
8701
|
+
|
|
8702
|
+
_context2.next = 16;
|
|
8703
|
+
break;
|
|
8704
|
+
|
|
8705
|
+
case 12:
|
|
8706
|
+
_context2.prev = 12;
|
|
8707
|
+
_context2.t0 = _context2["catch"](4);
|
|
8708
|
+
|
|
8709
|
+
_this.client.logger('error', _context2.t0.message);
|
|
8710
|
+
|
|
8711
|
+
_this.state.next(function (current) {
|
|
8712
|
+
return _objectSpread$1(_objectSpread$1({}, current), {}, {
|
|
8713
|
+
pagination: _objectSpread$1(_objectSpread$1({}, current.pagination), {}, {
|
|
8714
|
+
isLoadingNext: false
|
|
8715
|
+
})
|
|
8716
|
+
});
|
|
8717
|
+
});
|
|
8718
|
+
|
|
8719
|
+
case 16:
|
|
8720
|
+
case "end":
|
|
8721
|
+
return _context2.stop();
|
|
8722
|
+
}
|
|
8723
|
+
}
|
|
8724
|
+
}, _callee2, null, [[4, 12]]);
|
|
8725
|
+
})));
|
|
8726
|
+
|
|
8727
|
+
this.client = client;
|
|
8728
|
+
this.state = new StateStore({
|
|
8729
|
+
active: false,
|
|
8730
|
+
isThreadOrderStale: false,
|
|
8731
|
+
threads: [],
|
|
8732
|
+
unreadThreadCount: 0,
|
|
8733
|
+
unseenThreadIds: [],
|
|
8734
|
+
lastConnectionDropAt: null,
|
|
8735
|
+
pagination: {
|
|
8736
|
+
isLoading: false,
|
|
8737
|
+
isLoadingNext: false,
|
|
8738
|
+
nextCursor: null
|
|
8739
|
+
},
|
|
8740
|
+
ready: false
|
|
8741
|
+
});
|
|
8742
|
+
this.threadsByIdGetterCache = {
|
|
8743
|
+
threads: [],
|
|
8744
|
+
threadsById: {}
|
|
8745
|
+
};
|
|
8746
|
+
}
|
|
8747
|
+
|
|
8748
|
+
_createClass(ThreadManager, [{
|
|
8749
|
+
key: "threadsById",
|
|
8750
|
+
get: function get() {
|
|
8751
|
+
var _this$state$getLatest5 = this.state.getLatestValue(),
|
|
8752
|
+
threads = _this$state$getLatest5.threads;
|
|
8753
|
+
|
|
8754
|
+
if (threads === this.threadsByIdGetterCache.threads) {
|
|
8755
|
+
return this.threadsByIdGetterCache.threadsById;
|
|
8756
|
+
}
|
|
8757
|
+
|
|
8758
|
+
var threadsById = threads.reduce(function (newThreadsById, thread) {
|
|
8759
|
+
newThreadsById[thread.id] = thread;
|
|
8760
|
+
return newThreadsById;
|
|
8761
|
+
}, {});
|
|
8762
|
+
this.threadsByIdGetterCache.threads = threads;
|
|
8763
|
+
this.threadsByIdGetterCache.threadsById = threadsById;
|
|
8764
|
+
return threadsById;
|
|
8765
|
+
}
|
|
8766
|
+
}]);
|
|
8767
|
+
|
|
8768
|
+
return ThreadManager;
|
|
8769
|
+
}();
|
|
8770
|
+
|
|
7491
8771
|
var _excluded = ["created_at", "updated_at", "last_active", "online"],
|
|
7492
8772
|
_excluded2 = ["params", "headers"];
|
|
7493
8773
|
|
|
@@ -7516,6 +8796,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7516
8796
|
|
|
7517
8797
|
_defineProperty(this, "activeChannels", void 0);
|
|
7518
8798
|
|
|
8799
|
+
_defineProperty(this, "threads", void 0);
|
|
8800
|
+
|
|
7519
8801
|
_defineProperty(this, "anonymous", void 0);
|
|
7520
8802
|
|
|
7521
8803
|
_defineProperty(this, "persistUserOnConnectionFailure", void 0);
|
|
@@ -7747,7 +9029,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7747
9029
|
tags: ['connection', 'client']
|
|
7748
9030
|
});
|
|
7749
9031
|
|
|
7750
|
-
return _context3.abrupt("return"
|
|
9032
|
+
return _context3.abrupt("return");
|
|
7751
9033
|
|
|
7752
9034
|
case 8:
|
|
7753
9035
|
_this.clientID = "".concat(_this.userID, "--").concat(randomId());
|
|
@@ -8355,8 +9637,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8355
9637
|
this.tokenManager = new TokenManager(this.secret);
|
|
8356
9638
|
this.consecutiveFailures = 0;
|
|
8357
9639
|
this.insightMetrics = new InsightMetrics();
|
|
8358
|
-
this.defaultWSTimeoutWithFallback =
|
|
8359
|
-
this.defaultWSTimeout =
|
|
9640
|
+
this.defaultWSTimeoutWithFallback = 6 * 1000;
|
|
9641
|
+
this.defaultWSTimeout = 15 * 1000;
|
|
8360
9642
|
this.axiosInstance.defaults.paramsSerializer = axiosParamsSerializer;
|
|
8361
9643
|
/**
|
|
8362
9644
|
* logger function should accept 3 parameters:
|
|
@@ -8411,6 +9693,9 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8411
9693
|
return null;
|
|
8412
9694
|
};
|
|
8413
9695
|
this.recoverStateOnReconnect = this.options.recoverStateOnReconnect;
|
|
9696
|
+
this.threads = new ThreadManager({
|
|
9697
|
+
client: this
|
|
9698
|
+
});
|
|
8414
9699
|
}
|
|
8415
9700
|
/**
|
|
8416
9701
|
* Get a client instance
|
|
@@ -9561,7 +10846,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9561
10846
|
isLatestMessageSet: true
|
|
9562
10847
|
}
|
|
9563
10848
|
});
|
|
9564
|
-
return _context20.abrupt("return", this.hydrateActiveChannels(data.channels, stateOptions));
|
|
10849
|
+
return _context20.abrupt("return", this.hydrateActiveChannels(data.channels, stateOptions, options));
|
|
9565
10850
|
|
|
9566
10851
|
case 13:
|
|
9567
10852
|
case "end":
|
|
@@ -9611,7 +10896,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9611
10896
|
sort: normalizeQuerySort(sort)
|
|
9612
10897
|
}, options);
|
|
9613
10898
|
_context21.next = 7;
|
|
9614
|
-
return this.post(this.baseURL + '/messages/' + messageID + '/reactions', payload);
|
|
10899
|
+
return this.post(this.baseURL + '/messages/' + encodeURIComponent(messageID) + '/reactions', payload);
|
|
9615
10900
|
|
|
9616
10901
|
case 7:
|
|
9617
10902
|
return _context21.abrupt("return", _context21.sent);
|
|
@@ -9635,9 +10920,11 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9635
10920
|
value: function hydrateActiveChannels() {
|
|
9636
10921
|
var channelsFromApi = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
9637
10922
|
var stateOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
10923
|
+
var queryChannelsOptions = arguments.length > 2 ? arguments[2] : undefined;
|
|
9638
10924
|
var skipInitialization = stateOptions.skipInitialization,
|
|
9639
10925
|
_stateOptions$offline = stateOptions.offlineMode,
|
|
9640
10926
|
offlineMode = _stateOptions$offline === void 0 ? false : _stateOptions$offline;
|
|
10927
|
+
var channels = [];
|
|
9641
10928
|
|
|
9642
10929
|
var _iterator2 = _createForOfIteratorHelper(channelsFromApi),
|
|
9643
10930
|
_step2;
|
|
@@ -9647,40 +10934,42 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9647
10934
|
var channelState = _step2.value;
|
|
9648
10935
|
|
|
9649
10936
|
this._addChannelConfig(channelState.channel);
|
|
9650
|
-
}
|
|
9651
|
-
} catch (err) {
|
|
9652
|
-
_iterator2.e(err);
|
|
9653
|
-
} finally {
|
|
9654
|
-
_iterator2.f();
|
|
9655
|
-
}
|
|
9656
|
-
|
|
9657
|
-
var channels = [];
|
|
9658
10937
|
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
|
|
9662
|
-
try {
|
|
9663
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
9664
|
-
var _channelState = _step3.value;
|
|
9665
|
-
var c = this.channel(_channelState.channel.type, _channelState.channel.id);
|
|
9666
|
-
c.data = _channelState.channel;
|
|
10938
|
+
var c = this.channel(channelState.channel.type, channelState.channel.id);
|
|
10939
|
+
c.data = channelState.channel;
|
|
9667
10940
|
c.offlineMode = offlineMode;
|
|
9668
10941
|
c.initialized = !offlineMode;
|
|
10942
|
+
var updatedMessagesSet = void 0;
|
|
9669
10943
|
|
|
9670
10944
|
if (skipInitialization === undefined) {
|
|
9671
|
-
c._initializeState(
|
|
9672
|
-
|
|
10945
|
+
var _c$_initializeState = c._initializeState(channelState, 'latest'),
|
|
10946
|
+
messageSet = _c$_initializeState.messageSet;
|
|
10947
|
+
|
|
10948
|
+
updatedMessagesSet = messageSet;
|
|
10949
|
+
} else if (!skipInitialization.includes(channelState.channel.id)) {
|
|
9673
10950
|
c.state.clearMessages();
|
|
9674
10951
|
|
|
9675
|
-
c._initializeState(
|
|
10952
|
+
var _c$_initializeState2 = c._initializeState(channelState, 'latest'),
|
|
10953
|
+
_messageSet = _c$_initializeState2.messageSet;
|
|
10954
|
+
|
|
10955
|
+
updatedMessagesSet = _messageSet;
|
|
10956
|
+
}
|
|
10957
|
+
|
|
10958
|
+
if (updatedMessagesSet) {
|
|
10959
|
+
updatedMessagesSet.pagination = _objectSpread(_objectSpread({}, updatedMessagesSet.pagination), messageSetPagination({
|
|
10960
|
+
parentSet: updatedMessagesSet,
|
|
10961
|
+
requestedPageSize: (queryChannelsOptions === null || queryChannelsOptions === void 0 ? void 0 : queryChannelsOptions.message_limit) || DEFAULT_QUERY_CHANNELS_MESSAGE_LIST_PAGE_SIZE,
|
|
10962
|
+
returnedPage: channelState.messages,
|
|
10963
|
+
logger: this.logger
|
|
10964
|
+
}));
|
|
9676
10965
|
}
|
|
9677
10966
|
|
|
9678
10967
|
channels.push(c);
|
|
9679
10968
|
}
|
|
9680
10969
|
} catch (err) {
|
|
9681
|
-
|
|
10970
|
+
_iterator2.e(err);
|
|
9682
10971
|
} finally {
|
|
9683
|
-
|
|
10972
|
+
_iterator2.f();
|
|
9684
10973
|
}
|
|
9685
10974
|
|
|
9686
10975
|
return channels;
|
|
@@ -10153,25 +11442,25 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10153
11442
|
key: "upsertUsers",
|
|
10154
11443
|
value: function () {
|
|
10155
11444
|
var _upsertUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30(users) {
|
|
10156
|
-
var userMap,
|
|
11445
|
+
var userMap, _iterator3, _step3, userObject;
|
|
10157
11446
|
|
|
10158
11447
|
return _regeneratorRuntime.wrap(function _callee30$(_context30) {
|
|
10159
11448
|
while (1) {
|
|
10160
11449
|
switch (_context30.prev = _context30.next) {
|
|
10161
11450
|
case 0:
|
|
10162
11451
|
userMap = {};
|
|
10163
|
-
|
|
11452
|
+
_iterator3 = _createForOfIteratorHelper(users);
|
|
10164
11453
|
_context30.prev = 2;
|
|
10165
11454
|
|
|
10166
|
-
|
|
11455
|
+
_iterator3.s();
|
|
10167
11456
|
|
|
10168
11457
|
case 4:
|
|
10169
|
-
if ((
|
|
11458
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
10170
11459
|
_context30.next = 11;
|
|
10171
11460
|
break;
|
|
10172
11461
|
}
|
|
10173
11462
|
|
|
10174
|
-
userObject =
|
|
11463
|
+
userObject = _step3.value;
|
|
10175
11464
|
|
|
10176
11465
|
if (userObject.id) {
|
|
10177
11466
|
_context30.next = 8;
|
|
@@ -10195,12 +11484,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10195
11484
|
_context30.prev = 13;
|
|
10196
11485
|
_context30.t0 = _context30["catch"](2);
|
|
10197
11486
|
|
|
10198
|
-
|
|
11487
|
+
_iterator3.e(_context30.t0);
|
|
10199
11488
|
|
|
10200
11489
|
case 16:
|
|
10201
11490
|
_context30.prev = 16;
|
|
10202
11491
|
|
|
10203
|
-
|
|
11492
|
+
_iterator3.f();
|
|
10204
11493
|
|
|
10205
11494
|
return _context30.finish(16);
|
|
10206
11495
|
|
|
@@ -10270,24 +11559,24 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10270
11559
|
*/
|
|
10271
11560
|
function () {
|
|
10272
11561
|
var _partialUpdateUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31(users) {
|
|
10273
|
-
var
|
|
11562
|
+
var _iterator4, _step4, userObject;
|
|
10274
11563
|
|
|
10275
11564
|
return _regeneratorRuntime.wrap(function _callee31$(_context31) {
|
|
10276
11565
|
while (1) {
|
|
10277
11566
|
switch (_context31.prev = _context31.next) {
|
|
10278
11567
|
case 0:
|
|
10279
|
-
|
|
11568
|
+
_iterator4 = _createForOfIteratorHelper(users);
|
|
10280
11569
|
_context31.prev = 1;
|
|
10281
11570
|
|
|
10282
|
-
|
|
11571
|
+
_iterator4.s();
|
|
10283
11572
|
|
|
10284
11573
|
case 3:
|
|
10285
|
-
if ((
|
|
11574
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
10286
11575
|
_context31.next = 9;
|
|
10287
11576
|
break;
|
|
10288
11577
|
}
|
|
10289
11578
|
|
|
10290
|
-
userObject =
|
|
11579
|
+
userObject = _step4.value;
|
|
10291
11580
|
|
|
10292
11581
|
if (userObject.id) {
|
|
10293
11582
|
_context31.next = 7;
|
|
@@ -10308,12 +11597,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10308
11597
|
_context31.prev = 11;
|
|
10309
11598
|
_context31.t0 = _context31["catch"](1);
|
|
10310
11599
|
|
|
10311
|
-
|
|
11600
|
+
_iterator4.e(_context31.t0);
|
|
10312
11601
|
|
|
10313
11602
|
case 14:
|
|
10314
11603
|
_context31.prev = 14;
|
|
10315
11604
|
|
|
10316
|
-
|
|
11605
|
+
_iterator4.f();
|
|
10317
11606
|
|
|
10318
11607
|
return _context31.finish(14);
|
|
10319
11608
|
|
|
@@ -10349,7 +11638,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10349
11638
|
switch (_context32.prev = _context32.next) {
|
|
10350
11639
|
case 0:
|
|
10351
11640
|
_context32.next = 2;
|
|
10352
|
-
return this.delete(this.baseURL + "/users/".concat(userID), params);
|
|
11641
|
+
return this.delete(this.baseURL + "/users/".concat(encodeURIComponent(userID)), params);
|
|
10353
11642
|
|
|
10354
11643
|
case 2:
|
|
10355
11644
|
return _context32.abrupt("return", _context32.sent);
|
|
@@ -10424,7 +11713,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10424
11713
|
switch (_context34.prev = _context34.next) {
|
|
10425
11714
|
case 0:
|
|
10426
11715
|
_context34.next = 2;
|
|
10427
|
-
return this.post(this.baseURL + "/users/".concat(userID, "/reactivate"), _objectSpread({}, options));
|
|
11716
|
+
return this.post(this.baseURL + "/users/".concat(encodeURIComponent(userID), "/reactivate"), _objectSpread({}, options));
|
|
10428
11717
|
|
|
10429
11718
|
case 2:
|
|
10430
11719
|
return _context34.abrupt("return", _context34.sent);
|
|
@@ -10500,7 +11789,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10500
11789
|
switch (_context36.prev = _context36.next) {
|
|
10501
11790
|
case 0:
|
|
10502
11791
|
_context36.next = 2;
|
|
10503
|
-
return this.post(this.baseURL + "/users/".concat(userID, "/deactivate"), _objectSpread({}, options));
|
|
11792
|
+
return this.post(this.baseURL + "/users/".concat(encodeURIComponent(userID), "/deactivate"), _objectSpread({}, options));
|
|
10504
11793
|
|
|
10505
11794
|
case 2:
|
|
10506
11795
|
return _context36.abrupt("return", _context36.sent);
|
|
@@ -10567,7 +11856,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10567
11856
|
switch (_context38.prev = _context38.next) {
|
|
10568
11857
|
case 0:
|
|
10569
11858
|
_context38.next = 2;
|
|
10570
|
-
return this.get(this.baseURL + "/users/".concat(userID, "/export"), _objectSpread({}, options));
|
|
11859
|
+
return this.get(this.baseURL + "/users/".concat(encodeURIComponent(userID), "/export"), _objectSpread({}, options));
|
|
10571
11860
|
|
|
10572
11861
|
case 2:
|
|
10573
11862
|
return _context38.abrupt("return", _context38.sent);
|
|
@@ -11109,7 +12398,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11109
12398
|
case 0:
|
|
11110
12399
|
options = _args52.length > 1 && _args52[1] !== undefined ? _args52[1] : {};
|
|
11111
12400
|
_context52.next = 3;
|
|
11112
|
-
return this.post(this.baseURL + "/calls/".concat(callID), _objectSpread({}, options));
|
|
12401
|
+
return this.post(this.baseURL + "/calls/".concat(encodeURIComponent(callID)), _objectSpread({}, options));
|
|
11113
12402
|
|
|
11114
12403
|
case 3:
|
|
11115
12404
|
return _context52.abrupt("return", _context52.sent);
|
|
@@ -11253,7 +12542,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11253
12542
|
case 0:
|
|
11254
12543
|
options = _args55.length > 2 && _args55[2] !== undefined ? _args55[2] : {};
|
|
11255
12544
|
_context55.next = 3;
|
|
11256
|
-
return this.patch(this.baseURL + "/moderation/reports/".concat(id), _objectSpread({
|
|
12545
|
+
return this.patch(this.baseURL + "/moderation/reports/".concat(encodeURIComponent(id)), _objectSpread({
|
|
11257
12546
|
review_result: reviewResult
|
|
11258
12547
|
}, options));
|
|
11259
12548
|
|
|
@@ -11362,17 +12651,17 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11362
12651
|
}, {
|
|
11363
12652
|
key: "getCommand",
|
|
11364
12653
|
value: function getCommand(name) {
|
|
11365
|
-
return this.get(this.baseURL + "/commands/".concat(name));
|
|
12654
|
+
return this.get(this.baseURL + "/commands/".concat(encodeURIComponent(name)));
|
|
11366
12655
|
}
|
|
11367
12656
|
}, {
|
|
11368
12657
|
key: "updateCommand",
|
|
11369
12658
|
value: function updateCommand(name, data) {
|
|
11370
|
-
return this.put(this.baseURL + "/commands/".concat(name), data);
|
|
12659
|
+
return this.put(this.baseURL + "/commands/".concat(encodeURIComponent(name)), data);
|
|
11371
12660
|
}
|
|
11372
12661
|
}, {
|
|
11373
12662
|
key: "deleteCommand",
|
|
11374
12663
|
value: function deleteCommand(name) {
|
|
11375
|
-
return this.delete(this.baseURL + "/commands/".concat(name));
|
|
12664
|
+
return this.delete(this.baseURL + "/commands/".concat(encodeURIComponent(name)));
|
|
11376
12665
|
}
|
|
11377
12666
|
}, {
|
|
11378
12667
|
key: "listCommands",
|
|
@@ -11391,17 +12680,17 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11391
12680
|
}, {
|
|
11392
12681
|
key: "getChannelType",
|
|
11393
12682
|
value: function getChannelType(channelType) {
|
|
11394
|
-
return this.get(this.baseURL + "/channeltypes/".concat(channelType));
|
|
12683
|
+
return this.get(this.baseURL + "/channeltypes/".concat(encodeURIComponent(channelType)));
|
|
11395
12684
|
}
|
|
11396
12685
|
}, {
|
|
11397
12686
|
key: "updateChannelType",
|
|
11398
12687
|
value: function updateChannelType(channelType, data) {
|
|
11399
|
-
return this.put(this.baseURL + "/channeltypes/".concat(channelType), data);
|
|
12688
|
+
return this.put(this.baseURL + "/channeltypes/".concat(encodeURIComponent(channelType)), data);
|
|
11400
12689
|
}
|
|
11401
12690
|
}, {
|
|
11402
12691
|
key: "deleteChannelType",
|
|
11403
12692
|
value: function deleteChannelType(channelType) {
|
|
11404
|
-
return this.delete(this.baseURL + "/channeltypes/".concat(channelType));
|
|
12693
|
+
return this.delete(this.baseURL + "/channeltypes/".concat(encodeURIComponent(channelType)));
|
|
11405
12694
|
}
|
|
11406
12695
|
}, {
|
|
11407
12696
|
key: "listChannelTypes",
|
|
@@ -11426,7 +12715,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11426
12715
|
switch (_context58.prev = _context58.next) {
|
|
11427
12716
|
case 0:
|
|
11428
12717
|
_context58.next = 2;
|
|
11429
|
-
return this.post(this.baseURL + "/messages/".concat(messageId, "/translate"), {
|
|
12718
|
+
return this.post(this.baseURL + "/messages/".concat(encodeURIComponent(messageId), "/translate"), {
|
|
11430
12719
|
language: language
|
|
11431
12720
|
});
|
|
11432
12721
|
|
|
@@ -11588,7 +12877,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11588
12877
|
}
|
|
11589
12878
|
|
|
11590
12879
|
_context59.next = 10;
|
|
11591
|
-
return this.post(this.baseURL + "/messages/".concat(message.id), _objectSpread({
|
|
12880
|
+
return this.post(this.baseURL + "/messages/".concat(encodeURIComponent(message.id)), _objectSpread({
|
|
11592
12881
|
message: clonedMessage
|
|
11593
12882
|
}, options));
|
|
11594
12883
|
|
|
@@ -11649,7 +12938,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11649
12938
|
}
|
|
11650
12939
|
|
|
11651
12940
|
_context60.next = 6;
|
|
11652
|
-
return this.put(this.baseURL + "/messages/".concat(id), _objectSpread(_objectSpread(_objectSpread({}, partialMessageObject), options), {}, {
|
|
12941
|
+
return this.put(this.baseURL + "/messages/".concat(encodeURIComponent(id)), _objectSpread(_objectSpread(_objectSpread({}, partialMessageObject), options), {}, {
|
|
11653
12942
|
user: user
|
|
11654
12943
|
}));
|
|
11655
12944
|
|
|
@@ -11688,7 +12977,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11688
12977
|
}
|
|
11689
12978
|
|
|
11690
12979
|
_context61.next = 4;
|
|
11691
|
-
return this.delete(this.baseURL + "/messages/".concat(messageID), params);
|
|
12980
|
+
return this.delete(this.baseURL + "/messages/".concat(encodeURIComponent(messageID)), params);
|
|
11692
12981
|
|
|
11693
12982
|
case 4:
|
|
11694
12983
|
return _context61.abrupt("return", _context61.sent);
|
|
@@ -11729,7 +13018,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11729
13018
|
switch (_context62.prev = _context62.next) {
|
|
11730
13019
|
case 0:
|
|
11731
13020
|
_context62.next = 2;
|
|
11732
|
-
return this.post(this.baseURL + "/messages/".concat(messageID, "/undelete"), {
|
|
13021
|
+
return this.post(this.baseURL + "/messages/".concat(encodeURIComponent(messageID), "/undelete"), {
|
|
11733
13022
|
undeleted_by: userID
|
|
11734
13023
|
});
|
|
11735
13024
|
|
|
@@ -11814,7 +13103,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11814
13103
|
res = _context64.sent;
|
|
11815
13104
|
return _context64.abrupt("return", {
|
|
11816
13105
|
threads: res.threads.map(function (thread) {
|
|
11817
|
-
return new Thread(
|
|
13106
|
+
return new Thread({
|
|
13107
|
+
client: _this5,
|
|
13108
|
+
threadData: thread
|
|
13109
|
+
});
|
|
11818
13110
|
}),
|
|
11819
13111
|
next: res.next
|
|
11820
13112
|
});
|
|
@@ -11873,11 +13165,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11873
13165
|
watch: true
|
|
11874
13166
|
}, options);
|
|
11875
13167
|
_context65.next = 6;
|
|
11876
|
-
return this.get(this.baseURL + "/threads/".concat(messageId), opts);
|
|
13168
|
+
return this.get(this.baseURL + "/threads/".concat(encodeURIComponent(messageId)), opts);
|
|
11877
13169
|
|
|
11878
13170
|
case 6:
|
|
11879
13171
|
res = _context65.sent;
|
|
11880
|
-
return _context65.abrupt("return", new Thread(
|
|
13172
|
+
return _context65.abrupt("return", new Thread({
|
|
13173
|
+
client: this,
|
|
13174
|
+
threadData: res.thread
|
|
13175
|
+
}));
|
|
11881
13176
|
|
|
11882
13177
|
case 8:
|
|
11883
13178
|
case "end":
|
|
@@ -11946,7 +13241,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11946
13241
|
|
|
11947
13242
|
case 10:
|
|
11948
13243
|
_context66.next = 12;
|
|
11949
|
-
return this.patch(this.baseURL + "/threads/".concat(messageId), partialThreadObject);
|
|
13244
|
+
return this.patch(this.baseURL + "/threads/".concat(encodeURIComponent(messageId)), partialThreadObject);
|
|
11950
13245
|
|
|
11951
13246
|
case 12:
|
|
11952
13247
|
return _context66.abrupt("return", _context66.sent);
|
|
@@ -11968,7 +13263,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11968
13263
|
}, {
|
|
11969
13264
|
key: "getUserAgent",
|
|
11970
13265
|
value: function getUserAgent() {
|
|
11971
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.
|
|
13266
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.40.0");
|
|
11972
13267
|
}
|
|
11973
13268
|
}, {
|
|
11974
13269
|
key: "setUserAgent",
|
|
@@ -12078,7 +13373,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12078
13373
|
}, {
|
|
12079
13374
|
key: "getPermission",
|
|
12080
13375
|
value: function getPermission(name) {
|
|
12081
|
-
return this.get("".concat(this.baseURL, "/permissions/").concat(name));
|
|
13376
|
+
return this.get("".concat(this.baseURL, "/permissions/").concat(encodeURIComponent(name)));
|
|
12082
13377
|
}
|
|
12083
13378
|
/** createPermission - creates a custom permission
|
|
12084
13379
|
*
|
|
@@ -12101,7 +13396,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12101
13396
|
}, {
|
|
12102
13397
|
key: "updatePermission",
|
|
12103
13398
|
value: function updatePermission(id, permissionData) {
|
|
12104
|
-
return this.put("".concat(this.baseURL, "/permissions/").concat(id), _objectSpread({}, permissionData));
|
|
13399
|
+
return this.put("".concat(this.baseURL, "/permissions/").concat(encodeURIComponent(id)), _objectSpread({}, permissionData));
|
|
12105
13400
|
}
|
|
12106
13401
|
/** deletePermission - deletes a custom permission
|
|
12107
13402
|
*
|
|
@@ -12112,7 +13407,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12112
13407
|
}, {
|
|
12113
13408
|
key: "deletePermission",
|
|
12114
13409
|
value: function deletePermission(name) {
|
|
12115
|
-
return this.delete("".concat(this.baseURL, "/permissions/").concat(name));
|
|
13410
|
+
return this.delete("".concat(this.baseURL, "/permissions/").concat(encodeURIComponent(name)));
|
|
12116
13411
|
}
|
|
12117
13412
|
/** listPermissions - returns the list of all permissions for this application
|
|
12118
13413
|
*
|
|
@@ -12156,7 +13451,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12156
13451
|
}, {
|
|
12157
13452
|
key: "deleteRole",
|
|
12158
13453
|
value: function deleteRole(name) {
|
|
12159
|
-
return this.delete("".concat(this.baseURL, "/roles/").concat(name));
|
|
13454
|
+
return this.delete("".concat(this.baseURL, "/roles/").concat(encodeURIComponent(name)));
|
|
12160
13455
|
}
|
|
12161
13456
|
/** sync - returns all events that happened for a list of channels since last sync
|
|
12162
13457
|
* @param {string[]} channel_cids list of channel CIDs
|
|
@@ -12193,7 +13488,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12193
13488
|
switch (_context67.prev = _context67.next) {
|
|
12194
13489
|
case 0:
|
|
12195
13490
|
_context67.next = 2;
|
|
12196
|
-
return this.post("".concat(this.baseURL, "/users/").concat(targetUserID, "/event"), {
|
|
13491
|
+
return this.post("".concat(this.baseURL, "/users/").concat(encodeURIComponent(targetUserID), "/event"), {
|
|
12197
13492
|
event: event
|
|
12198
13493
|
});
|
|
12199
13494
|
|
|
@@ -12227,17 +13522,17 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12227
13522
|
}, {
|
|
12228
13523
|
key: "getBlockList",
|
|
12229
13524
|
value: function getBlockList(name) {
|
|
12230
|
-
return this.get("".concat(this.baseURL, "/blocklists/").concat(name));
|
|
13525
|
+
return this.get("".concat(this.baseURL, "/blocklists/").concat(encodeURIComponent(name)));
|
|
12231
13526
|
}
|
|
12232
13527
|
}, {
|
|
12233
13528
|
key: "updateBlockList",
|
|
12234
13529
|
value: function updateBlockList(name, data) {
|
|
12235
|
-
return this.put("".concat(this.baseURL, "/blocklists/").concat(name), data);
|
|
13530
|
+
return this.put("".concat(this.baseURL, "/blocklists/").concat(encodeURIComponent(name)), data);
|
|
12236
13531
|
}
|
|
12237
13532
|
}, {
|
|
12238
13533
|
key: "deleteBlockList",
|
|
12239
13534
|
value: function deleteBlockList(name) {
|
|
12240
|
-
return this.delete("".concat(this.baseURL, "/blocklists/").concat(name));
|
|
13535
|
+
return this.delete("".concat(this.baseURL, "/blocklists/").concat(encodeURIComponent(name)));
|
|
12241
13536
|
}
|
|
12242
13537
|
}, {
|
|
12243
13538
|
key: "exportChannels",
|
|
@@ -12263,7 +13558,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12263
13558
|
}, {
|
|
12264
13559
|
key: "getExportChannelStatus",
|
|
12265
13560
|
value: function getExportChannelStatus(id) {
|
|
12266
|
-
return this.get("".concat(this.baseURL, "/export_channels/").concat(id));
|
|
13561
|
+
return this.get("".concat(this.baseURL, "/export_channels/").concat(encodeURIComponent(id)));
|
|
12267
13562
|
}
|
|
12268
13563
|
}, {
|
|
12269
13564
|
key: "campaign",
|
|
@@ -12411,7 +13706,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12411
13706
|
switch (_context71.prev = _context71.next) {
|
|
12412
13707
|
case 0:
|
|
12413
13708
|
this.validateServerSideAuth();
|
|
12414
|
-
return _context71.abrupt("return", this.get(this.baseURL + "/segments/".concat(id)));
|
|
13709
|
+
return _context71.abrupt("return", this.get(this.baseURL + "/segments/".concat(encodeURIComponent(id))));
|
|
12415
13710
|
|
|
12416
13711
|
case 2:
|
|
12417
13712
|
case "end":
|
|
@@ -12445,7 +13740,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12445
13740
|
switch (_context72.prev = _context72.next) {
|
|
12446
13741
|
case 0:
|
|
12447
13742
|
this.validateServerSideAuth();
|
|
12448
|
-
return _context72.abrupt("return", this.put(this.baseURL + "/segments/".concat(id), data));
|
|
13743
|
+
return _context72.abrupt("return", this.put(this.baseURL + "/segments/".concat(encodeURIComponent(id)), data));
|
|
12449
13744
|
|
|
12450
13745
|
case 2:
|
|
12451
13746
|
case "end":
|
|
@@ -12483,7 +13778,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12483
13778
|
body = {
|
|
12484
13779
|
target_ids: targets
|
|
12485
13780
|
};
|
|
12486
|
-
return _context73.abrupt("return", this.post(this.baseURL + "/segments/".concat(id, "/addtargets"), body));
|
|
13781
|
+
return _context73.abrupt("return", this.post(this.baseURL + "/segments/".concat(encodeURIComponent(id), "/addtargets"), body));
|
|
12487
13782
|
|
|
12488
13783
|
case 3:
|
|
12489
13784
|
case "end":
|
|
@@ -12515,7 +13810,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12515
13810
|
sort = _args74.length > 2 && _args74[2] !== undefined ? _args74[2] : [];
|
|
12516
13811
|
options = _args74.length > 3 && _args74[3] !== undefined ? _args74[3] : {};
|
|
12517
13812
|
this.validateServerSideAuth();
|
|
12518
|
-
return _context74.abrupt("return", this.post(this.baseURL + "/segments/".concat(id, "/targets/query"), _objectSpread({
|
|
13813
|
+
return _context74.abrupt("return", this.post(this.baseURL + "/segments/".concat(encodeURIComponent(id), "/targets/query"), _objectSpread({
|
|
12519
13814
|
filter: filter || {},
|
|
12520
13815
|
sort: sort || []
|
|
12521
13816
|
}, options)));
|
|
@@ -12556,7 +13851,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12556
13851
|
body = {
|
|
12557
13852
|
target_ids: targets
|
|
12558
13853
|
};
|
|
12559
|
-
return _context75.abrupt("return", this.post(this.baseURL + "/segments/".concat(id, "/deletetargets"), body));
|
|
13854
|
+
return _context75.abrupt("return", this.post(this.baseURL + "/segments/".concat(encodeURIComponent(id), "/deletetargets"), body));
|
|
12560
13855
|
|
|
12561
13856
|
case 3:
|
|
12562
13857
|
case "end":
|
|
@@ -12629,7 +13924,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12629
13924
|
switch (_context77.prev = _context77.next) {
|
|
12630
13925
|
case 0:
|
|
12631
13926
|
this.validateServerSideAuth();
|
|
12632
|
-
return _context77.abrupt("return", this.delete(this.baseURL + "/segments/".concat(id)));
|
|
13927
|
+
return _context77.abrupt("return", this.delete(this.baseURL + "/segments/".concat(encodeURIComponent(id))));
|
|
12633
13928
|
|
|
12634
13929
|
case 2:
|
|
12635
13930
|
case "end":
|
|
@@ -12663,7 +13958,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12663
13958
|
switch (_context78.prev = _context78.next) {
|
|
12664
13959
|
case 0:
|
|
12665
13960
|
this.validateServerSideAuth();
|
|
12666
|
-
return _context78.abrupt("return", this.get(this.baseURL + "/segments/".concat(segmentId, "/target/").concat(targetId)));
|
|
13961
|
+
return _context78.abrupt("return", this.get(this.baseURL + "/segments/".concat(encodeURIComponent(segmentId), "/target/").concat(encodeURIComponent(targetId))));
|
|
12667
13962
|
|
|
12668
13963
|
case 2:
|
|
12669
13964
|
case "end":
|
|
@@ -12721,7 +14016,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12721
14016
|
switch (_context80.prev = _context80.next) {
|
|
12722
14017
|
case 0:
|
|
12723
14018
|
this.validateServerSideAuth();
|
|
12724
|
-
return _context80.abrupt("return", this.get(this.baseURL + "/campaigns/".concat(id)));
|
|
14019
|
+
return _context80.abrupt("return", this.get(this.baseURL + "/campaigns/".concat(encodeURIComponent(id))));
|
|
12725
14020
|
|
|
12726
14021
|
case 2:
|
|
12727
14022
|
case "end":
|
|
@@ -12746,7 +14041,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12746
14041
|
switch (_context81.prev = _context81.next) {
|
|
12747
14042
|
case 0:
|
|
12748
14043
|
this.validateServerSideAuth();
|
|
12749
|
-
return _context81.abrupt("return", this.post(this.baseURL + "/campaigns/".concat(id, "/start"), {
|
|
14044
|
+
return _context81.abrupt("return", this.post(this.baseURL + "/campaigns/".concat(encodeURIComponent(id), "/start"), {
|
|
12750
14045
|
scheduled_for: options === null || options === void 0 ? void 0 : options.scheduledFor,
|
|
12751
14046
|
stop_at: options === null || options === void 0 ? void 0 : options.stopAt
|
|
12752
14047
|
}));
|
|
@@ -12822,7 +14117,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12822
14117
|
switch (_context83.prev = _context83.next) {
|
|
12823
14118
|
case 0:
|
|
12824
14119
|
this.validateServerSideAuth();
|
|
12825
|
-
return _context83.abrupt("return", this.put(this.baseURL + "/campaigns/".concat(id), params));
|
|
14120
|
+
return _context83.abrupt("return", this.put(this.baseURL + "/campaigns/".concat(encodeURIComponent(id)), params));
|
|
12826
14121
|
|
|
12827
14122
|
case 2:
|
|
12828
14123
|
case "end":
|
|
@@ -12855,7 +14150,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12855
14150
|
switch (_context84.prev = _context84.next) {
|
|
12856
14151
|
case 0:
|
|
12857
14152
|
this.validateServerSideAuth();
|
|
12858
|
-
return _context84.abrupt("return", this.delete(this.baseURL + "/campaigns/".concat(id)));
|
|
14153
|
+
return _context84.abrupt("return", this.delete(this.baseURL + "/campaigns/".concat(encodeURIComponent(id))));
|
|
12859
14154
|
|
|
12860
14155
|
case 2:
|
|
12861
14156
|
case "end":
|
|
@@ -12888,7 +14183,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12888
14183
|
switch (_context85.prev = _context85.next) {
|
|
12889
14184
|
case 0:
|
|
12890
14185
|
this.validateServerSideAuth();
|
|
12891
|
-
return _context85.abrupt("return", this.post(this.baseURL + "/campaigns/".concat(id, "/stop")));
|
|
14186
|
+
return _context85.abrupt("return", this.post(this.baseURL + "/campaigns/".concat(encodeURIComponent(id), "/stop")));
|
|
12892
14187
|
|
|
12893
14188
|
case 2:
|
|
12894
14189
|
case "end":
|
|
@@ -12953,7 +14248,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
12953
14248
|
while (1) {
|
|
12954
14249
|
switch (_context87.prev = _context87.next) {
|
|
12955
14250
|
case 0:
|
|
12956
|
-
return _context87.abrupt("return", this.get("".concat(this.baseURL, "/tasks/").concat(id)));
|
|
14251
|
+
return _context87.abrupt("return", this.get("".concat(this.baseURL, "/tasks/").concat(encodeURIComponent(id))));
|
|
12957
14252
|
|
|
12958
14253
|
case 1:
|
|
12959
14254
|
case "end":
|
|
@@ -13190,7 +14485,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13190
14485
|
switch (_context92.prev = _context92.next) {
|
|
13191
14486
|
case 0:
|
|
13192
14487
|
_context92.next = 2;
|
|
13193
|
-
return this.get(this.baseURL + "/imports/".concat(id));
|
|
14488
|
+
return this.get(this.baseURL + "/imports/".concat(encodeURIComponent(id)));
|
|
13194
14489
|
|
|
13195
14490
|
case 2:
|
|
13196
14491
|
return _context92.abrupt("return", _context92.sent);
|
|
@@ -13311,7 +14606,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13311
14606
|
case 0:
|
|
13312
14607
|
type = _ref10.type, name = _ref10.name;
|
|
13313
14608
|
_context95.next = 3;
|
|
13314
|
-
return this.delete(this.baseURL + "/push_providers/".concat(type, "/").concat(name));
|
|
14609
|
+
return this.delete(this.baseURL + "/push_providers/".concat(encodeURIComponent(type), "/").concat(encodeURIComponent(name)));
|
|
13315
14610
|
|
|
13316
14611
|
case 3:
|
|
13317
14612
|
return _context95.abrupt("return", _context95.sent);
|
|
@@ -13391,7 +14686,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13391
14686
|
switch (_context97.prev = _context97.next) {
|
|
13392
14687
|
case 0:
|
|
13393
14688
|
_context97.next = 2;
|
|
13394
|
-
return this.post(this.baseURL + "/messages/".concat(id, "/commit"));
|
|
14689
|
+
return this.post(this.baseURL + "/messages/".concat(encodeURIComponent(id), "/commit"));
|
|
13395
14690
|
|
|
13396
14691
|
case 2:
|
|
13397
14692
|
return _context97.abrupt("return", _context97.sent);
|
|
@@ -13463,7 +14758,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13463
14758
|
switch (_context99.prev = _context99.next) {
|
|
13464
14759
|
case 0:
|
|
13465
14760
|
_context99.next = 2;
|
|
13466
|
-
return this.get(this.baseURL + "/polls/".concat(id), userId ? {
|
|
14761
|
+
return this.get(this.baseURL + "/polls/".concat(encodeURIComponent(id)), userId ? {
|
|
13467
14762
|
user_id: userId
|
|
13468
14763
|
} : {});
|
|
13469
14764
|
|
|
@@ -13539,7 +14834,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13539
14834
|
switch (_context101.prev = _context101.next) {
|
|
13540
14835
|
case 0:
|
|
13541
14836
|
_context101.next = 2;
|
|
13542
|
-
return this.patch(this.baseURL + "/polls/".concat(id), _objectSpread(_objectSpread({}, partialPollObject), userId ? {
|
|
14837
|
+
return this.patch(this.baseURL + "/polls/".concat(encodeURIComponent(id)), _objectSpread(_objectSpread({}, partialPollObject), userId ? {
|
|
13543
14838
|
user_id: userId
|
|
13544
14839
|
} : {}));
|
|
13545
14840
|
|
|
@@ -13576,7 +14871,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13576
14871
|
switch (_context102.prev = _context102.next) {
|
|
13577
14872
|
case 0:
|
|
13578
14873
|
_context102.next = 2;
|
|
13579
|
-
return this.delete(this.baseURL + "/polls/".concat(id), _objectSpread({}, userId ? {
|
|
14874
|
+
return this.delete(this.baseURL + "/polls/".concat(encodeURIComponent(id)), _objectSpread({}, userId ? {
|
|
13580
14875
|
user_id: userId
|
|
13581
14876
|
} : {}));
|
|
13582
14877
|
|
|
@@ -13651,7 +14946,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13651
14946
|
switch (_context104.prev = _context104.next) {
|
|
13652
14947
|
case 0:
|
|
13653
14948
|
_context104.next = 2;
|
|
13654
|
-
return this.post(this.baseURL + "/polls/".concat(pollId, "/options"), _objectSpread(_objectSpread({}, option), userId ? {
|
|
14949
|
+
return this.post(this.baseURL + "/polls/".concat(encodeURIComponent(pollId), "/options"), _objectSpread(_objectSpread({}, option), userId ? {
|
|
13655
14950
|
user_id: userId
|
|
13656
14951
|
} : {}));
|
|
13657
14952
|
|
|
@@ -13689,7 +14984,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13689
14984
|
switch (_context105.prev = _context105.next) {
|
|
13690
14985
|
case 0:
|
|
13691
14986
|
_context105.next = 2;
|
|
13692
|
-
return this.get(this.baseURL + "/polls/".concat(pollId, "/options/").concat(optionId), userId ? {
|
|
14987
|
+
return this.get(this.baseURL + "/polls/".concat(encodeURIComponent(pollId), "/options/").concat(encodeURIComponent(optionId)), userId ? {
|
|
13693
14988
|
user_id: userId
|
|
13694
14989
|
} : {});
|
|
13695
14990
|
|
|
@@ -13727,7 +15022,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13727
15022
|
switch (_context106.prev = _context106.next) {
|
|
13728
15023
|
case 0:
|
|
13729
15024
|
_context106.next = 2;
|
|
13730
|
-
return this.put(this.baseURL + "/polls/".concat(pollId, "/options"), _objectSpread(_objectSpread({}, option), userId ? {
|
|
15025
|
+
return this.put(this.baseURL + "/polls/".concat(encodeURIComponent(pollId), "/options"), _objectSpread(_objectSpread({}, option), userId ? {
|
|
13731
15026
|
user_id: userId
|
|
13732
15027
|
} : {}));
|
|
13733
15028
|
|
|
@@ -13765,7 +15060,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13765
15060
|
switch (_context107.prev = _context107.next) {
|
|
13766
15061
|
case 0:
|
|
13767
15062
|
_context107.next = 2;
|
|
13768
|
-
return this.delete(this.baseURL + "/polls/".concat(pollId, "/options/").concat(optionId), userId ? {
|
|
15063
|
+
return this.delete(this.baseURL + "/polls/".concat(encodeURIComponent(pollId), "/options/").concat(encodeURIComponent(optionId)), userId ? {
|
|
13769
15064
|
user_id: userId
|
|
13770
15065
|
} : {});
|
|
13771
15066
|
|
|
@@ -13804,7 +15099,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13804
15099
|
switch (_context108.prev = _context108.next) {
|
|
13805
15100
|
case 0:
|
|
13806
15101
|
_context108.next = 2;
|
|
13807
|
-
return this.post(this.baseURL + "/messages/".concat(messageId, "/polls/").concat(pollId, "/vote"), _objectSpread({
|
|
15102
|
+
return this.post(this.baseURL + "/messages/".concat(encodeURIComponent(messageId), "/polls/").concat(encodeURIComponent(pollId), "/vote"), _objectSpread({
|
|
13808
15103
|
vote: vote
|
|
13809
15104
|
}, userId ? {
|
|
13810
15105
|
user_id: userId
|
|
@@ -13870,7 +15165,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13870
15165
|
switch (_context110.prev = _context110.next) {
|
|
13871
15166
|
case 0:
|
|
13872
15167
|
_context110.next = 2;
|
|
13873
|
-
return this.delete(this.baseURL + "/messages/".concat(messageId, "/polls/").concat(pollId, "/vote/").concat(voteId), _objectSpread({}, userId ? {
|
|
15168
|
+
return this.delete(this.baseURL + "/messages/".concat(encodeURIComponent(messageId), "/polls/").concat(encodeURIComponent(pollId), "/vote/").concat(encodeURIComponent(voteId)), _objectSpread({}, userId ? {
|
|
13874
15169
|
user_id: userId
|
|
13875
15170
|
} : {}));
|
|
13876
15171
|
|
|
@@ -13972,7 +15267,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13972
15267
|
userId = _args112.length > 4 ? _args112[4] : undefined;
|
|
13973
15268
|
q = userId ? "?user_id=".concat(userId) : '';
|
|
13974
15269
|
_context112.next = 7;
|
|
13975
|
-
return this.post(this.baseURL + "/polls/".concat(pollId, "/votes").concat(q), _objectSpread({
|
|
15270
|
+
return this.post(this.baseURL + "/polls/".concat(encodeURIComponent(pollId), "/votes").concat(q), _objectSpread({
|
|
13976
15271
|
filter: filter,
|
|
13977
15272
|
sort: normalizeQuerySort(sort)
|
|
13978
15273
|
}, options));
|
|
@@ -14235,5 +15530,5 @@ var BuiltinPermissions = {
|
|
|
14235
15530
|
UseFrozenChannel: 'Send messages and reactions to frozen channels'
|
|
14236
15531
|
};
|
|
14237
15532
|
|
|
14238
|
-
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, StreamChat, Thread, TokenManager, UserFromToken, VotingVisibility, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, formatMessage, isOwnUser, logChatPromiseExecution, postInsights };
|
|
15533
|
+
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 };
|
|
14239
15534
|
//# sourceMappingURL=browser.es.js.map
|