sceyt-chat-react-uikit 1.8.6-beta.3 → 1.8.6-beta.5

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/index.js CHANGED
@@ -18689,11 +18689,11 @@ function markMessagesRead(action) {
18689
18689
  messageListMarker = _context0.v;
18690
18690
  _context0.n = 5;
18691
18691
  return effects.put(updateChannelDataAC(channel.id, {
18692
- lastReadMessageId: channel.lastDisplayedMessageId
18692
+ lastDisplayedMessageId: channel.lastDisplayedMessageId
18693
18693
  }));
18694
18694
  case 5:
18695
18695
  updateChannelOnAllChannels(channel.id, {
18696
- lastReadMessageId: channel.lastDisplayedMessageId
18696
+ lastDisplayedMessageId: channel.lastDisplayedMessageId
18697
18697
  });
18698
18698
  _iterator6 = _createForOfIteratorHelperLoose(messageListMarker.messageIds);
18699
18699
  case 6:
@@ -19155,7 +19155,7 @@ function notificationsTurnOn() {
19155
19155
  }, _marked14, null, [[3, 6]]);
19156
19156
  }
19157
19157
  function markChannelAsRead(action) {
19158
- var channelId, channel, updateData, _t16;
19158
+ var channelId, channel, updatedChannel, updateData, _t16;
19159
19159
  return _regenerator().w(function (_context16) {
19160
19160
  while (1) switch (_context16.p = _context16.n) {
19161
19161
  case 0:
@@ -19171,10 +19171,12 @@ function markChannelAsRead(action) {
19171
19171
  _context16.n = 2;
19172
19172
  return effects.call(channel.markAsRead);
19173
19173
  case 2:
19174
+ updatedChannel = _context16.v;
19174
19175
  updateData = {
19175
19176
  unread: false,
19176
19177
  newMessageCount: 0,
19177
- newMentionCount: 0
19178
+ newMentionCount: 0,
19179
+ lastDisplayedMessageId: updatedChannel === null || updatedChannel === void 0 ? void 0 : updatedChannel.lastDisplayedMessageId
19178
19180
  };
19179
19181
  updateChannelOnAllChannels(channel.id, updateData);
19180
19182
  _context16.n = 3;
@@ -28329,11 +28331,12 @@ function useOnScreen(ref, rootElement) {
28329
28331
  setIntersecting = _useState[1];
28330
28332
  React.useEffect(function () {
28331
28333
  if (!(ref !== null && ref !== void 0 && ref.current)) return;
28334
+ var root = rootElement || document.getElementById('scrollableDiv');
28332
28335
  var observer = new IntersectionObserver(function (_ref) {
28333
28336
  var entry = _ref[0];
28334
28337
  return setIntersecting(entry.isIntersecting);
28335
28338
  }, {
28336
- root: rootElement || null,
28339
+ root: root || null,
28337
28340
  rootMargin: '0px',
28338
28341
  threshold: 0.1
28339
28342
  });
@@ -35714,6 +35717,13 @@ var Message = function Message(_ref) {
35714
35717
  }
35715
35718
  }
35716
35719
  }, [channel.isLinkedChannel, channel.lastMessage, dispatch, isVisible, message, scrollToNewMessage.scrollToBottom, unreadScrollTo, setLastVisibleMessageId]);
35720
+ React.useEffect(function () {
35721
+ return function () {
35722
+ if (!channel.isLinkedChannel) {
35723
+ removeMessageFromVisibleMessagesMap(message);
35724
+ }
35725
+ };
35726
+ }, [channel.isLinkedChannel, message]);
35717
35727
  return /*#__PURE__*/React__default.createElement(Container$c, {
35718
35728
  id: message.id || message.tid,
35719
35729
  ref: messageItemRef,
@@ -43110,6 +43120,13 @@ var Message$1 = function Message(_ref) {
43110
43120
  }
43111
43121
  }
43112
43122
  }, [isVisible, setLastVisibleMessageId, message.id, handleSendReadMarker, channel.isLinkedChannel, channel.lastMessage, scrollToNewMessage.scrollToBottom, dispatch, message, tabIsActive]);
43123
+ React.useEffect(function () {
43124
+ return function () {
43125
+ if (!channel.isLinkedChannel) {
43126
+ removeMessageFromVisibleMessagesMap(message);
43127
+ }
43128
+ };
43129
+ }, [channel.isLinkedChannel, message]);
43113
43130
  React.useEffect(function () {
43114
43131
  if (!isVisible && infoPopupOpen) {
43115
43132
  setInfoPopupOpen(false);
@@ -44529,6 +44546,12 @@ function useChatController(_ref5) {
44529
44546
  return Promise.reject(e);
44530
44547
  }
44531
44548
  }, [beginEdgePagedRequest, channel.id, connectionStatus, dispatch, hasNextMessages, isNextLoading, scrollToMentionedMessage, scrollToNewMessage.scrollToBottom]);
44549
+ var isPreviousPaginationBlocked = React.useCallback(function (allowWhilePreviousLoading) {
44550
+ if (allowWhilePreviousLoading === void 0) {
44551
+ allowWhilePreviousLoading = false;
44552
+ }
44553
+ return !!windowLoadScopeRef.current || !allowWhilePreviousLoading && isPreviousLoading;
44554
+ }, [isPreviousLoading]);
44532
44555
  var loadPreviousItems = React.useCallback(function () {
44533
44556
  try {
44534
44557
  if (isJumping.current) {
@@ -44577,6 +44600,11 @@ function useChatController(_ref5) {
44577
44600
  });
44578
44601
  return Promise.resolve();
44579
44602
  }
44603
+ if (isPreviousPaginationBlocked()) {
44604
+ pendingEdgeCheckAfterLoadRef.current = true;
44605
+ historyLoadArmedRef.current = true;
44606
+ return Promise.resolve();
44607
+ }
44580
44608
  if (!oldestVisibleId) {
44581
44609
  activeEdgeIntentRef.current = null;
44582
44610
  historyLoadArmedRef.current = true;
@@ -44632,7 +44660,7 @@ function useChatController(_ref5) {
44632
44660
  } catch (e) {
44633
44661
  return Promise.reject(e);
44634
44662
  }
44635
- }, [channel.id, clearPreserveAnchorForRequest, consumeSuppressedMessageChange, createEdgeRequestId, clearPendingLatestJump, dispatch, getCachedPreviousMessages, suppressNextMessageChange, hasNext, hasPrevious, isActiveEdgeRequestCurrent, isLoadingPrevious, loadPrevious, messages, requestDirectionalPrefetchIfNeeded]);
44663
+ }, [channel.id, clearPreserveAnchorForRequest, consumeSuppressedMessageChange, createEdgeRequestId, clearPendingLatestJump, dispatch, getCachedPreviousMessages, suppressNextMessageChange, hasNext, hasPrevious, isPreviousPaginationBlocked, isActiveEdgeRequestCurrent, isLoadingPrevious, loadPrevious, messages, requestDirectionalPrefetchIfNeeded]);
44636
44664
  var loadNextItems = React.useCallback(function () {
44637
44665
  try {
44638
44666
  if (isJumping.current) {
@@ -44813,6 +44841,12 @@ function useChatController(_ref5) {
44813
44841
  }
44814
44842
  activeEdgeIntentRef.current = 'previous';
44815
44843
  if (historyLoadArmedRef.current) {
44844
+ var oldestVisibleMessage = messages[0];
44845
+ var hasCachedPreviousMessages = oldestVisibleMessage ? getCachedPreviousMessages(oldestVisibleMessage).length > 0 : false;
44846
+ if (isPreviousPaginationBlocked(hasCachedPreviousMessages)) {
44847
+ pendingEdgeCheckAfterLoadRef.current = true;
44848
+ return;
44849
+ }
44816
44850
  historyLoadArmedRef.current = false;
44817
44851
  loadPreviousItems();
44818
44852
  return;
@@ -44852,7 +44886,7 @@ function useChatController(_ref5) {
44852
44886
  dispatch(refreshCacheAroundMessageAC(channelRef.current.id, anchorId, true));
44853
44887
  }, SCROLL_IDLE_MS);
44854
44888
  }
44855
- }, [captureWindowPreserveAnchor, clearScrollIdleTimer, clearJumpScrollingLock, dispatch, hasNext, hasPrevious, invalidateEdgeDirection, isLatestJumpLocked, isActiveEdgeRequestCurrent, loadNextItems, loadPreviousItems, queueVisibleUnreadCheck, syncLatestState]);
44889
+ }, [captureWindowPreserveAnchor, clearScrollIdleTimer, clearJumpScrollingLock, dispatch, hasNext, hasPrevious, invalidateEdgeDirection, getCachedPreviousMessages, isLatestJumpLocked, isActiveEdgeRequestCurrent, isPreviousPaginationBlocked, loadNextItems, loadPreviousItems, queueVisibleUnreadCheck, syncLatestState]);
44856
44890
  handleScrollRef.current = handleTimelineScroll;
44857
44891
  React.useEffect(function () {
44858
44892
  var el = scrollRef.current;
@@ -45215,6 +45249,18 @@ function useChatController(_ref5) {
45215
45249
  syncLatestState();
45216
45250
  queueVisibleUnreadCheck();
45217
45251
  }, [messages, notifyIncomingItems, notifyOutgoingItem, queueVisibleUnreadCheck, syncLatestState]);
45252
+ React.useEffect(function () {
45253
+ if (!pendingEdgeCheckAfterLoadRef.current || loadingPrevMessages === LOADING_STATE.LOADING || loadingNextMessages === LOADING_STATE.LOADING) {
45254
+ return;
45255
+ }
45256
+ pendingEdgeCheckAfterLoadRef.current = false;
45257
+ var frameId = requestAnimationFrame(function () {
45258
+ handleScrollRef.current();
45259
+ });
45260
+ return function () {
45261
+ cancelAnimationFrame(frameId);
45262
+ };
45263
+ }, [loadingNextMessages, loadingPrevMessages]);
45218
45264
  React.useEffect(function () {
45219
45265
  serverUnreadCountRef.current = channel.newMessageCount || 0;
45220
45266
  optimisticReadUnreadCountRef.current = 0;
package/index.modern.js CHANGED
@@ -18688,11 +18688,11 @@ function markMessagesRead(action) {
18688
18688
  messageListMarker = _context0.v;
18689
18689
  _context0.n = 5;
18690
18690
  return put(updateChannelDataAC(channel.id, {
18691
- lastReadMessageId: channel.lastDisplayedMessageId
18691
+ lastDisplayedMessageId: channel.lastDisplayedMessageId
18692
18692
  }));
18693
18693
  case 5:
18694
18694
  updateChannelOnAllChannels(channel.id, {
18695
- lastReadMessageId: channel.lastDisplayedMessageId
18695
+ lastDisplayedMessageId: channel.lastDisplayedMessageId
18696
18696
  });
18697
18697
  _iterator6 = _createForOfIteratorHelperLoose(messageListMarker.messageIds);
18698
18698
  case 6:
@@ -19154,7 +19154,7 @@ function notificationsTurnOn() {
19154
19154
  }, _marked14, null, [[3, 6]]);
19155
19155
  }
19156
19156
  function markChannelAsRead(action) {
19157
- var channelId, channel, updateData, _t16;
19157
+ var channelId, channel, updatedChannel, updateData, _t16;
19158
19158
  return _regenerator().w(function (_context16) {
19159
19159
  while (1) switch (_context16.p = _context16.n) {
19160
19160
  case 0:
@@ -19170,10 +19170,12 @@ function markChannelAsRead(action) {
19170
19170
  _context16.n = 2;
19171
19171
  return call(channel.markAsRead);
19172
19172
  case 2:
19173
+ updatedChannel = _context16.v;
19173
19174
  updateData = {
19174
19175
  unread: false,
19175
19176
  newMessageCount: 0,
19176
- newMentionCount: 0
19177
+ newMentionCount: 0,
19178
+ lastDisplayedMessageId: updatedChannel === null || updatedChannel === void 0 ? void 0 : updatedChannel.lastDisplayedMessageId
19177
19179
  };
19178
19180
  updateChannelOnAllChannels(channel.id, updateData);
19179
19181
  _context16.n = 3;
@@ -28328,11 +28330,12 @@ function useOnScreen(ref, rootElement) {
28328
28330
  setIntersecting = _useState[1];
28329
28331
  useEffect(function () {
28330
28332
  if (!(ref !== null && ref !== void 0 && ref.current)) return;
28333
+ var root = rootElement || document.getElementById('scrollableDiv');
28331
28334
  var observer = new IntersectionObserver(function (_ref) {
28332
28335
  var entry = _ref[0];
28333
28336
  return setIntersecting(entry.isIntersecting);
28334
28337
  }, {
28335
- root: rootElement || null,
28338
+ root: root || null,
28336
28339
  rootMargin: '0px',
28337
28340
  threshold: 0.1
28338
28341
  });
@@ -35713,6 +35716,13 @@ var Message = function Message(_ref) {
35713
35716
  }
35714
35717
  }
35715
35718
  }, [channel.isLinkedChannel, channel.lastMessage, dispatch, isVisible, message, scrollToNewMessage.scrollToBottom, unreadScrollTo, setLastVisibleMessageId]);
35719
+ useEffect(function () {
35720
+ return function () {
35721
+ if (!channel.isLinkedChannel) {
35722
+ removeMessageFromVisibleMessagesMap(message);
35723
+ }
35724
+ };
35725
+ }, [channel.isLinkedChannel, message]);
35716
35726
  return /*#__PURE__*/React__default.createElement(Container$c, {
35717
35727
  id: message.id || message.tid,
35718
35728
  ref: messageItemRef,
@@ -43109,6 +43119,13 @@ var Message$1 = function Message(_ref) {
43109
43119
  }
43110
43120
  }
43111
43121
  }, [isVisible, setLastVisibleMessageId, message.id, handleSendReadMarker, channel.isLinkedChannel, channel.lastMessage, scrollToNewMessage.scrollToBottom, dispatch, message, tabIsActive]);
43122
+ useEffect(function () {
43123
+ return function () {
43124
+ if (!channel.isLinkedChannel) {
43125
+ removeMessageFromVisibleMessagesMap(message);
43126
+ }
43127
+ };
43128
+ }, [channel.isLinkedChannel, message]);
43112
43129
  useEffect(function () {
43113
43130
  if (!isVisible && infoPopupOpen) {
43114
43131
  setInfoPopupOpen(false);
@@ -44528,6 +44545,12 @@ function useChatController(_ref5) {
44528
44545
  return Promise.reject(e);
44529
44546
  }
44530
44547
  }, [beginEdgePagedRequest, channel.id, connectionStatus, dispatch, hasNextMessages, isNextLoading, scrollToMentionedMessage, scrollToNewMessage.scrollToBottom]);
44548
+ var isPreviousPaginationBlocked = useCallback(function (allowWhilePreviousLoading) {
44549
+ if (allowWhilePreviousLoading === void 0) {
44550
+ allowWhilePreviousLoading = false;
44551
+ }
44552
+ return !!windowLoadScopeRef.current || !allowWhilePreviousLoading && isPreviousLoading;
44553
+ }, [isPreviousLoading]);
44531
44554
  var loadPreviousItems = useCallback(function () {
44532
44555
  try {
44533
44556
  if (isJumping.current) {
@@ -44576,6 +44599,11 @@ function useChatController(_ref5) {
44576
44599
  });
44577
44600
  return Promise.resolve();
44578
44601
  }
44602
+ if (isPreviousPaginationBlocked()) {
44603
+ pendingEdgeCheckAfterLoadRef.current = true;
44604
+ historyLoadArmedRef.current = true;
44605
+ return Promise.resolve();
44606
+ }
44579
44607
  if (!oldestVisibleId) {
44580
44608
  activeEdgeIntentRef.current = null;
44581
44609
  historyLoadArmedRef.current = true;
@@ -44631,7 +44659,7 @@ function useChatController(_ref5) {
44631
44659
  } catch (e) {
44632
44660
  return Promise.reject(e);
44633
44661
  }
44634
- }, [channel.id, clearPreserveAnchorForRequest, consumeSuppressedMessageChange, createEdgeRequestId, clearPendingLatestJump, dispatch, getCachedPreviousMessages, suppressNextMessageChange, hasNext, hasPrevious, isActiveEdgeRequestCurrent, isLoadingPrevious, loadPrevious, messages, requestDirectionalPrefetchIfNeeded]);
44662
+ }, [channel.id, clearPreserveAnchorForRequest, consumeSuppressedMessageChange, createEdgeRequestId, clearPendingLatestJump, dispatch, getCachedPreviousMessages, suppressNextMessageChange, hasNext, hasPrevious, isPreviousPaginationBlocked, isActiveEdgeRequestCurrent, isLoadingPrevious, loadPrevious, messages, requestDirectionalPrefetchIfNeeded]);
44635
44663
  var loadNextItems = useCallback(function () {
44636
44664
  try {
44637
44665
  if (isJumping.current) {
@@ -44812,6 +44840,12 @@ function useChatController(_ref5) {
44812
44840
  }
44813
44841
  activeEdgeIntentRef.current = 'previous';
44814
44842
  if (historyLoadArmedRef.current) {
44843
+ var oldestVisibleMessage = messages[0];
44844
+ var hasCachedPreviousMessages = oldestVisibleMessage ? getCachedPreviousMessages(oldestVisibleMessage).length > 0 : false;
44845
+ if (isPreviousPaginationBlocked(hasCachedPreviousMessages)) {
44846
+ pendingEdgeCheckAfterLoadRef.current = true;
44847
+ return;
44848
+ }
44815
44849
  historyLoadArmedRef.current = false;
44816
44850
  loadPreviousItems();
44817
44851
  return;
@@ -44851,7 +44885,7 @@ function useChatController(_ref5) {
44851
44885
  dispatch(refreshCacheAroundMessageAC(channelRef.current.id, anchorId, true));
44852
44886
  }, SCROLL_IDLE_MS);
44853
44887
  }
44854
- }, [captureWindowPreserveAnchor, clearScrollIdleTimer, clearJumpScrollingLock, dispatch, hasNext, hasPrevious, invalidateEdgeDirection, isLatestJumpLocked, isActiveEdgeRequestCurrent, loadNextItems, loadPreviousItems, queueVisibleUnreadCheck, syncLatestState]);
44888
+ }, [captureWindowPreserveAnchor, clearScrollIdleTimer, clearJumpScrollingLock, dispatch, hasNext, hasPrevious, invalidateEdgeDirection, getCachedPreviousMessages, isLatestJumpLocked, isActiveEdgeRequestCurrent, isPreviousPaginationBlocked, loadNextItems, loadPreviousItems, queueVisibleUnreadCheck, syncLatestState]);
44855
44889
  handleScrollRef.current = handleTimelineScroll;
44856
44890
  useEffect(function () {
44857
44891
  var el = scrollRef.current;
@@ -45214,6 +45248,18 @@ function useChatController(_ref5) {
45214
45248
  syncLatestState();
45215
45249
  queueVisibleUnreadCheck();
45216
45250
  }, [messages, notifyIncomingItems, notifyOutgoingItem, queueVisibleUnreadCheck, syncLatestState]);
45251
+ useEffect(function () {
45252
+ if (!pendingEdgeCheckAfterLoadRef.current || loadingPrevMessages === LOADING_STATE.LOADING || loadingNextMessages === LOADING_STATE.LOADING) {
45253
+ return;
45254
+ }
45255
+ pendingEdgeCheckAfterLoadRef.current = false;
45256
+ var frameId = requestAnimationFrame(function () {
45257
+ handleScrollRef.current();
45258
+ });
45259
+ return function () {
45260
+ cancelAnimationFrame(frameId);
45261
+ };
45262
+ }, [loadingNextMessages, loadingPrevMessages]);
45217
45263
  useEffect(function () {
45218
45264
  serverUnreadCountRef.current = channel.newMessageCount || 0;
45219
45265
  optimisticReadUnreadCountRef.current = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sceyt-chat-react-uikit",
3
- "version": "1.8.6-beta.3",
3
+ "version": "1.8.6-beta.5",
4
4
  "description": "Interactive React UI Components for Sceyt Chat.",
5
5
  "author": "Sceyt",
6
6
  "license": "MIT",