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