stream-chat-react 12.2.2 → 12.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ChatView/ChatView.js +4 -2
- package/dist/components/Dialog/hooks/useDialog.js +6 -6
- package/dist/components/Thread/Thread.js +8 -8
- package/dist/components/Threads/ThreadList/ThreadList.js +2 -2
- package/dist/components/Threads/ThreadList/ThreadListItemUI.js +8 -8
- package/dist/components/Threads/ThreadList/ThreadListLoadingIndicator.js +4 -2
- package/dist/components/Threads/ThreadList/ThreadListUnseenThreadsBanner.js +4 -2
- package/dist/index.browser.cjs +36 -30
- package/dist/index.browser.cjs.map +2 -2
- package/dist/index.node.cjs +36 -30
- package/dist/index.node.cjs.map +2 -2
- package/dist/store/hooks/useStateStore.d.ts +2 -2
- package/package.json +3 -3
|
@@ -83,10 +83,12 @@ const ThreadAdapter = ({ children }) => {
|
|
|
83
83
|
useActiveThread({ activeThread });
|
|
84
84
|
return React.createElement(ThreadProvider, { thread: activeThread }, children);
|
|
85
85
|
};
|
|
86
|
-
const selector = (
|
|
86
|
+
const selector = ({ unreadThreadCount }) => ({
|
|
87
|
+
unreadThreadCount,
|
|
88
|
+
});
|
|
87
89
|
const ChatViewSelector = () => {
|
|
88
90
|
const { client } = useChatContext();
|
|
89
|
-
const
|
|
91
|
+
const { unreadThreadCount } = useStateStore(client.threads.state, selector);
|
|
90
92
|
const { activeChatView, setActiveChatView } = useContext(ChatViewContext);
|
|
91
93
|
return (React.createElement("div", { className: 'str-chat__chat-view__selector' },
|
|
92
94
|
React.createElement("button", { "aria-selected": activeChatView === 'channels', className: 'str-chat__chat-view__selector-button', onPointerDown: () => setActiveChatView('channels'), role: 'tab' },
|
|
@@ -10,17 +10,17 @@ export const useDialog = ({ id }) => {
|
|
|
10
10
|
};
|
|
11
11
|
export const useDialogIsOpen = (id) => {
|
|
12
12
|
const { dialogManager } = useDialogManager();
|
|
13
|
-
const dialogIsOpenSelector = useCallback(({ dialogsById }) =>
|
|
14
|
-
return useStateStore(dialogManager.state, dialogIsOpenSelector)
|
|
13
|
+
const dialogIsOpenSelector = useCallback(({ dialogsById }) => ({ isOpen: !!dialogsById[id]?.isOpen }), [id]);
|
|
14
|
+
return useStateStore(dialogManager.state, dialogIsOpenSelector).isOpen;
|
|
15
15
|
};
|
|
16
|
-
const openedDialogCountSelector = (nextValue) =>
|
|
17
|
-
Object.values(nextValue.dialogsById).reduce((count, dialog) => {
|
|
16
|
+
const openedDialogCountSelector = (nextValue) => ({
|
|
17
|
+
openedDialogCount: Object.values(nextValue.dialogsById).reduce((count, dialog) => {
|
|
18
18
|
if (dialog.isOpen)
|
|
19
19
|
return count + 1;
|
|
20
20
|
return count;
|
|
21
21
|
}, 0),
|
|
22
|
-
|
|
22
|
+
});
|
|
23
23
|
export const useOpenedDialogCount = () => {
|
|
24
24
|
const { dialogManager } = useDialogManager();
|
|
25
|
-
return useStateStore(dialogManager.state, openedDialogCountSelector)
|
|
25
|
+
return useStateStore(dialogManager.state, openedDialogCountSelector).openedDialogCount;
|
|
26
26
|
};
|
|
@@ -21,16 +21,16 @@ export const Thread = (props) => {
|
|
|
21
21
|
// FIXME: TS is having trouble here as at least one of the two would always be defined
|
|
22
22
|
React.createElement(ThreadInner, { ...props, key: `thread-${(thread ?? threadInstance)?.id}-${channel?.cid}` }));
|
|
23
23
|
};
|
|
24
|
-
const selector = (nextValue) =>
|
|
25
|
-
nextValue.
|
|
26
|
-
nextValue.pagination.isLoadingPrev,
|
|
27
|
-
nextValue.
|
|
28
|
-
nextValue.
|
|
29
|
-
|
|
24
|
+
const selector = (nextValue) => ({
|
|
25
|
+
isLoadingNext: nextValue.pagination.isLoadingNext,
|
|
26
|
+
isLoadingPrev: nextValue.pagination.isLoadingPrev,
|
|
27
|
+
parentMessage: nextValue.parentMessage,
|
|
28
|
+
replies: nextValue.replies,
|
|
29
|
+
});
|
|
30
30
|
const ThreadInner = (props) => {
|
|
31
31
|
const { additionalMessageInputProps, additionalMessageListProps, additionalParentMessageProps, additionalVirtualizedMessageListProps, autoFocus = true, enableDateSeparator = false, Input: PropInput, Message: PropMessage, messageActions = Object.keys(MESSAGE_ACTIONS), virtualized, } = props;
|
|
32
32
|
const threadInstance = useThreadContext();
|
|
33
|
-
const
|
|
33
|
+
const { isLoadingNext, isLoadingPrev, parentMessage, replies } = useStateStore(threadInstance?.state, selector) ?? {};
|
|
34
34
|
const { thread, threadHasMore, threadLoadingMore, threadMessages = [], threadSuppressAutoscroll, } = useChannelStateContext('Thread');
|
|
35
35
|
const { closeThread, loadMoreThread } = useChannelActionContext('Thread');
|
|
36
36
|
const { customClasses } = useChatContext('Thread');
|
|
@@ -53,7 +53,7 @@ const ThreadInner = (props) => {
|
|
|
53
53
|
loadingMoreNewer: isLoadingNext,
|
|
54
54
|
loadMore: threadInstance.loadPrevPage,
|
|
55
55
|
loadMoreNewer: threadInstance.loadNextPage,
|
|
56
|
-
messages:
|
|
56
|
+
messages: replies,
|
|
57
57
|
}
|
|
58
58
|
: {
|
|
59
59
|
hasMore: threadHasMore,
|
|
@@ -6,7 +6,7 @@ import { ThreadListUnseenThreadsBanner as DefaultThreadListUnseenThreadsBanner }
|
|
|
6
6
|
import { ThreadListLoadingIndicator as DefaultThreadListLoadingIndicator } from './ThreadListLoadingIndicator';
|
|
7
7
|
import { useChatContext, useComponentContext } from '../../../context';
|
|
8
8
|
import { useStateStore } from '../../../store';
|
|
9
|
-
const selector = (nextValue) =>
|
|
9
|
+
const selector = (nextValue) => ({ threads: nextValue.threads });
|
|
10
10
|
const computeItemKey = (_, item) => item.id;
|
|
11
11
|
export const useThreadList = () => {
|
|
12
12
|
const { client } = useChatContext();
|
|
@@ -30,7 +30,7 @@ export const useThreadList = () => {
|
|
|
30
30
|
export const ThreadList = ({ virtuosoProps }) => {
|
|
31
31
|
const { client } = useChatContext();
|
|
32
32
|
const { ThreadListItem = DefaultThreadListItem, ThreadListEmptyPlaceholder = DefaultThreadListEmptyPlaceholder, ThreadListLoadingIndicator = DefaultThreadListLoadingIndicator, ThreadListUnseenThreadsBanner = DefaultThreadListUnseenThreadsBanner, } = useComponentContext();
|
|
33
|
-
const
|
|
33
|
+
const { threads } = useStateStore(client.threads.state, selector);
|
|
34
34
|
useThreadList();
|
|
35
35
|
return (React.createElement("div", { className: 'str-chat__thread-list-container' },
|
|
36
36
|
React.createElement(ThreadListUnseenThreadsBanner, null),
|
|
@@ -42,14 +42,14 @@ export const ThreadListItemUI = (props) => {
|
|
|
42
42
|
const { client } = useChatContext();
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
44
44
|
const thread = useThreadListItemContext();
|
|
45
|
-
const selector = useCallback((nextValue) =>
|
|
46
|
-
nextValue.
|
|
47
|
-
|
|
48
|
-
nextValue.
|
|
49
|
-
nextValue.
|
|
50
|
-
nextValue.
|
|
51
|
-
|
|
52
|
-
const
|
|
45
|
+
const selector = useCallback((nextValue) => ({
|
|
46
|
+
channel: nextValue.channel,
|
|
47
|
+
deletedAt: nextValue.deletedAt,
|
|
48
|
+
latestReply: nextValue.replies.at(-1),
|
|
49
|
+
ownUnreadMessageCount: (client.userID && nextValue.read[client.userID]?.unreadMessageCount) || 0,
|
|
50
|
+
parentMessage: nextValue.parentMessage,
|
|
51
|
+
}), [client]);
|
|
52
|
+
const { channel, deletedAt, latestReply, ownUnreadMessageCount, parentMessage } = useStateStore(thread.state, selector);
|
|
53
53
|
const { displayTitle: channelDisplayTitle } = useChannelPreviewInfo({ channel });
|
|
54
54
|
const { activeThread, setActiveThread } = useThreadsViewContext();
|
|
55
55
|
const avatarProps = deletedAt ? null : latestReply?.user;
|
|
@@ -2,11 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import { LoadingIndicator as DefaultLoadingIndicator } from '../../Loading';
|
|
3
3
|
import { useChatContext, useComponentContext } from '../../../context';
|
|
4
4
|
import { useStateStore } from '../../../store';
|
|
5
|
-
const selector = (nextValue) =>
|
|
5
|
+
const selector = (nextValue) => ({
|
|
6
|
+
isLoadingNext: nextValue.pagination.isLoadingNext,
|
|
7
|
+
});
|
|
6
8
|
export const ThreadListLoadingIndicator = () => {
|
|
7
9
|
const { LoadingIndicator = DefaultLoadingIndicator } = useComponentContext();
|
|
8
10
|
const { client } = useChatContext();
|
|
9
|
-
const
|
|
11
|
+
const { isLoadingNext } = useStateStore(client.threads.state, selector);
|
|
10
12
|
if (!isLoadingNext)
|
|
11
13
|
return null;
|
|
12
14
|
return (React.createElement("div", { className: 'str-chat__thread-list-loading-indicator' },
|
|
@@ -2,10 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import { Icon } from '../icons';
|
|
3
3
|
import { useChatContext } from '../../../context';
|
|
4
4
|
import { useStateStore } from '../../../store';
|
|
5
|
-
const selector = (nextValue) =>
|
|
5
|
+
const selector = (nextValue) => ({
|
|
6
|
+
unseenThreadIds: nextValue.unseenThreadIds,
|
|
7
|
+
});
|
|
6
8
|
export const ThreadListUnseenThreadsBanner = () => {
|
|
7
9
|
const { client } = useChatContext();
|
|
8
|
-
const
|
|
10
|
+
const { unseenThreadIds } = useStateStore(client.threads.state, selector);
|
|
9
11
|
if (!unseenThreadIds.length)
|
|
10
12
|
return null;
|
|
11
13
|
return (React.createElement("div", { className: 'str-chat__unseen-threads-banner' },
|
package/dist/index.browser.cjs
CHANGED
|
@@ -18026,20 +18026,20 @@ var useDialog = ({ id }) => {
|
|
|
18026
18026
|
var useDialogIsOpen = (id) => {
|
|
18027
18027
|
const { dialogManager } = useDialogManager();
|
|
18028
18028
|
const dialogIsOpenSelector = (0, import_react7.useCallback)(
|
|
18029
|
-
({ dialogsById }) =>
|
|
18029
|
+
({ dialogsById }) => ({ isOpen: !!dialogsById[id]?.isOpen }),
|
|
18030
18030
|
[id]
|
|
18031
18031
|
);
|
|
18032
|
-
return useStateStore(dialogManager.state, dialogIsOpenSelector)
|
|
18032
|
+
return useStateStore(dialogManager.state, dialogIsOpenSelector).isOpen;
|
|
18033
18033
|
};
|
|
18034
|
-
var openedDialogCountSelector = (nextValue) =>
|
|
18035
|
-
Object.values(nextValue.dialogsById).reduce((count, dialog) => {
|
|
18034
|
+
var openedDialogCountSelector = (nextValue) => ({
|
|
18035
|
+
openedDialogCount: Object.values(nextValue.dialogsById).reduce((count, dialog) => {
|
|
18036
18036
|
if (dialog.isOpen) return count + 1;
|
|
18037
18037
|
return count;
|
|
18038
18038
|
}, 0)
|
|
18039
|
-
|
|
18039
|
+
});
|
|
18040
18040
|
var useOpenedDialogCount = () => {
|
|
18041
18041
|
const { dialogManager } = useDialogManager();
|
|
18042
|
-
return useStateStore(dialogManager.state, openedDialogCountSelector)
|
|
18042
|
+
return useStateStore(dialogManager.state, openedDialogCountSelector).openedDialogCount;
|
|
18043
18043
|
};
|
|
18044
18044
|
|
|
18045
18045
|
// src/components/Dialog/DialogPortal.tsx
|
|
@@ -39353,10 +39353,12 @@ var ThreadAdapter = ({ children }) => {
|
|
|
39353
39353
|
useActiveThread({ activeThread });
|
|
39354
39354
|
return /* @__PURE__ */ import_react89.default.createElement(ThreadProvider, { thread: activeThread }, children);
|
|
39355
39355
|
};
|
|
39356
|
-
var selector = (
|
|
39356
|
+
var selector = ({ unreadThreadCount }) => ({
|
|
39357
|
+
unreadThreadCount
|
|
39358
|
+
});
|
|
39357
39359
|
var ChatViewSelector = () => {
|
|
39358
39360
|
const { client } = useChatContext();
|
|
39359
|
-
const
|
|
39361
|
+
const { unreadThreadCount } = useStateStore(client.threads.state, selector);
|
|
39360
39362
|
const { activeChatView, setActiveChatView } = (0, import_react89.useContext)(ChatViewContext);
|
|
39361
39363
|
return /* @__PURE__ */ import_react89.default.createElement("div", { className: "str-chat__chat-view__selector" }, /* @__PURE__ */ import_react89.default.createElement(
|
|
39362
39364
|
"button",
|
|
@@ -39419,16 +39421,16 @@ var ThreadListItemUI = (props) => {
|
|
|
39419
39421
|
const { client } = useChatContext();
|
|
39420
39422
|
const thread = useThreadListItemContext();
|
|
39421
39423
|
const selector6 = (0, import_react90.useCallback)(
|
|
39422
|
-
(nextValue) =>
|
|
39423
|
-
nextValue.
|
|
39424
|
-
|
|
39425
|
-
nextValue.
|
|
39426
|
-
nextValue.
|
|
39427
|
-
nextValue.
|
|
39428
|
-
|
|
39424
|
+
(nextValue) => ({
|
|
39425
|
+
channel: nextValue.channel,
|
|
39426
|
+
deletedAt: nextValue.deletedAt,
|
|
39427
|
+
latestReply: nextValue.replies.at(-1),
|
|
39428
|
+
ownUnreadMessageCount: client.userID && nextValue.read[client.userID]?.unreadMessageCount || 0,
|
|
39429
|
+
parentMessage: nextValue.parentMessage
|
|
39430
|
+
}),
|
|
39429
39431
|
[client]
|
|
39430
39432
|
);
|
|
39431
|
-
const
|
|
39433
|
+
const { channel, deletedAt, latestReply, ownUnreadMessageCount, parentMessage } = useStateStore(
|
|
39432
39434
|
thread.state,
|
|
39433
39435
|
selector6
|
|
39434
39436
|
);
|
|
@@ -39467,10 +39469,12 @@ var ThreadListEmptyPlaceholder = () => /* @__PURE__ */ import_react92.default.cr
|
|
|
39467
39469
|
|
|
39468
39470
|
// src/components/Threads/ThreadList/ThreadListUnseenThreadsBanner.tsx
|
|
39469
39471
|
var import_react93 = __toESM(require("react"));
|
|
39470
|
-
var selector2 = (nextValue) =>
|
|
39472
|
+
var selector2 = (nextValue) => ({
|
|
39473
|
+
unseenThreadIds: nextValue.unseenThreadIds
|
|
39474
|
+
});
|
|
39471
39475
|
var ThreadListUnseenThreadsBanner = () => {
|
|
39472
39476
|
const { client } = useChatContext();
|
|
39473
|
-
const
|
|
39477
|
+
const { unseenThreadIds } = useStateStore(client.threads.state, selector2);
|
|
39474
39478
|
if (!unseenThreadIds.length) return null;
|
|
39475
39479
|
return /* @__PURE__ */ import_react93.default.createElement("div", { className: "str-chat__unseen-threads-banner" }, unseenThreadIds.length, " unread threads", /* @__PURE__ */ import_react93.default.createElement(
|
|
39476
39480
|
"button",
|
|
@@ -39484,17 +39488,19 @@ var ThreadListUnseenThreadsBanner = () => {
|
|
|
39484
39488
|
|
|
39485
39489
|
// src/components/Threads/ThreadList/ThreadListLoadingIndicator.tsx
|
|
39486
39490
|
var import_react94 = __toESM(require("react"));
|
|
39487
|
-
var selector3 = (nextValue) =>
|
|
39491
|
+
var selector3 = (nextValue) => ({
|
|
39492
|
+
isLoadingNext: nextValue.pagination.isLoadingNext
|
|
39493
|
+
});
|
|
39488
39494
|
var ThreadListLoadingIndicator = () => {
|
|
39489
39495
|
const { LoadingIndicator: LoadingIndicator2 = LoadingIndicator } = useComponentContext();
|
|
39490
39496
|
const { client } = useChatContext();
|
|
39491
|
-
const
|
|
39497
|
+
const { isLoadingNext } = useStateStore(client.threads.state, selector3);
|
|
39492
39498
|
if (!isLoadingNext) return null;
|
|
39493
39499
|
return /* @__PURE__ */ import_react94.default.createElement("div", { className: "str-chat__thread-list-loading-indicator" }, /* @__PURE__ */ import_react94.default.createElement(LoadingIndicator2, null));
|
|
39494
39500
|
};
|
|
39495
39501
|
|
|
39496
39502
|
// src/components/Threads/ThreadList/ThreadList.tsx
|
|
39497
|
-
var selector4 = (nextValue) =>
|
|
39503
|
+
var selector4 = (nextValue) => ({ threads: nextValue.threads });
|
|
39498
39504
|
var computeItemKey = (_, item2) => item2.id;
|
|
39499
39505
|
var useThreadList = () => {
|
|
39500
39506
|
const { client } = useChatContext();
|
|
@@ -39523,7 +39529,7 @@ var ThreadList = ({ virtuosoProps }) => {
|
|
|
39523
39529
|
ThreadListLoadingIndicator: ThreadListLoadingIndicator2 = ThreadListLoadingIndicator,
|
|
39524
39530
|
ThreadListUnseenThreadsBanner: ThreadListUnseenThreadsBanner2 = ThreadListUnseenThreadsBanner
|
|
39525
39531
|
} = useComponentContext();
|
|
39526
|
-
const
|
|
39532
|
+
const { threads } = useStateStore(client.threads.state, selector4);
|
|
39527
39533
|
useThreadList();
|
|
39528
39534
|
return /* @__PURE__ */ import_react95.default.createElement("div", { className: "str-chat__thread-list-container" }, /* @__PURE__ */ import_react95.default.createElement(ThreadListUnseenThreadsBanner2, null), /* @__PURE__ */ import_react95.default.createElement(
|
|
39529
39535
|
import_react_virtuoso.Virtuoso,
|
|
@@ -47789,12 +47795,12 @@ var Thread = (props) => {
|
|
|
47789
47795
|
/* @__PURE__ */ import_react222.default.createElement(ThreadInner, { ...props, key: `thread-${(thread ?? threadInstance)?.id}-${channel?.cid}` })
|
|
47790
47796
|
);
|
|
47791
47797
|
};
|
|
47792
|
-
var selector5 = (nextValue) =>
|
|
47793
|
-
nextValue.
|
|
47794
|
-
nextValue.pagination.isLoadingPrev,
|
|
47795
|
-
nextValue.
|
|
47796
|
-
nextValue.
|
|
47797
|
-
|
|
47798
|
+
var selector5 = (nextValue) => ({
|
|
47799
|
+
isLoadingNext: nextValue.pagination.isLoadingNext,
|
|
47800
|
+
isLoadingPrev: nextValue.pagination.isLoadingPrev,
|
|
47801
|
+
parentMessage: nextValue.parentMessage,
|
|
47802
|
+
replies: nextValue.replies
|
|
47803
|
+
});
|
|
47798
47804
|
var ThreadInner = (props) => {
|
|
47799
47805
|
const {
|
|
47800
47806
|
additionalMessageInputProps,
|
|
@@ -47809,7 +47815,7 @@ var ThreadInner = (props) => {
|
|
|
47809
47815
|
virtualized
|
|
47810
47816
|
} = props;
|
|
47811
47817
|
const threadInstance = useThreadContext();
|
|
47812
|
-
const
|
|
47818
|
+
const { isLoadingNext, isLoadingPrev, parentMessage, replies } = useStateStore(threadInstance?.state, selector5) ?? {};
|
|
47813
47819
|
const {
|
|
47814
47820
|
thread,
|
|
47815
47821
|
threadHasMore,
|
|
@@ -47841,7 +47847,7 @@ var ThreadInner = (props) => {
|
|
|
47841
47847
|
loadingMoreNewer: isLoadingNext,
|
|
47842
47848
|
loadMore: threadInstance.loadPrevPage,
|
|
47843
47849
|
loadMoreNewer: threadInstance.loadNextPage,
|
|
47844
|
-
messages:
|
|
47850
|
+
messages: replies
|
|
47845
47851
|
} : {
|
|
47846
47852
|
hasMore: threadHasMore,
|
|
47847
47853
|
loadingMore: threadLoadingMore,
|