stream-chat-react 12.15.7 → 12.16.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/AutoCompleteTextarea/Textarea.d.ts +23 -24
- package/dist/components/Channel/Channel.js +2 -6
- package/dist/components/ChannelList/ChannelList.js +2 -3
- package/dist/components/ChannelList/hooks/usePaginatedChannels.js +1 -5
- package/dist/components/ChannelList/utils.d.ts +1 -2
- package/dist/components/ChannelList/utils.js +0 -1
- package/dist/components/ChannelPreview/ChannelPreview.js +13 -2
- package/dist/components/Chat/hooks/useChat.js +1 -1
- package/dist/components/Gallery/ModalGallery.js +1 -3
- package/dist/components/Message/renderText/renderText.d.ts +2 -2
- package/dist/constants/limits.d.ts +3 -4
- package/dist/constants/limits.js +3 -4
- package/dist/experimental/index.browser.cjs +17 -5
- package/dist/experimental/index.browser.cjs.map +2 -2
- package/dist/experimental/index.node.cjs +17 -5
- package/dist/experimental/index.node.cjs.map +2 -2
- package/dist/index.browser.cjs +122 -125
- package/dist/index.browser.cjs.map +4 -4
- package/dist/index.node.cjs +122 -126
- package/dist/index.node.cjs.map +4 -4
- package/package.json +4 -5
|
@@ -83,32 +83,31 @@ export class ReactTextareaAutocomplete extends React.Component<any, any, any> {
|
|
|
83
83
|
}
|
|
84
84
|
export namespace ReactTextareaAutocomplete {
|
|
85
85
|
namespace propTypes {
|
|
86
|
-
export let className:
|
|
87
|
-
export let closeOnClickOutside:
|
|
88
|
-
export let containerClassName:
|
|
89
|
-
export let containerStyle:
|
|
90
|
-
export let disableMentions:
|
|
91
|
-
export let dropdownClassName:
|
|
92
|
-
export let dropdownStyle:
|
|
93
|
-
export let itemClassName:
|
|
94
|
-
export let itemStyle:
|
|
95
|
-
export let listClassName:
|
|
96
|
-
export let listStyle:
|
|
97
|
-
export let loaderClassName:
|
|
98
|
-
export let loaderStyle:
|
|
99
|
-
export let loadingComponent:
|
|
100
|
-
export let minChar:
|
|
101
|
-
export let onBlur:
|
|
102
|
-
export let onCaretPositionChange:
|
|
103
|
-
export let onChange:
|
|
104
|
-
export let onSelect:
|
|
105
|
-
export let shouldSubmit:
|
|
106
|
-
export let style:
|
|
107
|
-
export let SuggestionList:
|
|
86
|
+
export let className: any;
|
|
87
|
+
export let closeOnClickOutside: any;
|
|
88
|
+
export let containerClassName: any;
|
|
89
|
+
export let containerStyle: any;
|
|
90
|
+
export let disableMentions: any;
|
|
91
|
+
export let dropdownClassName: any;
|
|
92
|
+
export let dropdownStyle: any;
|
|
93
|
+
export let itemClassName: any;
|
|
94
|
+
export let itemStyle: any;
|
|
95
|
+
export let listClassName: any;
|
|
96
|
+
export let listStyle: any;
|
|
97
|
+
export let loaderClassName: any;
|
|
98
|
+
export let loaderStyle: any;
|
|
99
|
+
export let loadingComponent: any;
|
|
100
|
+
export let minChar: any;
|
|
101
|
+
export let onBlur: any;
|
|
102
|
+
export let onCaretPositionChange: any;
|
|
103
|
+
export let onChange: any;
|
|
104
|
+
export let onSelect: any;
|
|
105
|
+
export let shouldSubmit: any;
|
|
106
|
+
export let style: any;
|
|
107
|
+
export let SuggestionList: any;
|
|
108
108
|
export { triggerPropsCheck as trigger };
|
|
109
|
-
export let value:
|
|
109
|
+
export let value: any;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
import React from 'react';
|
|
113
|
-
import PropTypes from 'prop-types';
|
|
114
113
|
import { triggerPropsCheck } from './utils';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, } from 'react';
|
|
2
2
|
import debounce from 'lodash.debounce';
|
|
3
|
-
import defaultsDeep from 'lodash.defaultsdeep';
|
|
4
3
|
import throttle from 'lodash.throttle';
|
|
5
4
|
import { nanoid } from 'nanoid';
|
|
6
5
|
import clsx from 'clsx';
|
|
@@ -15,7 +14,7 @@ import { LoadingChannel as DefaultLoadingIndicator } from './LoadingChannel';
|
|
|
15
14
|
import { DropzoneProvider } from '../MessageInput/DropzoneProvider';
|
|
16
15
|
import { ChannelActionProvider, ChannelStateProvider, TypingProvider, useChatContext, useTranslationContext, WithComponents, } from '../../context';
|
|
17
16
|
import { CHANNEL_CONTAINER_ID } from './constants';
|
|
18
|
-
import { DEFAULT_HIGHLIGHT_DURATION,
|
|
17
|
+
import { DEFAULT_HIGHLIGHT_DURATION, DEFAULT_JUMP_TO_PAGE_SIZE, DEFAULT_NEXT_CHANNEL_PAGE_SIZE, DEFAULT_THREAD_PAGE_SIZE, } from '../../constants/limits';
|
|
19
18
|
import { hasMoreMessagesProbably } from '../MessageList';
|
|
20
19
|
import { getChatContainerClass, useChannelContainerClasses, useImageFlagEmojisOnWindowsClass, } from './hooks/useChannelContainerClasses';
|
|
21
20
|
import { findInMsgSetByDate, findInMsgSetById, makeAddNotifications } from './utils';
|
|
@@ -50,10 +49,7 @@ const UnMemoizedChannel = (props) => {
|
|
|
50
49
|
return React.createElement(ChannelInner, { ...props, channel: channel, key: channel.cid });
|
|
51
50
|
};
|
|
52
51
|
const ChannelInner = (props) => {
|
|
53
|
-
const { acceptedFiles, activeUnreadHandler, channel, channelQueryOptions
|
|
54
|
-
const channelQueryOptions = useMemo(() => defaultsDeep(propChannelQueryOptions, {
|
|
55
|
-
messages: { limit: DEFAULT_INITIAL_CHANNEL_PAGE_SIZE },
|
|
56
|
-
}), [propChannelQueryOptions]);
|
|
52
|
+
const { acceptedFiles, activeUnreadHandler, channel, channelQueryOptions, children, doDeleteMessageRequest, doMarkReadRequest, doSendMessageRequest, doUpdateMessageRequest, dragAndDropWindow = false, enrichURLForPreviewConfig, initializeOnMount = true, LoadingErrorIndicator = DefaultLoadingErrorIndicator, LoadingIndicator = DefaultLoadingIndicator, markReadOnMount = true, maxNumberOfFiles, multipleUploads = true, onMentionsClick, onMentionsHover, optionalMessageInputProps = {}, skipMessageDataMemoization, } = props;
|
|
57
53
|
const { client, customClasses, latestMessageDatesByChannels, mutes, searchController } = useChatContext('Channel');
|
|
58
54
|
const { t } = useTranslationContext('Channel');
|
|
59
55
|
const chatContainerClass = getChatContainerClass(customClasses?.chatContainer);
|
|
@@ -5,7 +5,7 @@ import { useConnectionRecoveredListener } from './hooks/useConnectionRecoveredLi
|
|
|
5
5
|
import { useMobileNavigation } from './hooks/useMobileNavigation';
|
|
6
6
|
import { usePaginatedChannels, } from './hooks/usePaginatedChannels';
|
|
7
7
|
import { useChannelListShape, usePrepareShapeHandlers, } from './hooks/useChannelListShape';
|
|
8
|
-
import {
|
|
8
|
+
import { moveChannelUpwards } from './utils';
|
|
9
9
|
import { Avatar as DefaultAvatar } from '../Avatar';
|
|
10
10
|
import { ChannelPreview, } from '../ChannelPreview/ChannelPreview';
|
|
11
11
|
import { ChannelSearch as DefaultChannelSearch, } from '../ChannelSearch/ChannelSearch';
|
|
@@ -36,8 +36,7 @@ const UnMemoizedChannelList = (props) => {
|
|
|
36
36
|
* If customActiveChannel prop is absent, then set the first channel in list as active channel.
|
|
37
37
|
*/
|
|
38
38
|
const activeChannelHandler = async (channels, setChannels) => {
|
|
39
|
-
if (!channels.length
|
|
40
|
-
channels.length > (options?.limit || MAX_QUERY_CHANNELS_LIMIT)) {
|
|
39
|
+
if (!channels.length) {
|
|
41
40
|
return;
|
|
42
41
|
}
|
|
43
42
|
if (customActiveChannel) {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import uniqBy from 'lodash.uniqby';
|
|
3
|
-
import { MAX_QUERY_CHANNELS_LIMIT } from '../utils';
|
|
4
3
|
import { useChatContext } from '../../../context/ChatContext';
|
|
5
|
-
import { DEFAULT_INITIAL_CHANNEL_PAGE_SIZE } from '../../../constants/limits';
|
|
6
4
|
const RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS = 5000;
|
|
7
5
|
const MIN_RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS = 2000;
|
|
8
6
|
export const usePaginatedChannels = (client, filters, sort, options, activeChannelHandler, recoveryThrottleIntervalMs = RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS, customQueryChannels) => {
|
|
@@ -35,8 +33,6 @@ export const usePaginatedChannels = (client, filters, sort, options, activeChann
|
|
|
35
33
|
else {
|
|
36
34
|
const offset = queryType === 'reload' ? 0 : channels.length;
|
|
37
35
|
const newOptions = {
|
|
38
|
-
limit: options?.limit ?? MAX_QUERY_CHANNELS_LIMIT,
|
|
39
|
-
message_limit: options?.message_limit ?? DEFAULT_INITIAL_CHANNEL_PAGE_SIZE,
|
|
40
36
|
offset,
|
|
41
37
|
...options,
|
|
42
38
|
};
|
|
@@ -45,7 +41,7 @@ export const usePaginatedChannels = (client, filters, sort, options, activeChann
|
|
|
45
41
|
? channelQueryResponse
|
|
46
42
|
: uniqBy([...channels, ...channelQueryResponse], 'cid');
|
|
47
43
|
setChannels(newChannels);
|
|
48
|
-
setHasNextPage(channelQueryResponse.length >= newOptions.limit);
|
|
44
|
+
setHasNextPage(channelQueryResponse.length >= (newOptions.limit ?? 1));
|
|
49
45
|
// Set active channel only on load of first page
|
|
50
46
|
if (!offset && activeChannelHandler) {
|
|
51
47
|
activeChannelHandler(newChannels, setChannels);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Channel, ChannelSort, ChannelSortBase, ExtendableGenerics } from 'stream-chat';
|
|
2
2
|
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
3
3
|
import type { ChannelListProps } from './ChannelList';
|
|
4
|
-
export declare const MAX_QUERY_CHANNELS_LIMIT = 30;
|
|
5
4
|
type MoveChannelUpParams<SCG extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
|
|
6
5
|
channels: Array<Channel<SCG>>;
|
|
7
6
|
cid: string;
|
|
@@ -40,7 +39,7 @@ export declare const extractSortValue: <SCG extends ExtendableGenerics>({ atInde
|
|
|
40
39
|
atIndex: number;
|
|
41
40
|
targetKey: keyof ChannelSortBase<SCG>;
|
|
42
41
|
sort?: ChannelListProps<SCG>['sort'];
|
|
43
|
-
}) => NonNullable<ChannelSortBase<SCG>["created_at" | "pinned_at" | "updated_at" |
|
|
42
|
+
}) => NonNullable<ChannelSortBase<SCG>["created_at" | "pinned_at" | "updated_at" | "last_message_at" | "member_count" | keyof SCG["channelType"] | "has_unread" | "last_updated" | "unread_count"]> | null;
|
|
44
43
|
/**
|
|
45
44
|
* Returns `true` only if `archived` property is of type `boolean` within `filters` object.
|
|
46
45
|
*/
|
|
@@ -15,6 +15,7 @@ export const ChannelPreview = (props) => {
|
|
|
15
15
|
channel,
|
|
16
16
|
});
|
|
17
17
|
const [lastMessage, setLastMessage] = useState(channel.state.messages[channel.state.messages.length - 1]);
|
|
18
|
+
const [latestMessagePreview, setLatestMessagePreview] = useState(() => getLatestMessagePreview(channel, t, userLanguage, isMessageAIGenerated));
|
|
18
19
|
const [unread, setUnread] = useState(0);
|
|
19
20
|
const { messageDeliveryStatus } = useMessageDeliveryStatus({
|
|
20
21
|
channel,
|
|
@@ -55,8 +56,10 @@ export const ChannelPreview = (props) => {
|
|
|
55
56
|
}, 400), [channel, muted]);
|
|
56
57
|
useEffect(() => {
|
|
57
58
|
refreshUnreadCount();
|
|
59
|
+
setLatestMessagePreview(getLatestMessagePreview(channel, t, userLanguage, isMessageAIGenerated));
|
|
58
60
|
const handleEvent = () => {
|
|
59
61
|
setLastMessage(channel.state.latestMessages[channel.state.latestMessages.length - 1]);
|
|
62
|
+
setLatestMessagePreview(getLatestMessagePreview(channel, t, userLanguage, isMessageAIGenerated));
|
|
60
63
|
refreshUnreadCount();
|
|
61
64
|
};
|
|
62
65
|
channel.on('message.new', handleEvent);
|
|
@@ -71,9 +74,17 @@ export const ChannelPreview = (props) => {
|
|
|
71
74
|
channel.off('message.undeleted', handleEvent);
|
|
72
75
|
channel.off('channel.truncated', handleEvent);
|
|
73
76
|
};
|
|
74
|
-
}, [
|
|
77
|
+
}, [
|
|
78
|
+
channel,
|
|
79
|
+
client,
|
|
80
|
+
refreshUnreadCount,
|
|
81
|
+
channelUpdateCount,
|
|
82
|
+
getLatestMessagePreview,
|
|
83
|
+
t,
|
|
84
|
+
userLanguage,
|
|
85
|
+
isMessageAIGenerated,
|
|
86
|
+
]);
|
|
75
87
|
if (!Preview)
|
|
76
88
|
return null;
|
|
77
|
-
const latestMessagePreview = getLatestMessagePreview(channel, t, userLanguage, isMessageAIGenerated);
|
|
78
89
|
return (React.createElement(Preview, { ...props, active: isActive, displayImage: displayImage, displayTitle: displayTitle, groupChannelDisplayInfo: groupChannelDisplayInfo, lastMessage: lastMessage, latestMessage: latestMessagePreview, latestMessagePreview: latestMessagePreview, messageDeliveryStatus: messageDeliveryStatus, setActiveChannel: setActiveChannel, unread: unread }));
|
|
79
90
|
};
|
|
@@ -24,7 +24,7 @@ export const useChat = ({ client, defaultLanguage = 'en', i18nInstance, initialN
|
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
if (!client)
|
|
26
26
|
return;
|
|
27
|
-
const version = "12.
|
|
27
|
+
const version = "12.16.0";
|
|
28
28
|
const userAgent = client.getUserAgent();
|
|
29
29
|
if (!userAgent.includes('stream-chat-react')) {
|
|
30
30
|
// result looks like: 'stream-chat-react-2.3.2-stream-chat-javascript-client-browser-2.2.2'
|
|
@@ -19,7 +19,5 @@ export const ModalGallery = (props) => {
|
|
|
19
19
|
source: imageSrc,
|
|
20
20
|
};
|
|
21
21
|
}), [images, t]);
|
|
22
|
-
return (
|
|
23
|
-
// @ts-expect-error ignore the TS error as react-image-gallery was on @types/react@18 while stream-chat-react being upgraded to React 19 (https://github.com/xiaolin/react-image-gallery/issues/809)
|
|
24
|
-
React.createElement(ImageGallery, { items: formattedArray, renderItem: renderItem, showIndex: true, showPlayButton: false, showThumbnails: false, startIndex: index }));
|
|
22
|
+
return (React.createElement(ImageGallery, { items: formattedArray, renderItem: renderItem, showIndex: true, showPlayButton: false, showThumbnails: false, startIndex: index }));
|
|
25
23
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentType, JSX } from 'react';
|
|
2
2
|
import { MentionProps } from './componentRenderers';
|
|
3
3
|
import type { Options } from 'react-markdown/lib';
|
|
4
4
|
import type { UserResponse } from 'stream-chat';
|
|
@@ -16,4 +16,4 @@ export type RenderTextOptions<StreamChatGenerics extends DefaultStreamChatGeneri
|
|
|
16
16
|
getRehypePlugins?: RenderTextPluginConfigurator;
|
|
17
17
|
getRemarkPlugins?: RenderTextPluginConfigurator;
|
|
18
18
|
};
|
|
19
|
-
export declare const renderText: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(text?: string, mentionedUsers?: UserResponse<StreamChatGenerics>[], { allowedTagNames, customMarkDownRenderers, getRehypePlugins, getRemarkPlugins, }?: RenderTextOptions) =>
|
|
19
|
+
export declare const renderText: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(text?: string, mentionedUsers?: UserResponse<StreamChatGenerics>[], { allowedTagNames, customMarkDownRenderers, getRehypePlugins, getRemarkPlugins, }?: RenderTextOptions) => JSX.Element | null;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const DEFAULT_THREAD_PAGE_SIZE = 50;
|
|
1
|
+
export declare const DEFAULT_NEXT_CHANNEL_PAGE_SIZE = 25;
|
|
2
|
+
export declare const DEFAULT_JUMP_TO_PAGE_SIZE = 25;
|
|
3
|
+
export declare const DEFAULT_THREAD_PAGE_SIZE = 25;
|
|
5
4
|
export declare const DEFAULT_LOAD_PAGE_SCROLL_THRESHOLD = 250;
|
|
6
5
|
export declare const DEFAULT_UPLOAD_SIZE_LIMIT_BYTES: number;
|
|
7
6
|
export declare const DEFAULT_HIGHLIGHT_DURATION = 500;
|
package/dist/constants/limits.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export const
|
|
2
|
-
export const
|
|
3
|
-
export const
|
|
4
|
-
export const DEFAULT_THREAD_PAGE_SIZE = 50;
|
|
1
|
+
export const DEFAULT_NEXT_CHANNEL_PAGE_SIZE = 25;
|
|
2
|
+
export const DEFAULT_JUMP_TO_PAGE_SIZE = 25;
|
|
3
|
+
export const DEFAULT_THREAD_PAGE_SIZE = 25;
|
|
5
4
|
export const DEFAULT_LOAD_PAGE_SCROLL_THRESHOLD = 250;
|
|
6
5
|
export const DEFAULT_UPLOAD_SIZE_LIMIT_BYTES = 100 * 1024 * 1024; // 100 MB
|
|
7
6
|
export const DEFAULT_HIGHLIGHT_DURATION = 500;
|
|
@@ -513,7 +513,7 @@ var useMessageContext = (_componentName) => {
|
|
|
513
513
|
};
|
|
514
514
|
|
|
515
515
|
// src/constants/limits.ts
|
|
516
|
-
var DEFAULT_JUMP_TO_PAGE_SIZE =
|
|
516
|
+
var DEFAULT_JUMP_TO_PAGE_SIZE = 25;
|
|
517
517
|
var DEFAULT_LOAD_PAGE_SCROLL_THRESHOLD = 250;
|
|
518
518
|
var DEFAULT_UPLOAD_SIZE_LIMIT_BYTES = 100 * 1024 * 1024;
|
|
519
519
|
|
|
@@ -10733,6 +10733,9 @@ var ChannelPreview = (props) => {
|
|
|
10733
10733
|
const [lastMessage, setLastMessage] = (0, import_react23.useState)(
|
|
10734
10734
|
channel.state.messages[channel.state.messages.length - 1]
|
|
10735
10735
|
);
|
|
10736
|
+
const [latestMessagePreview, setLatestMessagePreview] = (0, import_react23.useState)(
|
|
10737
|
+
() => getLatestMessagePreview2(channel, t, userLanguage, isMessageAIGenerated)
|
|
10738
|
+
);
|
|
10736
10739
|
const [unread, setUnread] = (0, import_react23.useState)(0);
|
|
10737
10740
|
const { messageDeliveryStatus } = useMessageDeliveryStatus({
|
|
10738
10741
|
channel,
|
|
@@ -10771,10 +10774,16 @@ var ChannelPreview = (props) => {
|
|
|
10771
10774
|
);
|
|
10772
10775
|
(0, import_react23.useEffect)(() => {
|
|
10773
10776
|
refreshUnreadCount();
|
|
10777
|
+
setLatestMessagePreview(
|
|
10778
|
+
getLatestMessagePreview2(channel, t, userLanguage, isMessageAIGenerated)
|
|
10779
|
+
);
|
|
10774
10780
|
const handleEvent = () => {
|
|
10775
10781
|
setLastMessage(
|
|
10776
10782
|
channel.state.latestMessages[channel.state.latestMessages.length - 1]
|
|
10777
10783
|
);
|
|
10784
|
+
setLatestMessagePreview(
|
|
10785
|
+
getLatestMessagePreview2(channel, t, userLanguage, isMessageAIGenerated)
|
|
10786
|
+
);
|
|
10778
10787
|
refreshUnreadCount();
|
|
10779
10788
|
};
|
|
10780
10789
|
channel.on("message.new", handleEvent);
|
|
@@ -10789,14 +10798,17 @@ var ChannelPreview = (props) => {
|
|
|
10789
10798
|
channel.off("message.undeleted", handleEvent);
|
|
10790
10799
|
channel.off("channel.truncated", handleEvent);
|
|
10791
10800
|
};
|
|
10792
|
-
}, [
|
|
10793
|
-
if (!Preview) return null;
|
|
10794
|
-
const latestMessagePreview = getLatestMessagePreview2(
|
|
10801
|
+
}, [
|
|
10795
10802
|
channel,
|
|
10803
|
+
client,
|
|
10804
|
+
refreshUnreadCount,
|
|
10805
|
+
channelUpdateCount,
|
|
10806
|
+
getLatestMessagePreview2,
|
|
10796
10807
|
t,
|
|
10797
10808
|
userLanguage,
|
|
10798
10809
|
isMessageAIGenerated
|
|
10799
|
-
);
|
|
10810
|
+
]);
|
|
10811
|
+
if (!Preview) return null;
|
|
10800
10812
|
return /* @__PURE__ */ import_react23.default.createElement(
|
|
10801
10813
|
Preview,
|
|
10802
10814
|
{
|