sceyt-chat-react-uikit 1.8.6-beta.3 → 1.8.6-beta.4
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 +47 -3
- package/index.modern.js +47 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -28329,11 +28329,12 @@ function useOnScreen(ref, rootElement) {
|
|
|
28329
28329
|
setIntersecting = _useState[1];
|
|
28330
28330
|
React.useEffect(function () {
|
|
28331
28331
|
if (!(ref !== null && ref !== void 0 && ref.current)) return;
|
|
28332
|
+
var root = rootElement || document.getElementById('scrollableDiv');
|
|
28332
28333
|
var observer = new IntersectionObserver(function (_ref) {
|
|
28333
28334
|
var entry = _ref[0];
|
|
28334
28335
|
return setIntersecting(entry.isIntersecting);
|
|
28335
28336
|
}, {
|
|
28336
|
-
root:
|
|
28337
|
+
root: root || null,
|
|
28337
28338
|
rootMargin: '0px',
|
|
28338
28339
|
threshold: 0.1
|
|
28339
28340
|
});
|
|
@@ -35714,6 +35715,13 @@ var Message = function Message(_ref) {
|
|
|
35714
35715
|
}
|
|
35715
35716
|
}
|
|
35716
35717
|
}, [channel.isLinkedChannel, channel.lastMessage, dispatch, isVisible, message, scrollToNewMessage.scrollToBottom, unreadScrollTo, setLastVisibleMessageId]);
|
|
35718
|
+
React.useEffect(function () {
|
|
35719
|
+
return function () {
|
|
35720
|
+
if (!channel.isLinkedChannel) {
|
|
35721
|
+
removeMessageFromVisibleMessagesMap(message);
|
|
35722
|
+
}
|
|
35723
|
+
};
|
|
35724
|
+
}, [channel.isLinkedChannel, message]);
|
|
35717
35725
|
return /*#__PURE__*/React__default.createElement(Container$c, {
|
|
35718
35726
|
id: message.id || message.tid,
|
|
35719
35727
|
ref: messageItemRef,
|
|
@@ -43110,6 +43118,13 @@ var Message$1 = function Message(_ref) {
|
|
|
43110
43118
|
}
|
|
43111
43119
|
}
|
|
43112
43120
|
}, [isVisible, setLastVisibleMessageId, message.id, handleSendReadMarker, channel.isLinkedChannel, channel.lastMessage, scrollToNewMessage.scrollToBottom, dispatch, message, tabIsActive]);
|
|
43121
|
+
React.useEffect(function () {
|
|
43122
|
+
return function () {
|
|
43123
|
+
if (!channel.isLinkedChannel) {
|
|
43124
|
+
removeMessageFromVisibleMessagesMap(message);
|
|
43125
|
+
}
|
|
43126
|
+
};
|
|
43127
|
+
}, [channel.isLinkedChannel, message]);
|
|
43113
43128
|
React.useEffect(function () {
|
|
43114
43129
|
if (!isVisible && infoPopupOpen) {
|
|
43115
43130
|
setInfoPopupOpen(false);
|
|
@@ -44529,6 +44544,12 @@ function useChatController(_ref5) {
|
|
|
44529
44544
|
return Promise.reject(e);
|
|
44530
44545
|
}
|
|
44531
44546
|
}, [beginEdgePagedRequest, channel.id, connectionStatus, dispatch, hasNextMessages, isNextLoading, scrollToMentionedMessage, scrollToNewMessage.scrollToBottom]);
|
|
44547
|
+
var isPreviousPaginationBlocked = React.useCallback(function (allowWhilePreviousLoading) {
|
|
44548
|
+
if (allowWhilePreviousLoading === void 0) {
|
|
44549
|
+
allowWhilePreviousLoading = false;
|
|
44550
|
+
}
|
|
44551
|
+
return !!windowLoadScopeRef.current || !allowWhilePreviousLoading && isPreviousLoading;
|
|
44552
|
+
}, [isPreviousLoading]);
|
|
44532
44553
|
var loadPreviousItems = React.useCallback(function () {
|
|
44533
44554
|
try {
|
|
44534
44555
|
if (isJumping.current) {
|
|
@@ -44577,6 +44598,11 @@ function useChatController(_ref5) {
|
|
|
44577
44598
|
});
|
|
44578
44599
|
return Promise.resolve();
|
|
44579
44600
|
}
|
|
44601
|
+
if (isPreviousPaginationBlocked()) {
|
|
44602
|
+
pendingEdgeCheckAfterLoadRef.current = true;
|
|
44603
|
+
historyLoadArmedRef.current = true;
|
|
44604
|
+
return Promise.resolve();
|
|
44605
|
+
}
|
|
44580
44606
|
if (!oldestVisibleId) {
|
|
44581
44607
|
activeEdgeIntentRef.current = null;
|
|
44582
44608
|
historyLoadArmedRef.current = true;
|
|
@@ -44632,7 +44658,7 @@ function useChatController(_ref5) {
|
|
|
44632
44658
|
} catch (e) {
|
|
44633
44659
|
return Promise.reject(e);
|
|
44634
44660
|
}
|
|
44635
|
-
}, [channel.id, clearPreserveAnchorForRequest, consumeSuppressedMessageChange, createEdgeRequestId, clearPendingLatestJump, dispatch, getCachedPreviousMessages, suppressNextMessageChange, hasNext, hasPrevious, isActiveEdgeRequestCurrent, isLoadingPrevious, loadPrevious, messages, requestDirectionalPrefetchIfNeeded]);
|
|
44661
|
+
}, [channel.id, clearPreserveAnchorForRequest, consumeSuppressedMessageChange, createEdgeRequestId, clearPendingLatestJump, dispatch, getCachedPreviousMessages, suppressNextMessageChange, hasNext, hasPrevious, isPreviousPaginationBlocked, isActiveEdgeRequestCurrent, isLoadingPrevious, loadPrevious, messages, requestDirectionalPrefetchIfNeeded]);
|
|
44636
44662
|
var loadNextItems = React.useCallback(function () {
|
|
44637
44663
|
try {
|
|
44638
44664
|
if (isJumping.current) {
|
|
@@ -44813,6 +44839,12 @@ function useChatController(_ref5) {
|
|
|
44813
44839
|
}
|
|
44814
44840
|
activeEdgeIntentRef.current = 'previous';
|
|
44815
44841
|
if (historyLoadArmedRef.current) {
|
|
44842
|
+
var oldestVisibleMessage = messages[0];
|
|
44843
|
+
var hasCachedPreviousMessages = oldestVisibleMessage ? getCachedPreviousMessages(oldestVisibleMessage).length > 0 : false;
|
|
44844
|
+
if (isPreviousPaginationBlocked(hasCachedPreviousMessages)) {
|
|
44845
|
+
pendingEdgeCheckAfterLoadRef.current = true;
|
|
44846
|
+
return;
|
|
44847
|
+
}
|
|
44816
44848
|
historyLoadArmedRef.current = false;
|
|
44817
44849
|
loadPreviousItems();
|
|
44818
44850
|
return;
|
|
@@ -44852,7 +44884,7 @@ function useChatController(_ref5) {
|
|
|
44852
44884
|
dispatch(refreshCacheAroundMessageAC(channelRef.current.id, anchorId, true));
|
|
44853
44885
|
}, SCROLL_IDLE_MS);
|
|
44854
44886
|
}
|
|
44855
|
-
}, [captureWindowPreserveAnchor, clearScrollIdleTimer, clearJumpScrollingLock, dispatch, hasNext, hasPrevious, invalidateEdgeDirection, isLatestJumpLocked, isActiveEdgeRequestCurrent, loadNextItems, loadPreviousItems, queueVisibleUnreadCheck, syncLatestState]);
|
|
44887
|
+
}, [captureWindowPreserveAnchor, clearScrollIdleTimer, clearJumpScrollingLock, dispatch, hasNext, hasPrevious, invalidateEdgeDirection, getCachedPreviousMessages, isLatestJumpLocked, isActiveEdgeRequestCurrent, isPreviousPaginationBlocked, loadNextItems, loadPreviousItems, queueVisibleUnreadCheck, syncLatestState]);
|
|
44856
44888
|
handleScrollRef.current = handleTimelineScroll;
|
|
44857
44889
|
React.useEffect(function () {
|
|
44858
44890
|
var el = scrollRef.current;
|
|
@@ -45215,6 +45247,18 @@ function useChatController(_ref5) {
|
|
|
45215
45247
|
syncLatestState();
|
|
45216
45248
|
queueVisibleUnreadCheck();
|
|
45217
45249
|
}, [messages, notifyIncomingItems, notifyOutgoingItem, queueVisibleUnreadCheck, syncLatestState]);
|
|
45250
|
+
React.useEffect(function () {
|
|
45251
|
+
if (!pendingEdgeCheckAfterLoadRef.current || loadingPrevMessages === LOADING_STATE.LOADING || loadingNextMessages === LOADING_STATE.LOADING) {
|
|
45252
|
+
return;
|
|
45253
|
+
}
|
|
45254
|
+
pendingEdgeCheckAfterLoadRef.current = false;
|
|
45255
|
+
var frameId = requestAnimationFrame(function () {
|
|
45256
|
+
handleScrollRef.current();
|
|
45257
|
+
});
|
|
45258
|
+
return function () {
|
|
45259
|
+
cancelAnimationFrame(frameId);
|
|
45260
|
+
};
|
|
45261
|
+
}, [loadingNextMessages, loadingPrevMessages]);
|
|
45218
45262
|
React.useEffect(function () {
|
|
45219
45263
|
serverUnreadCountRef.current = channel.newMessageCount || 0;
|
|
45220
45264
|
optimisticReadUnreadCountRef.current = 0;
|
package/index.modern.js
CHANGED
|
@@ -28328,11 +28328,12 @@ function useOnScreen(ref, rootElement) {
|
|
|
28328
28328
|
setIntersecting = _useState[1];
|
|
28329
28329
|
useEffect(function () {
|
|
28330
28330
|
if (!(ref !== null && ref !== void 0 && ref.current)) return;
|
|
28331
|
+
var root = rootElement || document.getElementById('scrollableDiv');
|
|
28331
28332
|
var observer = new IntersectionObserver(function (_ref) {
|
|
28332
28333
|
var entry = _ref[0];
|
|
28333
28334
|
return setIntersecting(entry.isIntersecting);
|
|
28334
28335
|
}, {
|
|
28335
|
-
root:
|
|
28336
|
+
root: root || null,
|
|
28336
28337
|
rootMargin: '0px',
|
|
28337
28338
|
threshold: 0.1
|
|
28338
28339
|
});
|
|
@@ -35713,6 +35714,13 @@ var Message = function Message(_ref) {
|
|
|
35713
35714
|
}
|
|
35714
35715
|
}
|
|
35715
35716
|
}, [channel.isLinkedChannel, channel.lastMessage, dispatch, isVisible, message, scrollToNewMessage.scrollToBottom, unreadScrollTo, setLastVisibleMessageId]);
|
|
35717
|
+
useEffect(function () {
|
|
35718
|
+
return function () {
|
|
35719
|
+
if (!channel.isLinkedChannel) {
|
|
35720
|
+
removeMessageFromVisibleMessagesMap(message);
|
|
35721
|
+
}
|
|
35722
|
+
};
|
|
35723
|
+
}, [channel.isLinkedChannel, message]);
|
|
35716
35724
|
return /*#__PURE__*/React__default.createElement(Container$c, {
|
|
35717
35725
|
id: message.id || message.tid,
|
|
35718
35726
|
ref: messageItemRef,
|
|
@@ -43109,6 +43117,13 @@ var Message$1 = function Message(_ref) {
|
|
|
43109
43117
|
}
|
|
43110
43118
|
}
|
|
43111
43119
|
}, [isVisible, setLastVisibleMessageId, message.id, handleSendReadMarker, channel.isLinkedChannel, channel.lastMessage, scrollToNewMessage.scrollToBottom, dispatch, message, tabIsActive]);
|
|
43120
|
+
useEffect(function () {
|
|
43121
|
+
return function () {
|
|
43122
|
+
if (!channel.isLinkedChannel) {
|
|
43123
|
+
removeMessageFromVisibleMessagesMap(message);
|
|
43124
|
+
}
|
|
43125
|
+
};
|
|
43126
|
+
}, [channel.isLinkedChannel, message]);
|
|
43112
43127
|
useEffect(function () {
|
|
43113
43128
|
if (!isVisible && infoPopupOpen) {
|
|
43114
43129
|
setInfoPopupOpen(false);
|
|
@@ -44528,6 +44543,12 @@ function useChatController(_ref5) {
|
|
|
44528
44543
|
return Promise.reject(e);
|
|
44529
44544
|
}
|
|
44530
44545
|
}, [beginEdgePagedRequest, channel.id, connectionStatus, dispatch, hasNextMessages, isNextLoading, scrollToMentionedMessage, scrollToNewMessage.scrollToBottom]);
|
|
44546
|
+
var isPreviousPaginationBlocked = useCallback(function (allowWhilePreviousLoading) {
|
|
44547
|
+
if (allowWhilePreviousLoading === void 0) {
|
|
44548
|
+
allowWhilePreviousLoading = false;
|
|
44549
|
+
}
|
|
44550
|
+
return !!windowLoadScopeRef.current || !allowWhilePreviousLoading && isPreviousLoading;
|
|
44551
|
+
}, [isPreviousLoading]);
|
|
44531
44552
|
var loadPreviousItems = useCallback(function () {
|
|
44532
44553
|
try {
|
|
44533
44554
|
if (isJumping.current) {
|
|
@@ -44576,6 +44597,11 @@ function useChatController(_ref5) {
|
|
|
44576
44597
|
});
|
|
44577
44598
|
return Promise.resolve();
|
|
44578
44599
|
}
|
|
44600
|
+
if (isPreviousPaginationBlocked()) {
|
|
44601
|
+
pendingEdgeCheckAfterLoadRef.current = true;
|
|
44602
|
+
historyLoadArmedRef.current = true;
|
|
44603
|
+
return Promise.resolve();
|
|
44604
|
+
}
|
|
44579
44605
|
if (!oldestVisibleId) {
|
|
44580
44606
|
activeEdgeIntentRef.current = null;
|
|
44581
44607
|
historyLoadArmedRef.current = true;
|
|
@@ -44631,7 +44657,7 @@ function useChatController(_ref5) {
|
|
|
44631
44657
|
} catch (e) {
|
|
44632
44658
|
return Promise.reject(e);
|
|
44633
44659
|
}
|
|
44634
|
-
}, [channel.id, clearPreserveAnchorForRequest, consumeSuppressedMessageChange, createEdgeRequestId, clearPendingLatestJump, dispatch, getCachedPreviousMessages, suppressNextMessageChange, hasNext, hasPrevious, isActiveEdgeRequestCurrent, isLoadingPrevious, loadPrevious, messages, requestDirectionalPrefetchIfNeeded]);
|
|
44660
|
+
}, [channel.id, clearPreserveAnchorForRequest, consumeSuppressedMessageChange, createEdgeRequestId, clearPendingLatestJump, dispatch, getCachedPreviousMessages, suppressNextMessageChange, hasNext, hasPrevious, isPreviousPaginationBlocked, isActiveEdgeRequestCurrent, isLoadingPrevious, loadPrevious, messages, requestDirectionalPrefetchIfNeeded]);
|
|
44635
44661
|
var loadNextItems = useCallback(function () {
|
|
44636
44662
|
try {
|
|
44637
44663
|
if (isJumping.current) {
|
|
@@ -44812,6 +44838,12 @@ function useChatController(_ref5) {
|
|
|
44812
44838
|
}
|
|
44813
44839
|
activeEdgeIntentRef.current = 'previous';
|
|
44814
44840
|
if (historyLoadArmedRef.current) {
|
|
44841
|
+
var oldestVisibleMessage = messages[0];
|
|
44842
|
+
var hasCachedPreviousMessages = oldestVisibleMessage ? getCachedPreviousMessages(oldestVisibleMessage).length > 0 : false;
|
|
44843
|
+
if (isPreviousPaginationBlocked(hasCachedPreviousMessages)) {
|
|
44844
|
+
pendingEdgeCheckAfterLoadRef.current = true;
|
|
44845
|
+
return;
|
|
44846
|
+
}
|
|
44815
44847
|
historyLoadArmedRef.current = false;
|
|
44816
44848
|
loadPreviousItems();
|
|
44817
44849
|
return;
|
|
@@ -44851,7 +44883,7 @@ function useChatController(_ref5) {
|
|
|
44851
44883
|
dispatch(refreshCacheAroundMessageAC(channelRef.current.id, anchorId, true));
|
|
44852
44884
|
}, SCROLL_IDLE_MS);
|
|
44853
44885
|
}
|
|
44854
|
-
}, [captureWindowPreserveAnchor, clearScrollIdleTimer, clearJumpScrollingLock, dispatch, hasNext, hasPrevious, invalidateEdgeDirection, isLatestJumpLocked, isActiveEdgeRequestCurrent, loadNextItems, loadPreviousItems, queueVisibleUnreadCheck, syncLatestState]);
|
|
44886
|
+
}, [captureWindowPreserveAnchor, clearScrollIdleTimer, clearJumpScrollingLock, dispatch, hasNext, hasPrevious, invalidateEdgeDirection, getCachedPreviousMessages, isLatestJumpLocked, isActiveEdgeRequestCurrent, isPreviousPaginationBlocked, loadNextItems, loadPreviousItems, queueVisibleUnreadCheck, syncLatestState]);
|
|
44855
44887
|
handleScrollRef.current = handleTimelineScroll;
|
|
44856
44888
|
useEffect(function () {
|
|
44857
44889
|
var el = scrollRef.current;
|
|
@@ -45214,6 +45246,18 @@ function useChatController(_ref5) {
|
|
|
45214
45246
|
syncLatestState();
|
|
45215
45247
|
queueVisibleUnreadCheck();
|
|
45216
45248
|
}, [messages, notifyIncomingItems, notifyOutgoingItem, queueVisibleUnreadCheck, syncLatestState]);
|
|
45249
|
+
useEffect(function () {
|
|
45250
|
+
if (!pendingEdgeCheckAfterLoadRef.current || loadingPrevMessages === LOADING_STATE.LOADING || loadingNextMessages === LOADING_STATE.LOADING) {
|
|
45251
|
+
return;
|
|
45252
|
+
}
|
|
45253
|
+
pendingEdgeCheckAfterLoadRef.current = false;
|
|
45254
|
+
var frameId = requestAnimationFrame(function () {
|
|
45255
|
+
handleScrollRef.current();
|
|
45256
|
+
});
|
|
45257
|
+
return function () {
|
|
45258
|
+
cancelAnimationFrame(frameId);
|
|
45259
|
+
};
|
|
45260
|
+
}, [loadingNextMessages, loadingPrevMessages]);
|
|
45217
45261
|
useEffect(function () {
|
|
45218
45262
|
serverUnreadCountRef.current = channel.newMessageCount || 0;
|
|
45219
45263
|
optimisticReadUnreadCountRef.current = 0;
|