stream-chat-react-native-core 5.11.3-beta.3 → 5.11.3-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/lib/commonjs/components/Chat/Chat.js +8 -8
- package/lib/commonjs/components/Chat/Chat.js.map +1 -1
- package/lib/commonjs/components/Chat/hooks/useAppSettings.js +15 -21
- package/lib/commonjs/components/Chat/hooks/useAppSettings.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +57 -51
- package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Chat/Chat.js +8 -8
- package/lib/module/components/Chat/Chat.js.map +1 -1
- package/lib/module/components/Chat/hooks/useAppSettings.js +15 -21
- package/lib/module/components/Chat/hooks/useAppSettings.js.map +1 -1
- package/lib/module/components/MessageList/MessageList.js +57 -51
- package/lib/module/components/MessageList/MessageList.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Chat/hooks/useAppSettings.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Chat/Chat.tsx +6 -6
- package/src/components/Chat/hooks/useAppSettings.ts +3 -4
- package/src/components/MessageList/MessageList.tsx +28 -27
- package/src/version.json +1 -1
|
@@ -65,10 +65,10 @@ var ChatWithContext = function ChatWithContext(props) {
|
|
|
65
65
|
var _useIsOnline = (0, _useIsOnline2.useIsOnline)(client, closeConnectionOnBackground),
|
|
66
66
|
connectionRecovering = _useIsOnline.connectionRecovering,
|
|
67
67
|
isOnline = _useIsOnline.isOnline;
|
|
68
|
-
var _useState5 = (0, _react.useState)(
|
|
68
|
+
var _useState5 = (0, _react.useState)(false),
|
|
69
69
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
initialisedDatabase = _useState6[0],
|
|
71
|
+
setInitialisedDatabase = _useState6[1];
|
|
72
72
|
var mutedUsers = (0, _useMutedUsers.useMutedUsers)(client);
|
|
73
73
|
var debugRef = (0, _DebugContext.useDebugContext)();
|
|
74
74
|
var isDebugModeEnabled = __DEV__ && debugRef && debugRef.current;
|
|
@@ -85,20 +85,20 @@ var ChatWithContext = function ChatWithContext(props) {
|
|
|
85
85
|
data: client.user
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
}, [client]);
|
|
88
|
+
}, [client, enableOfflineSupport]);
|
|
89
89
|
var setActiveChannel = function setActiveChannel(newChannel) {
|
|
90
90
|
return setChannel(newChannel);
|
|
91
91
|
};
|
|
92
92
|
(0, _react.useEffect)(function () {
|
|
93
93
|
var _client$user;
|
|
94
94
|
if ((_client$user = client.user) != null && _client$user.id && enableOfflineSupport) {
|
|
95
|
-
|
|
95
|
+
setInitialisedDatabase(false);
|
|
96
96
|
_QuickSqliteClient.QuickSqliteClient.initializeDatabase();
|
|
97
97
|
_DBSyncManager.DBSyncManager.init(client);
|
|
98
|
-
|
|
98
|
+
setInitialisedDatabase(true);
|
|
99
99
|
}
|
|
100
100
|
}, [client == null ? void 0 : (_client$user2 = client.user) == null ? void 0 : _client$user2.id, enableOfflineSupport]);
|
|
101
|
-
var appSettings = (0, _useAppSettings.useAppSettings)(client, isOnline, enableOfflineSupport,
|
|
101
|
+
var appSettings = (0, _useAppSettings.useAppSettings)(client, isOnline, enableOfflineSupport, initialisedDatabase);
|
|
102
102
|
var chatContext = (0, _useCreateChatContext.useCreateChatContext)({
|
|
103
103
|
appSettings: appSettings,
|
|
104
104
|
channel: channel,
|
|
@@ -114,7 +114,7 @@ var ChatWithContext = function ChatWithContext(props) {
|
|
|
114
114
|
client: client,
|
|
115
115
|
enableOfflineSupport: enableOfflineSupport
|
|
116
116
|
});
|
|
117
|
-
if (loadingTranslators
|
|
117
|
+
if (loadingTranslators) return null;
|
|
118
118
|
return _react["default"].createElement(_ChatContext.ChatProvider, {
|
|
119
119
|
value: chatContext,
|
|
120
120
|
__self: _this,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_dayjs","_interopRequireDefault","_useAppSettings","_useCreateChatContext","_useIsOnline2","_useMutedUsers","_useSyncDatabase","_ChannelsStateContext","_ChatContext","_DebugContext","_OverlayContext","_ThemeContext","_TranslationContext","_useStreami18n","_init","_native","_QuickSqliteClient","_DBSyncManager","_version","_this","_jsxFileName","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","init","ChatWithContext","props","_client$user2","_client$user3","children","client","_props$closeConnectio","closeConnectionOnBackground","_props$enableOfflineS","enableOfflineSupport","i18nInstance","_props$ImageComponent","ImageComponent","Image","style","_useState","useState","_useState2","_slicedToArray2","channel","setChannel","_useState3","t","tDateTimeParser","input","Dayjs","_useState4","translators","setTranslators","loadingTranslators","useStreami18n","_useIsOnline","useIsOnline","connectionRecovering","isOnline","_useState5","_useState6","initialisingDatabase","setInitialisingDatabase","mutedUsers","useMutedUsers","debugRef","useDebugContext","isDebugModeEnabled","__DEV__","current","useEffect","setUserAgent","SDK","Platform","OS","version","recoverStateOnReconnect","persistUserOnConnectionFailure","setEventType","setSendEventParams","action","data","user","setActiveChannel","newChannel","_client$user","id","QuickSqliteClient","initializeDatabase","DBSyncManager","appSettings","useAppSettings","chatContext","useCreateChatContext","useSyncDatabase","createElement","ChatProvider","value","__self","__source","fileName","lineNumber","columnNumber","TranslationProvider","_extends2","userLanguage","language","DEFAULT_USER_LANGUAGE","ThemeProvider","ChannelsStateProvider","Chat","_useOverlayContext","useOverlayContext","exports"],"sources":["Chat.tsx"],"sourcesContent":["import React, { PropsWithChildren, useEffect, useState } from 'react';\nimport { Image, Platform } from 'react-native';\n\nimport Dayjs from 'dayjs';\n\nimport type { Channel, StreamChat } from 'stream-chat';\n\nimport { useAppSettings } from './hooks/useAppSettings';\nimport { useCreateChatContext } from './hooks/useCreateChatContext';\nimport { useIsOnline } from './hooks/useIsOnline';\nimport { useMutedUsers } from './hooks/useMutedUsers';\n\nimport { useSyncDatabase } from './hooks/useSyncDatabase';\n\nimport { ChannelsStateProvider } from '../../contexts/channelsStateContext/ChannelsStateContext';\nimport { ChatContextValue, ChatProvider } from '../../contexts/chatContext/ChatContext';\nimport { useDebugContext } from '../../contexts/debugContext/DebugContext';\nimport { useOverlayContext } from '../../contexts/overlayContext/OverlayContext';\nimport { DeepPartial, ThemeProvider } from '../../contexts/themeContext/ThemeContext';\nimport type { Theme } from '../../contexts/themeContext/utils/theme';\nimport {\n DEFAULT_USER_LANGUAGE,\n TranslationProvider,\n TranslatorFunctions,\n} from '../../contexts/translationContext/TranslationContext';\nimport { useStreami18n } from '../../hooks/useStreami18n';\nimport init from '../../init';\n\nimport { SDK } from '../../native';\nimport { QuickSqliteClient } from '../../store/QuickSqliteClient';\nimport type { DefaultStreamChatGenerics } from '../../types/types';\nimport { DBSyncManager } from '../../utils/DBSyncManager';\nimport type { Streami18n } from '../../utils/Streami18n';\nimport { version } from '../../version.json';\n\ninit();\n\nexport type ChatProps<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Pick<ChatContextValue<StreamChatGenerics>, 'client'> &\n Partial<Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'>> & {\n /**\n * When false, ws connection won't be disconnection upon backgrounding the app.\n * To receive push notifications, its necessary that user doesn't have active\n * websocket connection. So by default, we disconnect websocket connection when\n * app goes to background, and reconnect when app comes to foreground.\n */\n closeConnectionOnBackground?: boolean;\n /**\n * Enables offline storage and loading for chat data.\n */\n enableOfflineSupport?: boolean;\n /**\n * Instance of Streami18n class should be provided to Chat component to enable internationalization.\n *\n * Stream provides following list of in-built translations:\n * 1. English (en)\n * 2. Dutch (nl)\n * 3. ...\n * 4. ...\n *\n * Simplest way to start using chat components in one of the in-built languages would be following:\n *\n * ```\n * const i18n = new Streami18n('nl');\n * <Chat client={chatClient} i18nInstance={i18n}>\n * ...\n * </Chat>\n * ```\n *\n * If you would like to override certain keys in in-built translation.\n * UI will be automatically updated in this case.\n *\n * ```\n * const i18n = new Streami18n('nl');\n *\n * i18n.registerTranslation('nl', {\n * 'Nothing yet...': 'Nog Niet ...',\n * '{{ firstUser }} and {{ secondUser }} are typing...': '{{ firstUser }} en {{ secondUser }} zijn aan het typen...',\n * });\n *\n * <Chat client={chatClient} i18nInstance={i18n}>\n * ...\n * </Chat>\n * ```\n *\n * You can use the same function to add whole new language.\n *\n * ```\n * const i18n = new Streami18n('it');\n *\n * i18n.registerTranslation('it', {\n * 'Nothing yet...': 'Non ancora ...',\n * '{{ firstUser }} and {{ secondUser }} are typing...': '{{ firstUser }} a {{ secondUser }} stanno scrivendo...',\n * });\n *\n * // Make sure to call setLanguage to reflect new language in UI.\n * i18n.setLanguage('it');\n * <Chat client={chatClient} i18nInstance={i18n}>\n * ...\n * </Chat>\n * ```\n */\n i18nInstance?: Streami18n;\n /**\n * You can pass the theme object to customize the styles of Chat components. You can check the default theme in [theme.ts](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/contexts/themeContext/utils/theme.ts)\n *\n * Please check section about [themes in cookbook](https://github.com/GetStream/stream-chat-react-native/wiki/Cookbook-v3.0#theme) for details.\n *\n * ```\n * import type { DeepPartial, Theme } from 'stream-chat-react-native';\n *\n * const theme: DeepPartial<Theme> = {\n * messageSimple: {\n * file: {\n * container: {\n * backgroundColor: 'red',\n * },\n * icon: {\n * height: 16,\n * width: 16,\n * },\n * },\n * },\n * };\n *\n * <Chat style={theme}>\n * </Chat>\n * ```\n *\n * @overrideType object\n */\n style?: DeepPartial<Theme>;\n };\n\nconst ChatWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: PropsWithChildren<ChatProps<StreamChatGenerics>>,\n) => {\n const {\n children,\n client,\n closeConnectionOnBackground = true,\n enableOfflineSupport = false,\n i18nInstance,\n ImageComponent = Image,\n style,\n } = props;\n\n const [channel, setChannel] = useState<Channel<StreamChatGenerics>>();\n const [translators, setTranslators] = useState<TranslatorFunctions>({\n t: (key: string) => key,\n tDateTimeParser: (input?: string | number | Date) => Dayjs(input),\n });\n\n /**\n * Setup translators\n */\n const loadingTranslators = useStreami18n({ i18nInstance, setTranslators });\n\n /**\n * Setup connection event listeners\n */\n const { connectionRecovering, isOnline } = useIsOnline<StreamChatGenerics>(\n client,\n closeConnectionOnBackground,\n );\n\n const [initialisingDatabase, setInitialisingDatabase] = useState(enableOfflineSupport);\n\n /**\n * Setup muted user listener\n * TODO: reimplement\n */\n const mutedUsers = useMutedUsers<StreamChatGenerics>(client);\n\n const debugRef = useDebugContext();\n const isDebugModeEnabled = __DEV__ && debugRef && debugRef.current;\n\n useEffect(() => {\n if (client) {\n client.setUserAgent(`${SDK}-${Platform.OS}-${version}`);\n // This is to disable recovery related logic in js client, since we handle it in this SDK\n client.recoverStateOnReconnect = false;\n client.persistUserOnConnectionFailure = enableOfflineSupport;\n }\n\n if (isDebugModeEnabled) {\n if (debugRef.current.setEventType) debugRef.current.setEventType('send');\n if (debugRef.current.setSendEventParams)\n debugRef.current.setSendEventParams({\n action: 'Client',\n data: client.user,\n });\n }\n }, [client]);\n\n const setActiveChannel = (newChannel?: Channel<StreamChatGenerics>) => setChannel(newChannel);\n\n useEffect(() => {\n if (client.user?.id && enableOfflineSupport) {\n setInitialisingDatabase(true);\n QuickSqliteClient.initializeDatabase();\n DBSyncManager.init(client as unknown as StreamChat);\n setInitialisingDatabase(false);\n }\n }, [client?.user?.id, enableOfflineSupport]);\n\n const appSettings = useAppSettings(client, isOnline, enableOfflineSupport, initialisingDatabase);\n\n const chatContext = useCreateChatContext({\n appSettings,\n channel,\n client,\n connectionRecovering,\n enableOfflineSupport,\n ImageComponent,\n isOnline,\n mutedUsers,\n setActiveChannel,\n });\n\n useSyncDatabase({\n client,\n enableOfflineSupport,\n });\n\n if (loadingTranslators || initialisingDatabase) return null;\n\n return (\n <ChatProvider<StreamChatGenerics> value={chatContext}>\n <TranslationProvider\n value={{ ...translators, userLanguage: client.user?.language || DEFAULT_USER_LANGUAGE }}\n >\n <ThemeProvider style={style}>\n <ChannelsStateProvider<StreamChatGenerics>>{children}</ChannelsStateProvider>\n </ThemeProvider>\n </TranslationProvider>\n </ChatProvider>\n );\n};\n\n/**\n * Chat - Wrapper component for Chat. The needs to be placed around any other chat components.\n * This Chat component provides the ChatContext to all other components.\n *\n * The ChatContext provides the following props:\n *\n * - channel - currently active channel\n * - client - client connection\n * - connectionRecovering - whether or not websocket is reconnecting\n * - isOnline - whether or not set user is active\n * - setActiveChannel - function to set the currently active channel\n *\n * The Chat Component takes the following generics in order:\n * - At (AttachmentType) - custom Attachment object extension\n * - Ct (ChannelType) - custom Channel object extension\n * - Co (CommandType) - custom Command string union extension\n * - Ev (EventType) - custom Event object extension\n * - Me (MessageType) - custom Message object extension\n * - Re (ReactionType) - custom Reaction object extension\n * - Us (UserType) - custom User object extension\n */\nexport const Chat = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: PropsWithChildren<ChatProps<StreamChatGenerics>>,\n) => {\n const { style } = useOverlayContext();\n\n return <ChatWithContext {...{ style }} {...props} />;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAIA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,qBAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AAEA,IAAAQ,gBAAA,GAAAR,OAAA;AAEA,IAAAS,qBAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AACA,IAAAW,aAAA,GAAAX,OAAA;AACA,IAAAY,eAAA,GAAAZ,OAAA;AACA,IAAAa,aA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{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_dayjs","_interopRequireDefault","_useAppSettings","_useCreateChatContext","_useIsOnline2","_useMutedUsers","_useSyncDatabase","_ChannelsStateContext","_ChatContext","_DebugContext","_OverlayContext","_ThemeContext","_TranslationContext","_useStreami18n","_init","_native","_QuickSqliteClient","_DBSyncManager","_version","_this","_jsxFileName","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","init","ChatWithContext","props","_client$user2","_client$user3","children","client","_props$closeConnectio","closeConnectionOnBackground","_props$enableOfflineS","enableOfflineSupport","i18nInstance","_props$ImageComponent","ImageComponent","Image","style","_useState","useState","_useState2","_slicedToArray2","channel","setChannel","_useState3","t","tDateTimeParser","input","Dayjs","_useState4","translators","setTranslators","loadingTranslators","useStreami18n","_useIsOnline","useIsOnline","connectionRecovering","isOnline","_useState5","_useState6","initialisedDatabase","setInitialisedDatabase","mutedUsers","useMutedUsers","debugRef","useDebugContext","isDebugModeEnabled","__DEV__","current","useEffect","setUserAgent","SDK","Platform","OS","version","recoverStateOnReconnect","persistUserOnConnectionFailure","setEventType","setSendEventParams","action","data","user","setActiveChannel","newChannel","_client$user","id","QuickSqliteClient","initializeDatabase","DBSyncManager","appSettings","useAppSettings","chatContext","useCreateChatContext","useSyncDatabase","createElement","ChatProvider","value","__self","__source","fileName","lineNumber","columnNumber","TranslationProvider","_extends2","userLanguage","language","DEFAULT_USER_LANGUAGE","ThemeProvider","ChannelsStateProvider","Chat","_useOverlayContext","useOverlayContext","exports"],"sources":["Chat.tsx"],"sourcesContent":["import React, { PropsWithChildren, useEffect, useState } from 'react';\nimport { Image, Platform } from 'react-native';\n\nimport Dayjs from 'dayjs';\n\nimport type { Channel, StreamChat } from 'stream-chat';\n\nimport { useAppSettings } from './hooks/useAppSettings';\nimport { useCreateChatContext } from './hooks/useCreateChatContext';\nimport { useIsOnline } from './hooks/useIsOnline';\nimport { useMutedUsers } from './hooks/useMutedUsers';\n\nimport { useSyncDatabase } from './hooks/useSyncDatabase';\n\nimport { ChannelsStateProvider } from '../../contexts/channelsStateContext/ChannelsStateContext';\nimport { ChatContextValue, ChatProvider } from '../../contexts/chatContext/ChatContext';\nimport { useDebugContext } from '../../contexts/debugContext/DebugContext';\nimport { useOverlayContext } from '../../contexts/overlayContext/OverlayContext';\nimport { DeepPartial, ThemeProvider } from '../../contexts/themeContext/ThemeContext';\nimport type { Theme } from '../../contexts/themeContext/utils/theme';\nimport {\n DEFAULT_USER_LANGUAGE,\n TranslationProvider,\n TranslatorFunctions,\n} from '../../contexts/translationContext/TranslationContext';\nimport { useStreami18n } from '../../hooks/useStreami18n';\nimport init from '../../init';\n\nimport { SDK } from '../../native';\nimport { QuickSqliteClient } from '../../store/QuickSqliteClient';\nimport type { DefaultStreamChatGenerics } from '../../types/types';\nimport { DBSyncManager } from '../../utils/DBSyncManager';\nimport type { Streami18n } from '../../utils/Streami18n';\nimport { version } from '../../version.json';\n\ninit();\n\nexport type ChatProps<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Pick<ChatContextValue<StreamChatGenerics>, 'client'> &\n Partial<Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'>> & {\n /**\n * When false, ws connection won't be disconnection upon backgrounding the app.\n * To receive push notifications, its necessary that user doesn't have active\n * websocket connection. So by default, we disconnect websocket connection when\n * app goes to background, and reconnect when app comes to foreground.\n */\n closeConnectionOnBackground?: boolean;\n /**\n * Enables offline storage and loading for chat data.\n */\n enableOfflineSupport?: boolean;\n /**\n * Instance of Streami18n class should be provided to Chat component to enable internationalization.\n *\n * Stream provides following list of in-built translations:\n * 1. English (en)\n * 2. Dutch (nl)\n * 3. ...\n * 4. ...\n *\n * Simplest way to start using chat components in one of the in-built languages would be following:\n *\n * ```\n * const i18n = new Streami18n('nl');\n * <Chat client={chatClient} i18nInstance={i18n}>\n * ...\n * </Chat>\n * ```\n *\n * If you would like to override certain keys in in-built translation.\n * UI will be automatically updated in this case.\n *\n * ```\n * const i18n = new Streami18n('nl');\n *\n * i18n.registerTranslation('nl', {\n * 'Nothing yet...': 'Nog Niet ...',\n * '{{ firstUser }} and {{ secondUser }} are typing...': '{{ firstUser }} en {{ secondUser }} zijn aan het typen...',\n * });\n *\n * <Chat client={chatClient} i18nInstance={i18n}>\n * ...\n * </Chat>\n * ```\n *\n * You can use the same function to add whole new language.\n *\n * ```\n * const i18n = new Streami18n('it');\n *\n * i18n.registerTranslation('it', {\n * 'Nothing yet...': 'Non ancora ...',\n * '{{ firstUser }} and {{ secondUser }} are typing...': '{{ firstUser }} a {{ secondUser }} stanno scrivendo...',\n * });\n *\n * // Make sure to call setLanguage to reflect new language in UI.\n * i18n.setLanguage('it');\n * <Chat client={chatClient} i18nInstance={i18n}>\n * ...\n * </Chat>\n * ```\n */\n i18nInstance?: Streami18n;\n /**\n * You can pass the theme object to customize the styles of Chat components. You can check the default theme in [theme.ts](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/contexts/themeContext/utils/theme.ts)\n *\n * Please check section about [themes in cookbook](https://github.com/GetStream/stream-chat-react-native/wiki/Cookbook-v3.0#theme) for details.\n *\n * ```\n * import type { DeepPartial, Theme } from 'stream-chat-react-native';\n *\n * const theme: DeepPartial<Theme> = {\n * messageSimple: {\n * file: {\n * container: {\n * backgroundColor: 'red',\n * },\n * icon: {\n * height: 16,\n * width: 16,\n * },\n * },\n * },\n * };\n *\n * <Chat style={theme}>\n * </Chat>\n * ```\n *\n * @overrideType object\n */\n style?: DeepPartial<Theme>;\n };\n\nconst ChatWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: PropsWithChildren<ChatProps<StreamChatGenerics>>,\n) => {\n const {\n children,\n client,\n closeConnectionOnBackground = true,\n enableOfflineSupport = false,\n i18nInstance,\n ImageComponent = Image,\n style,\n } = props;\n\n const [channel, setChannel] = useState<Channel<StreamChatGenerics>>();\n const [translators, setTranslators] = useState<TranslatorFunctions>({\n t: (key: string) => key,\n tDateTimeParser: (input?: string | number | Date) => Dayjs(input),\n });\n\n /**\n * Setup translators\n */\n const loadingTranslators = useStreami18n({ i18nInstance, setTranslators });\n\n /**\n * Setup connection event listeners\n */\n const { connectionRecovering, isOnline } = useIsOnline<StreamChatGenerics>(\n client,\n closeConnectionOnBackground,\n );\n\n const [initialisedDatabase, setInitialisedDatabase] = useState(false);\n\n /**\n * Setup muted user listener\n * TODO: reimplement\n */\n const mutedUsers = useMutedUsers<StreamChatGenerics>(client);\n\n const debugRef = useDebugContext();\n const isDebugModeEnabled = __DEV__ && debugRef && debugRef.current;\n\n useEffect(() => {\n if (client) {\n client.setUserAgent(`${SDK}-${Platform.OS}-${version}`);\n // This is to disable recovery related logic in js client, since we handle it in this SDK\n client.recoverStateOnReconnect = false;\n client.persistUserOnConnectionFailure = enableOfflineSupport;\n }\n\n if (isDebugModeEnabled) {\n if (debugRef.current.setEventType) debugRef.current.setEventType('send');\n if (debugRef.current.setSendEventParams)\n debugRef.current.setSendEventParams({\n action: 'Client',\n data: client.user,\n });\n }\n }, [client, enableOfflineSupport]);\n\n const setActiveChannel = (newChannel?: Channel<StreamChatGenerics>) => setChannel(newChannel);\n\n useEffect(() => {\n if (client.user?.id && enableOfflineSupport) {\n setInitialisedDatabase(false);\n QuickSqliteClient.initializeDatabase();\n DBSyncManager.init(client as unknown as StreamChat);\n setInitialisedDatabase(true);\n }\n }, [client?.user?.id, enableOfflineSupport]);\n\n const appSettings = useAppSettings(client, isOnline, enableOfflineSupport, initialisedDatabase);\n\n const chatContext = useCreateChatContext({\n appSettings,\n channel,\n client,\n connectionRecovering,\n enableOfflineSupport,\n ImageComponent,\n isOnline,\n mutedUsers,\n setActiveChannel,\n });\n\n useSyncDatabase({\n client,\n enableOfflineSupport,\n });\n\n if (loadingTranslators) return null;\n\n return (\n <ChatProvider<StreamChatGenerics> value={chatContext}>\n <TranslationProvider\n value={{ ...translators, userLanguage: client.user?.language || DEFAULT_USER_LANGUAGE }}\n >\n <ThemeProvider style={style}>\n <ChannelsStateProvider<StreamChatGenerics>>{children}</ChannelsStateProvider>\n </ThemeProvider>\n </TranslationProvider>\n </ChatProvider>\n );\n};\n\n/**\n * Chat - Wrapper component for Chat. The needs to be placed around any other chat components.\n * This Chat component provides the ChatContext to all other components.\n *\n * The ChatContext provides the following props:\n *\n * - channel - currently active channel\n * - client - client connection\n * - connectionRecovering - whether or not websocket is reconnecting\n * - isOnline - whether or not set user is active\n * - setActiveChannel - function to set the currently active channel\n *\n * The Chat Component takes the following generics in order:\n * - At (AttachmentType) - custom Attachment object extension\n * - Ct (ChannelType) - custom Channel object extension\n * - Co (CommandType) - custom Command string union extension\n * - Ev (EventType) - custom Event object extension\n * - Me (MessageType) - custom Message object extension\n * - Re (ReactionType) - custom Reaction object extension\n * - Us (UserType) - custom User object extension\n */\nexport const Chat = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: PropsWithChildren<ChatProps<StreamChatGenerics>>,\n) => {\n const { style } = useOverlayContext();\n\n return <ChatWithContext {...{ style }} {...props} />;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAIA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,qBAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AAEA,IAAAQ,gBAAA,GAAAR,OAAA;AAEA,IAAAS,qBAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AACA,IAAAW,aAAA,GAAAX,OAAA;AACA,IAAAY,eAAA,GAAAZ,OAAA;AACA,IAAAa,aAAA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,7 @@ var _react = require("react");
|
|
|
11
11
|
var dbApi = _interopRequireWildcard(require("../../../store/apis"));
|
|
12
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
-
var useAppSettings = function useAppSettings(client, isOnline, enableOfflineSupport,
|
|
14
|
+
var useAppSettings = function useAppSettings(client, isOnline, enableOfflineSupport, initialisedDatabase) {
|
|
15
15
|
var _useState = (0, _react.useState)(null),
|
|
16
16
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
17
17
|
appSettings = _useState2[0],
|
|
@@ -27,20 +27,14 @@ var useAppSettings = function useAppSettings(client, isOnline, enableOfflineSupp
|
|
|
27
27
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
28
28
|
while (1) switch (_context.prev = _context.next) {
|
|
29
29
|
case 0:
|
|
30
|
-
if (
|
|
30
|
+
if (client.userID) {
|
|
31
31
|
_context.next = 2;
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
34
|
return _context.abrupt("return");
|
|
35
35
|
case 2:
|
|
36
|
-
if (
|
|
37
|
-
_context.next =
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
return _context.abrupt("return");
|
|
41
|
-
case 4:
|
|
42
|
-
if (!(!isOnline && enableOfflineSupport)) {
|
|
43
|
-
_context.next = 8;
|
|
36
|
+
if (!(!isOnline && enableOfflineSupport && initialisedDatabase)) {
|
|
37
|
+
_context.next = 6;
|
|
44
38
|
break;
|
|
45
39
|
}
|
|
46
40
|
_appSettings = dbApi.getAppSettings({
|
|
@@ -48,11 +42,11 @@ var useAppSettings = function useAppSettings(client, isOnline, enableOfflineSupp
|
|
|
48
42
|
});
|
|
49
43
|
setAppSettings(_appSettings);
|
|
50
44
|
return _context.abrupt("return");
|
|
51
|
-
case
|
|
52
|
-
_context.prev =
|
|
53
|
-
_context.next =
|
|
45
|
+
case 6:
|
|
46
|
+
_context.prev = 6;
|
|
47
|
+
_context.next = 9;
|
|
54
48
|
return client.getAppSettings();
|
|
55
|
-
case
|
|
49
|
+
case 9:
|
|
56
50
|
_appSettings2 = _context.sent;
|
|
57
51
|
if (isMounted.current) {
|
|
58
52
|
setAppSettings(_appSettings2);
|
|
@@ -61,19 +55,19 @@ var useAppSettings = function useAppSettings(client, isOnline, enableOfflineSupp
|
|
|
61
55
|
currentUserId: client.userID
|
|
62
56
|
});
|
|
63
57
|
}
|
|
64
|
-
_context.next =
|
|
58
|
+
_context.next = 16;
|
|
65
59
|
break;
|
|
66
|
-
case
|
|
67
|
-
_context.prev =
|
|
68
|
-
_context.t0 = _context["catch"](
|
|
60
|
+
case 13:
|
|
61
|
+
_context.prev = 13;
|
|
62
|
+
_context.t0 = _context["catch"](6);
|
|
69
63
|
if (_context.t0 instanceof Error) {
|
|
70
64
|
console.error("An error occurred while getting app settings: " + _context.t0);
|
|
71
65
|
}
|
|
72
|
-
case
|
|
66
|
+
case 16:
|
|
73
67
|
case "end":
|
|
74
68
|
return _context.stop();
|
|
75
69
|
}
|
|
76
|
-
}, _callee, null, [[
|
|
70
|
+
}, _callee, null, [[6, 13]]);
|
|
77
71
|
}));
|
|
78
72
|
return _enforeAppSettings.apply(this, arguments);
|
|
79
73
|
}
|
|
@@ -81,7 +75,7 @@ var useAppSettings = function useAppSettings(client, isOnline, enableOfflineSupp
|
|
|
81
75
|
return function () {
|
|
82
76
|
isMounted.current = false;
|
|
83
77
|
};
|
|
84
|
-
}, [client, isOnline,
|
|
78
|
+
}, [client, isOnline, initialisedDatabase]);
|
|
85
79
|
return appSettings;
|
|
86
80
|
};
|
|
87
81
|
exports.useAppSettings = useAppSettings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","dbApi","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","useAppSettings","client","isOnline","enableOfflineSupport","
|
|
1
|
+
{"version":3,"names":["_react","require","dbApi","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","useAppSettings","client","isOnline","enableOfflineSupport","initialisedDatabase","_useState","useState","_useState2","_slicedToArray2","appSettings","setAppSettings","isMounted","useRef","useEffect","enforeAppSettings","_enforeAppSettings","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","_appSettings","_appSettings2","wrap","_callee$","_context","prev","next","userID","abrupt","getAppSettings","currentUserId","sent","current","upsertAppSettings","t0","Error","console","error","stop","exports"],"sources":["useAppSettings.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport type { AppSettingsAPIResponse, StreamChat } from 'stream-chat';\n\nimport * as dbApi from '../../../store/apis';\nimport type { DefaultStreamChatGenerics } from '../../../types/types';\nexport const useAppSettings = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n client: StreamChat<StreamChatGenerics>,\n isOnline: boolean | null,\n enableOfflineSupport: boolean,\n initialisedDatabase: boolean,\n): AppSettingsAPIResponse | null => {\n const [appSettings, setAppSettings] = useState<AppSettingsAPIResponse | null>(null);\n const isMounted = useRef(true);\n\n useEffect(() => {\n async function enforeAppSettings() {\n if (!client.userID) return;\n\n if (!isOnline && enableOfflineSupport && initialisedDatabase) {\n const appSettings = dbApi.getAppSettings({ currentUserId: client.userID });\n setAppSettings(appSettings);\n return;\n }\n\n try {\n const appSettings = await client.getAppSettings();\n if (isMounted.current) {\n setAppSettings(appSettings);\n enableOfflineSupport &&\n dbApi.upsertAppSettings({\n appSettings,\n currentUserId: client.userID as string,\n });\n }\n } catch (error: unknown) {\n if (error instanceof Error) {\n console.error(`An error occurred while getting app settings: ${error}`);\n }\n }\n }\n\n enforeAppSettings();\n\n return () => {\n isMounted.current = false;\n };\n }, [client, isOnline, initialisedDatabase]);\n\n return appSettings;\n};\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAC,uBAAA,CAAAF,OAAA;AAA6C,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,uCAAAA,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA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AO,GAAG,KAAK;IAC3B,CAAC;EACH,CAAC,EAAE,CAACjC,MAAM,EAAEC,QAAQ,EAAEE,mBAAmB,CAAC,CAAC;EAE3C,OAAOK,WAAW;AACpB,CAAC;AAACgC,OAAA,CAAAzC,cAAA,GAAAA,cAAA"}
|
|
@@ -73,7 +73,7 @@ var InvertedCellRendererComponent = function InvertedCellRendererComponent(props
|
|
|
73
73
|
__self: _this,
|
|
74
74
|
__source: {
|
|
75
75
|
fileName: _jsxFileName,
|
|
76
|
-
lineNumber:
|
|
76
|
+
lineNumber: 95,
|
|
77
77
|
columnNumber: 3
|
|
78
78
|
}
|
|
79
79
|
}));
|
|
@@ -195,13 +195,8 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
195
195
|
stickyHeaderDate = _useState10[0],
|
|
196
196
|
setStickyHeaderDate = _useState10[1];
|
|
197
197
|
var stickyHeaderDateRef = (0, _react.useRef)();
|
|
198
|
-
var
|
|
199
|
-
|
|
200
|
-
});
|
|
201
|
-
var channelLastReadRef = (0, _react.useRef)(channel != null && channel.initialized ? channel.lastRead() : undefined);
|
|
202
|
-
(0, _react.useEffect)(function () {
|
|
203
|
-
channelLastReadRef.current = channel != null && channel.initialized ? channel.lastRead() : undefined;
|
|
204
|
-
}, [channel]);
|
|
198
|
+
var channelRef = (0, _react.useRef)(channel);
|
|
199
|
+
channelRef.current = channel;
|
|
205
200
|
var updateStickyHeaderDateIfNeeded = function updateStickyHeaderDateIfNeeded(viewableItems) {
|
|
206
201
|
if (viewableItems.length) {
|
|
207
202
|
var _lastItem$item, _stickyHeaderDateRef$;
|
|
@@ -285,16 +280,28 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
285
280
|
message = _ref2.item;
|
|
286
281
|
if (!channel || !channel.initialized && !channel.offlineMode) return null;
|
|
287
282
|
var lastRead = channel.lastRead();
|
|
288
|
-
var
|
|
289
|
-
|
|
290
|
-
|
|
283
|
+
var countUnread = channel.countUnread();
|
|
284
|
+
function isMessageUnread(messageArrayIndex) {
|
|
285
|
+
if (lastRead && message.created_at) {
|
|
286
|
+
return lastRead < message.created_at;
|
|
287
|
+
} else {
|
|
288
|
+
var isLatestMessageSetShown = !!channel.state.messageSets.find(function (set) {
|
|
289
|
+
return set.isCurrent && set.isLatest;
|
|
290
|
+
});
|
|
291
|
+
return isLatestMessageSetShown && messageArrayIndex <= countUnread - 1;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
var isCurrentMessageUnread = isMessageUnread(index);
|
|
295
|
+
var isLastMessageUnread = isMessageUnread(index + 1);
|
|
296
|
+
var showUnreadUnderlay = isCurrentMessageUnread && scrollToBottomButtonVisible;
|
|
297
|
+
var insertInlineUnreadIndicator = showUnreadUnderlay && !isLastMessageUnread;
|
|
291
298
|
if (message.type === 'system') {
|
|
292
299
|
return _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement(_reactNative.View, {
|
|
293
300
|
testID: "message-list-item-" + index,
|
|
294
301
|
__self: _this,
|
|
295
302
|
__source: {
|
|
296
303
|
fileName: _jsxFileName,
|
|
297
|
-
lineNumber:
|
|
304
|
+
lineNumber: 553,
|
|
298
305
|
columnNumber: 11
|
|
299
306
|
}
|
|
300
307
|
}, _react["default"].createElement(MessageSystem, {
|
|
@@ -303,14 +310,14 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
303
310
|
__self: _this,
|
|
304
311
|
__source: {
|
|
305
312
|
fileName: _jsxFileName,
|
|
306
|
-
lineNumber:
|
|
313
|
+
lineNumber: 554,
|
|
307
314
|
columnNumber: 13
|
|
308
315
|
}
|
|
309
316
|
})), insertInlineUnreadIndicator && _react["default"].createElement(InlineUnreadIndicator, {
|
|
310
317
|
__self: _this,
|
|
311
318
|
__source: {
|
|
312
319
|
fileName: _jsxFileName,
|
|
313
|
-
lineNumber:
|
|
320
|
+
lineNumber: 556,
|
|
314
321
|
columnNumber: 43
|
|
315
322
|
}
|
|
316
323
|
}));
|
|
@@ -321,7 +328,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
321
328
|
__self: _this,
|
|
322
329
|
__source: {
|
|
323
330
|
fileName: _jsxFileName,
|
|
324
|
-
lineNumber:
|
|
331
|
+
lineNumber: 566,
|
|
325
332
|
columnNumber: 36
|
|
326
333
|
}
|
|
327
334
|
}), _react["default"].createElement(_ThemeContext.ThemeProvider, {
|
|
@@ -329,7 +336,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
329
336
|
__self: _this,
|
|
330
337
|
__source: {
|
|
331
338
|
fileName: _jsxFileName,
|
|
332
|
-
lineNumber:
|
|
339
|
+
lineNumber: 567,
|
|
333
340
|
columnNumber: 9
|
|
334
341
|
}
|
|
335
342
|
}, _react["default"].createElement(_reactNative.View, {
|
|
@@ -337,7 +344,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
337
344
|
__self: _this,
|
|
338
345
|
__source: {
|
|
339
346
|
fileName: _jsxFileName,
|
|
340
|
-
lineNumber:
|
|
347
|
+
lineNumber: 568,
|
|
341
348
|
columnNumber: 11
|
|
342
349
|
}
|
|
343
350
|
}, _react["default"].createElement(Message, {
|
|
@@ -353,7 +360,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
353
360
|
__self: _this,
|
|
354
361
|
__source: {
|
|
355
362
|
fileName: _jsxFileName,
|
|
356
|
-
lineNumber:
|
|
363
|
+
lineNumber: 569,
|
|
357
364
|
columnNumber: 13
|
|
358
365
|
}
|
|
359
366
|
}))), !shouldApplyAndroidWorkaround && (0, _useMessageList.isMessageWithStylesReadByAndDateSeparator)(message) && message.dateSeparator && _react["default"].createElement(InlineDateSeparator, {
|
|
@@ -361,14 +368,14 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
361
368
|
__self: _this,
|
|
362
369
|
__source: {
|
|
363
370
|
fileName: _jsxFileName,
|
|
364
|
-
lineNumber:
|
|
371
|
+
lineNumber: 586,
|
|
365
372
|
columnNumber: 36
|
|
366
373
|
}
|
|
367
374
|
}), insertInlineUnreadIndicator && _react["default"].createElement(InlineUnreadIndicator, {
|
|
368
375
|
__self: _this,
|
|
369
376
|
__source: {
|
|
370
377
|
fileName: _jsxFileName,
|
|
371
|
-
lineNumber:
|
|
378
|
+
lineNumber: 588,
|
|
372
379
|
columnNumber: 41
|
|
373
380
|
}
|
|
374
381
|
})) : _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement(_reactNative.View, {
|
|
@@ -376,7 +383,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
376
383
|
__self: _this,
|
|
377
384
|
__source: {
|
|
378
385
|
fileName: _jsxFileName,
|
|
379
|
-
lineNumber:
|
|
386
|
+
lineNumber: 592,
|
|
380
387
|
columnNumber: 9
|
|
381
388
|
}
|
|
382
389
|
}, shouldApplyAndroidWorkaround && (0, _useMessageList.isMessageWithStylesReadByAndDateSeparator)(message) && message.dateSeparator && _react["default"].createElement(InlineDateSeparator, {
|
|
@@ -384,7 +391,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
384
391
|
__self: _this,
|
|
385
392
|
__source: {
|
|
386
393
|
fileName: _jsxFileName,
|
|
387
|
-
lineNumber:
|
|
394
|
+
lineNumber: 595,
|
|
388
395
|
columnNumber: 38
|
|
389
396
|
}
|
|
390
397
|
}), _react["default"].createElement(Message, {
|
|
@@ -400,7 +407,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
400
407
|
__self: _this,
|
|
401
408
|
__source: {
|
|
402
409
|
fileName: _jsxFileName,
|
|
403
|
-
lineNumber:
|
|
410
|
+
lineNumber: 596,
|
|
404
411
|
columnNumber: 11
|
|
405
412
|
}
|
|
406
413
|
})), !shouldApplyAndroidWorkaround && (0, _useMessageList.isMessageWithStylesReadByAndDateSeparator)(message) && message.dateSeparator && _react["default"].createElement(InlineDateSeparator, {
|
|
@@ -408,14 +415,14 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
408
415
|
__self: _this,
|
|
409
416
|
__source: {
|
|
410
417
|
fileName: _jsxFileName,
|
|
411
|
-
lineNumber:
|
|
418
|
+
lineNumber: 616,
|
|
412
419
|
columnNumber: 36
|
|
413
420
|
}
|
|
414
421
|
}), insertInlineUnreadIndicator && _react["default"].createElement(InlineUnreadIndicator, {
|
|
415
422
|
__self: _this,
|
|
416
423
|
__source: {
|
|
417
424
|
fileName: _jsxFileName,
|
|
418
|
-
lineNumber:
|
|
425
|
+
lineNumber: 618,
|
|
419
426
|
columnNumber: 41
|
|
420
427
|
}
|
|
421
428
|
}));
|
|
@@ -616,13 +623,12 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
616
623
|
(0, _react.useEffect)(function () {
|
|
617
624
|
if (scrollToDebounceTimeoutRef.current) clearTimeout(scrollToDebounceTimeoutRef.current);
|
|
618
625
|
scrollToDebounceTimeoutRef.current = setTimeout(function () {
|
|
626
|
+
var _channelRef$current;
|
|
619
627
|
var messageIdToScroll = messageIdToScrollToRef.current;
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
break;
|
|
625
|
-
}
|
|
628
|
+
var countUnread = (_channelRef$current = channelRef.current) == null ? void 0 : _channelRef$current.countUnread();
|
|
629
|
+
if (!initialScrollSet.current && initialScrollToFirstUnreadMessage && countUnread > scrollToFirstUnreadThreshold) {
|
|
630
|
+
if (messageList.length >= countUnread) {
|
|
631
|
+
messageIdToScroll = messageList[countUnread - 1].id;
|
|
626
632
|
}
|
|
627
633
|
} else if (targetedMessage && messageIdLastScrolledToRef.current !== targetedMessage) {
|
|
628
634
|
messageIdToScroll = targetedMessage;
|
|
@@ -646,7 +652,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
646
652
|
}
|
|
647
653
|
}
|
|
648
654
|
}, 150);
|
|
649
|
-
}, [messageList, targetedMessage, initialScrollToFirstUnreadMessage]);
|
|
655
|
+
}, [channel.initialized, messageList, targetedMessage, initialScrollToFirstUnreadMessage]);
|
|
650
656
|
var messagesWithImages = legacyImageViewerSwipeBehaviour && messageList.filter(function (message) {
|
|
651
657
|
var isMessageTypeDeleted = message.type === 'deleted';
|
|
652
658
|
if (!isMessageTypeDeleted && message.attachments) {
|
|
@@ -710,7 +716,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
710
716
|
__self: _this,
|
|
711
717
|
__source: {
|
|
712
718
|
fileName: _jsxFileName,
|
|
713
|
-
lineNumber:
|
|
719
|
+
lineNumber: 970,
|
|
714
720
|
columnNumber: 7
|
|
715
721
|
}
|
|
716
722
|
}, _react["default"].createElement(EmptyStateIndicator, {
|
|
@@ -718,7 +724,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
718
724
|
__self: _this,
|
|
719
725
|
__source: {
|
|
720
726
|
fileName: _jsxFileName,
|
|
721
|
-
lineNumber:
|
|
727
|
+
lineNumber: 974,
|
|
722
728
|
columnNumber: 9
|
|
723
729
|
}
|
|
724
730
|
}));
|
|
@@ -729,14 +735,14 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
729
735
|
__self: _this,
|
|
730
736
|
__source: {
|
|
731
737
|
fileName: _jsxFileName,
|
|
732
|
-
lineNumber:
|
|
738
|
+
lineNumber: 982,
|
|
733
739
|
columnNumber: 7
|
|
734
740
|
}
|
|
735
741
|
}, _react["default"].createElement(FooterComponent, {
|
|
736
742
|
__self: _this,
|
|
737
743
|
__source: {
|
|
738
744
|
fileName: _jsxFileName,
|
|
739
|
-
lineNumber:
|
|
745
|
+
lineNumber: 983,
|
|
740
746
|
columnNumber: 9
|
|
741
747
|
}
|
|
742
748
|
}));
|
|
@@ -747,14 +753,14 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
747
753
|
__self: _this,
|
|
748
754
|
__source: {
|
|
749
755
|
fileName: _jsxFileName,
|
|
750
|
-
lineNumber:
|
|
756
|
+
lineNumber: 991,
|
|
751
757
|
columnNumber: 7
|
|
752
758
|
}
|
|
753
759
|
}, _react["default"].createElement(HeaderComponent, {
|
|
754
760
|
__self: _this,
|
|
755
761
|
__source: {
|
|
756
762
|
fileName: _jsxFileName,
|
|
757
|
-
lineNumber:
|
|
763
|
+
lineNumber: 992,
|
|
758
764
|
columnNumber: 9
|
|
759
765
|
}
|
|
760
766
|
}));
|
|
@@ -766,7 +772,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
766
772
|
__self: _this,
|
|
767
773
|
__source: {
|
|
768
774
|
fileName: _jsxFileName,
|
|
769
|
-
lineNumber:
|
|
775
|
+
lineNumber: 1002,
|
|
770
776
|
columnNumber: 7
|
|
771
777
|
}
|
|
772
778
|
}, _react["default"].createElement(LoadingIndicator, {
|
|
@@ -774,7 +780,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
774
780
|
__self: _this,
|
|
775
781
|
__source: {
|
|
776
782
|
fileName: _jsxFileName,
|
|
777
|
-
lineNumber:
|
|
783
|
+
lineNumber: 1003,
|
|
778
784
|
columnNumber: 9
|
|
779
785
|
}
|
|
780
786
|
}));
|
|
@@ -786,7 +792,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
786
792
|
__self: _this,
|
|
787
793
|
__source: {
|
|
788
794
|
fileName: _jsxFileName,
|
|
789
|
-
lineNumber:
|
|
795
|
+
lineNumber: 1010,
|
|
790
796
|
columnNumber: 30
|
|
791
797
|
}
|
|
792
798
|
});
|
|
@@ -795,7 +801,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
795
801
|
__self: _this,
|
|
796
802
|
__source: {
|
|
797
803
|
fileName: _jsxFileName,
|
|
798
|
-
lineNumber:
|
|
804
|
+
lineNumber: 1011,
|
|
799
805
|
columnNumber: 46
|
|
800
806
|
}
|
|
801
807
|
});
|
|
@@ -809,7 +815,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
809
815
|
__self: _this,
|
|
810
816
|
__source: {
|
|
811
817
|
fileName: _jsxFileName,
|
|
812
|
-
lineNumber:
|
|
818
|
+
lineNumber: 1016,
|
|
813
819
|
columnNumber: 5
|
|
814
820
|
}
|
|
815
821
|
}, _react["default"].createElement(FlatList, (0, _extends2["default"])({
|
|
@@ -845,7 +851,7 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
845
851
|
__self: _this,
|
|
846
852
|
__source: {
|
|
847
853
|
fileName: _jsxFileName,
|
|
848
|
-
lineNumber:
|
|
854
|
+
lineNumber: 1020,
|
|
849
855
|
columnNumber: 7
|
|
850
856
|
}
|
|
851
857
|
})), !loading && _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement(_reactNative.View, {
|
|
@@ -853,28 +859,28 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
853
859
|
__self: _this,
|
|
854
860
|
__source: {
|
|
855
861
|
fileName: _jsxFileName,
|
|
856
|
-
lineNumber:
|
|
862
|
+
lineNumber: 1060,
|
|
857
863
|
columnNumber: 11
|
|
858
864
|
}
|
|
859
865
|
}, _react["default"].createElement(StickyHeaderComponent, {
|
|
860
866
|
__self: _this,
|
|
861
867
|
__source: {
|
|
862
868
|
fileName: _jsxFileName,
|
|
863
|
-
lineNumber:
|
|
869
|
+
lineNumber: 1061,
|
|
864
870
|
columnNumber: 13
|
|
865
871
|
}
|
|
866
872
|
})), !disableTypingIndicator && TypingIndicator && _react["default"].createElement(TypingIndicatorContainer, {
|
|
867
873
|
__self: _this,
|
|
868
874
|
__source: {
|
|
869
875
|
fileName: _jsxFileName,
|
|
870
|
-
lineNumber:
|
|
876
|
+
lineNumber: 1064,
|
|
871
877
|
columnNumber: 13
|
|
872
878
|
}
|
|
873
879
|
}, _react["default"].createElement(TypingIndicator, {
|
|
874
880
|
__self: _this,
|
|
875
881
|
__source: {
|
|
876
882
|
fileName: _jsxFileName,
|
|
877
|
-
lineNumber:
|
|
883
|
+
lineNumber: 1065,
|
|
878
884
|
columnNumber: 15
|
|
879
885
|
}
|
|
880
886
|
})), _react["default"].createElement(ScrollToBottomButton, {
|
|
@@ -884,14 +890,14 @@ var MessageListWithContext = function MessageListWithContext(props) {
|
|
|
884
890
|
__self: _this,
|
|
885
891
|
__source: {
|
|
886
892
|
fileName: _jsxFileName,
|
|
887
|
-
lineNumber:
|
|
893
|
+
lineNumber: 1068,
|
|
888
894
|
columnNumber: 11
|
|
889
895
|
}
|
|
890
896
|
})), _react["default"].createElement(NetworkDownIndicator, {
|
|
891
897
|
__self: _this,
|
|
892
898
|
__source: {
|
|
893
899
|
fileName: _jsxFileName,
|
|
894
|
-
lineNumber:
|
|
900
|
+
lineNumber: 1075,
|
|
895
901
|
columnNumber: 7
|
|
896
902
|
}
|
|
897
903
|
}));
|
|
@@ -998,7 +1004,7 @@ var MessageList = function MessageList(props) {
|
|
|
998
1004
|
__self: _this,
|
|
999
1005
|
__source: {
|
|
1000
1006
|
fileName: _jsxFileName,
|
|
1001
|
-
lineNumber:
|
|
1007
|
+
lineNumber: 1133,
|
|
1002
1008
|
columnNumber: 5
|
|
1003
1009
|
}
|
|
1004
1010
|
}));
|