stream-chat-react-native-core 4.3.1-beta.2 → 4.3.1

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.
Files changed (30) hide show
  1. package/lib/commonjs/components/Chat/Chat.js +4 -8
  2. package/lib/commonjs/components/Chat/Chat.js.map +1 -1
  3. package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js +1 -3
  4. package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js.map +1 -1
  5. package/lib/commonjs/contexts/chatContext/ChatContext.js +2 -2
  6. package/lib/commonjs/contexts/chatContext/ChatContext.js.map +1 -1
  7. package/lib/commonjs/version.json +1 -1
  8. package/lib/module/components/Chat/Chat.js +4 -8
  9. package/lib/module/components/Chat/Chat.js.map +1 -1
  10. package/lib/module/components/Chat/hooks/useCreateChatContext.js +1 -3
  11. package/lib/module/components/Chat/hooks/useCreateChatContext.js.map +1 -1
  12. package/lib/module/contexts/chatContext/ChatContext.js +2 -2
  13. package/lib/module/contexts/chatContext/ChatContext.js.map +1 -1
  14. package/lib/module/version.json +1 -1
  15. package/lib/typescript/components/Chat/hooks/useCreateChatContext.d.ts +1 -1
  16. package/lib/typescript/contexts/chatContext/ChatContext.d.ts +1 -5
  17. package/package.json +1 -1
  18. package/src/components/ChannelList/hooks/listeners/__tests__/useChannelUpdated.test.tsx +0 -1
  19. package/src/components/Chat/Chat.tsx +0 -4
  20. package/src/components/Chat/hooks/useCreateChatContext.ts +0 -2
  21. package/src/contexts/chatContext/ChatContext.tsx +1 -5
  22. package/src/version.json +1 -1
  23. package/lib/commonjs/components/Chat/hooks/useAppSettings.js +0 -80
  24. package/lib/commonjs/components/Chat/hooks/useAppSettings.js.map +0 -1
  25. package/lib/module/components/Chat/hooks/useAppSettings.js +0 -80
  26. package/lib/module/components/Chat/hooks/useAppSettings.js.map +0 -1
  27. package/lib/typescript/components/Chat/hooks/__tests__/useAppSettings.test.d.ts +0 -1
  28. package/lib/typescript/components/Chat/hooks/useAppSettings.d.ts +0 -3
  29. package/src/components/Chat/hooks/__tests__/useAppSettings.test.tsx +0 -34
  30. package/src/components/Chat/hooks/useAppSettings.ts +0 -39
@@ -17,8 +17,6 @@ var _reactNative = require("react-native");
17
17
 
18
18
  var _dayjs = _interopRequireDefault(require("dayjs"));
19
19
 
20
- var _useAppSettings = require("./hooks/useAppSettings");
21
-
22
20
  var _useCreateChatContext = require("./hooks/useCreateChatContext");
23
21
 
24
22
  var _useIsOnline2 = require("./hooks/useIsOnline");
@@ -96,9 +94,7 @@ var ChatWithContext = function ChatWithContext(props) {
96
94
  return setChannel(newChannel);
97
95
  };
98
96
 
99
- var appSettings = (0, _useAppSettings.useAppSettings)(client, isOnline);
100
97
  var chatContext = (0, _useCreateChatContext.useCreateChatContext)({
101
- appSettings: appSettings,
102
98
  channel: channel,
103
99
  client: client,
104
100
  connectionRecovering: connectionRecovering,
@@ -112,7 +108,7 @@ var ChatWithContext = function ChatWithContext(props) {
112
108
  __self: _this,
113
109
  __source: {
114
110
  fileName: _jsxFileName,
115
- lineNumber: 180,
111
+ lineNumber: 176,
116
112
  columnNumber: 5
117
113
  }
118
114
  }, _react["default"].createElement(_TranslationContext.TranslationProvider, {
@@ -120,7 +116,7 @@ var ChatWithContext = function ChatWithContext(props) {
120
116
  __self: _this,
121
117
  __source: {
122
118
  fileName: _jsxFileName,
123
- lineNumber: 181,
119
+ lineNumber: 177,
124
120
  columnNumber: 7
125
121
  }
126
122
  }, _react["default"].createElement(_ThemeContext.ThemeProvider, {
@@ -128,7 +124,7 @@ var ChatWithContext = function ChatWithContext(props) {
128
124
  __self: _this,
129
125
  __source: {
130
126
  fileName: _jsxFileName,
131
- lineNumber: 182,
127
+ lineNumber: 178,
132
128
  columnNumber: 9
133
129
  }
134
130
  }, children)));
@@ -144,7 +140,7 @@ var Chat = function Chat(props) {
144
140
  __self: _this,
145
141
  __source: {
146
142
  fileName: _jsxFileName,
147
- lineNumber: 216,
143
+ lineNumber: 212,
148
144
  columnNumber: 10
149
145
  }
150
146
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["Chat.tsx"],"names":["ChatWithContext","props","children","client","closeConnectionOnBackground","i18nInstance","style","channel","setChannel","t","key","tDateTimeParser","input","translators","setTranslators","loadingTranslators","connectionRecovering","isOnline","mutedUsers","setUserAgent","SDK","Platform","OS","version","recoverStateOnReconnect","setActiveChannel","newChannel","appSettings","chatContext","Chat"],"mappings":"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","sourcesContent":["import React, { PropsWithChildren, useEffect, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport Dayjs from 'dayjs';\n\nimport type { Channel } 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 { ChatContextValue, ChatProvider } from '../../contexts/chatContext/ChatContext';\nimport { useOverlayContext } from '../../contexts/overlayContext/OverlayContext';\nimport { DeepPartial, ThemeProvider } from '../../contexts/themeContext/ThemeContext';\nimport type { Theme } from '../../contexts/themeContext/utils/theme';\nimport {\n TranslationContextValue,\n TranslationProvider,\n} from '../../contexts/translationContext/TranslationContext';\nimport { useStreami18n } from '../../hooks/useStreami18n';\nimport init from '../../init';\n\nimport { SDK } from '../../native';\nimport type { DefaultStreamChatGenerics } from '../../types/types';\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 /**\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 * 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/master/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 { children, client, closeConnectionOnBackground = true, i18nInstance, style } = props;\n\n const [channel, setChannel] = useState<Channel<StreamChatGenerics>>();\n const [translators, setTranslators] = useState<TranslationContextValue>({\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 /**\n * Setup muted user listener\n */\n const mutedUsers = useMutedUsers<StreamChatGenerics>(client);\n\n useEffect(() => {\n if (client.setUserAgent) {\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 }\n }, []);\n\n const setActiveChannel = (newChannel?: Channel<StreamChatGenerics>) => setChannel(newChannel);\n\n const appSettings = useAppSettings(client, isOnline);\n\n const chatContext = useCreateChatContext({\n appSettings,\n channel,\n client,\n connectionRecovering,\n isOnline,\n mutedUsers,\n setActiveChannel,\n });\n\n if (loadingTranslators) return null;\n\n return (\n <ChatProvider<StreamChatGenerics> value={chatContext}>\n <TranslationProvider value={translators}>\n <ThemeProvider style={style}>{children}</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"]}
1
+ {"version":3,"sources":["Chat.tsx"],"names":["ChatWithContext","props","children","client","closeConnectionOnBackground","i18nInstance","style","channel","setChannel","t","key","tDateTimeParser","input","translators","setTranslators","loadingTranslators","connectionRecovering","isOnline","mutedUsers","setUserAgent","SDK","Platform","OS","version","recoverStateOnReconnect","setActiveChannel","newChannel","chatContext","Chat"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AAIA;;AACA;;AAEA;;AAGA;;;;;;;;;AAEA;;AA+FA,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAGtBC,KAHsB,EAInB;AACH,MAAQC,QAAR,GAAsFD,KAAtF,CAAQC,QAAR;AAAA,MAAkBC,MAAlB,GAAsFF,KAAtF,CAAkBE,MAAlB;AAAA,8BAAsFF,KAAtF,CAA0BG,2BAA1B;AAAA,MAA0BA,2BAA1B,sCAAwD,IAAxD;AAAA,MAA8DC,YAA9D,GAAsFJ,KAAtF,CAA8DI,YAA9D;AAAA,MAA4EC,KAA5E,GAAsFL,KAAtF,CAA4EK,KAA5E;;AAEA,kBAA8B,sBAA9B;AAAA;AAAA,MAAOC,OAAP;AAAA,MAAgBC,UAAhB;;AACA,mBAAsC,qBAAkC;AACtEC,IAAAA,CAAC,EAAE,WAACC,GAAD;AAAA,aAAiBA,GAAjB;AAAA,KADmE;AAEtEC,IAAAA,eAAe,EAAE,yBAACC,KAAD;AAAA,aAAoC,uBAAMA,KAAN,CAApC;AAAA;AAFqD,GAAlC,CAAtC;AAAA;AAAA,MAAOC,WAAP;AAAA,MAAoBC,cAApB;;AAQA,MAAMC,kBAAkB,GAAG,kCAAc;AAAEV,IAAAA,YAAY,EAAZA,YAAF;AAAgBS,IAAAA,cAAc,EAAdA;AAAhB,GAAd,CAA3B;;AAKA,qBAA2C,+BACzCX,MADyC,EAEzCC,2BAFyC,CAA3C;AAAA,MAAQY,oBAAR,gBAAQA,oBAAR;AAAA,MAA8BC,QAA9B,gBAA8BA,QAA9B;;AAQA,MAAMC,UAAU,GAAG,kCAAkCf,MAAlC,CAAnB;AAEA,wBAAU,YAAM;AACd,QAAIA,MAAM,CAACgB,YAAX,EAAyB;AACvBhB,MAAAA,MAAM,CAACgB,YAAP,CAAuBC,WAAvB,SAA8BC,sBAASC,EAAvC,SAA6CC,gBAA7C;AAEApB,MAAAA,MAAM,CAACqB,uBAAP,GAAiC,KAAjC;AACD;AACF,GAND,EAMG,EANH;;AAQA,MAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,UAAD;AAAA,WAA8ClB,UAAU,CAACkB,UAAD,CAAxD;AAAA,GAAzB;;AAEA,MAAMC,WAAW,GAAG,gDAAqB;AACvCpB,IAAAA,OAAO,EAAPA,OADuC;AAEvCJ,IAAAA,MAAM,EAANA,MAFuC;AAGvCa,IAAAA,oBAAoB,EAApBA,oBAHuC;AAIvCC,IAAAA,QAAQ,EAARA,QAJuC;AAKvCC,IAAAA,UAAU,EAAVA,UALuC;AAMvCO,IAAAA,gBAAgB,EAAhBA;AANuC,GAArB,CAApB;AASA,MAAIV,kBAAJ,EAAwB,OAAO,IAAP;AAExB,SACE,gCAAC,yBAAD;AAAkC,IAAA,KAAK,EAAEY,WAAzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACE,gCAAC,uCAAD;AAAqB,IAAA,KAAK,EAAEd,WAA5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACE,gCAAC,2BAAD;AAAe,IAAA,KAAK,EAAEP,KAAtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAA8BJ,QAA9B,CADF,CADF,CADF;AAOD,CA3DD;;AAkFO,IAAM0B,IAAI,GAAG,SAAPA,IAAO,CAGlB3B,KAHkB,EAIf;AACH,2BAAkB,wCAAlB;AAAA,MAAQK,KAAR,sBAAQA,KAAR;;AAEA,SAAO,gCAAC,eAAD;AAAuBA,IAAAA,KAAK,EAALA;AAAvB,KAAoCL,KAApC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAP;AACD,CARM","sourcesContent":["import React, { PropsWithChildren, useEffect, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport Dayjs from 'dayjs';\n\nimport type { Channel } from 'stream-chat';\n\nimport { useCreateChatContext } from './hooks/useCreateChatContext';\nimport { useIsOnline } from './hooks/useIsOnline';\nimport { useMutedUsers } from './hooks/useMutedUsers';\n\nimport { ChatContextValue, ChatProvider } from '../../contexts/chatContext/ChatContext';\nimport { useOverlayContext } from '../../contexts/overlayContext/OverlayContext';\nimport { DeepPartial, ThemeProvider } from '../../contexts/themeContext/ThemeContext';\nimport type { Theme } from '../../contexts/themeContext/utils/theme';\nimport {\n TranslationContextValue,\n TranslationProvider,\n} from '../../contexts/translationContext/TranslationContext';\nimport { useStreami18n } from '../../hooks/useStreami18n';\nimport init from '../../init';\n\nimport { SDK } from '../../native';\nimport type { DefaultStreamChatGenerics } from '../../types/types';\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 /**\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 * 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/master/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 { children, client, closeConnectionOnBackground = true, i18nInstance, style } = props;\n\n const [channel, setChannel] = useState<Channel<StreamChatGenerics>>();\n const [translators, setTranslators] = useState<TranslationContextValue>({\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 /**\n * Setup muted user listener\n */\n const mutedUsers = useMutedUsers<StreamChatGenerics>(client);\n\n useEffect(() => {\n if (client.setUserAgent) {\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 }\n }, []);\n\n const setActiveChannel = (newChannel?: Channel<StreamChatGenerics>) => setChannel(newChannel);\n\n const chatContext = useCreateChatContext({\n channel,\n client,\n connectionRecovering,\n isOnline,\n mutedUsers,\n setActiveChannel,\n });\n\n if (loadingTranslators) return null;\n\n return (\n <ChatProvider<StreamChatGenerics> value={chatContext}>\n <TranslationProvider value={translators}>\n <ThemeProvider style={style}>{children}</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"]}
@@ -6,8 +6,7 @@ exports.useCreateChatContext = void 0;
6
6
  var _react = require("react");
7
7
 
8
8
  var useCreateChatContext = function useCreateChatContext(_ref) {
9
- var appSettings = _ref.appSettings,
10
- channel = _ref.channel,
9
+ var channel = _ref.channel,
11
10
  client = _ref.client,
12
11
  connectionRecovering = _ref.connectionRecovering,
13
12
  isOnline = _ref.isOnline,
@@ -18,7 +17,6 @@ var useCreateChatContext = function useCreateChatContext(_ref) {
18
17
  var mutedUsersLength = mutedUsers.length;
19
18
  var chatContext = (0, _react.useMemo)(function () {
20
19
  return {
21
- appSettings: appSettings,
22
20
  channel: channel,
23
21
  client: client,
24
22
  connectionRecovering: connectionRecovering,
@@ -1 +1 @@
1
- {"version":3,"sources":["useCreateChatContext.ts"],"names":["useCreateChatContext","appSettings","channel","client","connectionRecovering","isOnline","mutedUsers","setActiveChannel","channelId","id","clientValues","clientID","Object","keys","activeChannels","length","listeners","mutedChannels","mutedUsersLength","chatContext"],"mappings":";;;;;AAAA;;AAKO,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB,OAUQ;AAAA,MAP1CC,WAO0C,QAP1CA,WAO0C;AAAA,MAN1CC,OAM0C,QAN1CA,OAM0C;AAAA,MAL1CC,MAK0C,QAL1CA,MAK0C;AAAA,MAJ1CC,oBAI0C,QAJ1CA,oBAI0C;AAAA,MAH1CC,QAG0C,QAH1CA,QAG0C;AAAA,MAF1CC,UAE0C,QAF1CA,UAE0C;AAAA,MAD1CC,gBAC0C,QAD1CA,gBAC0C;AAC1C,MAAMC,SAAS,GAAGN,OAAH,oBAAGA,OAAO,CAAEO,EAA3B;AACA,MAAMC,YAAY,QAAMP,MAAM,CAACQ,QAAb,GAAwBC,MAAM,CAACC,IAAP,CAAYV,MAAM,CAACW,cAAnB,EAAmCC,MAA3D,GAChBH,MAAM,CAACC,IAAP,CAAYV,MAAM,CAACa,SAAnB,EAA8BD,MADd,GAEfZ,MAAM,CAACc,aAAP,CAAqBF,MAFxB;AAGA,MAAMG,gBAAgB,GAAGZ,UAAU,CAACS,MAApC;AAEA,MAAMI,WAAiD,GAAG,oBACxD;AAAA,WAAO;AACLlB,MAAAA,WAAW,EAAXA,WADK;AAELC,MAAAA,OAAO,EAAPA,OAFK;AAGLC,MAAAA,MAAM,EAANA,MAHK;AAILC,MAAAA,oBAAoB,EAApBA,oBAJK;AAKLC,MAAAA,QAAQ,EAARA,QALK;AAMLC,MAAAA,UAAU,EAAVA,UANK;AAOLC,MAAAA,gBAAgB,EAAhBA;AAPK,KAAP;AAAA,GADwD,EAUxD,CAACC,SAAD,EAAYE,YAAZ,EAA0BN,oBAA1B,EAAgDC,QAAhD,EAA0Da,gBAA1D,CAVwD,CAA1D;AAaA,SAAOC,WAAP;AACD,CA/BM","sourcesContent":["import { useMemo } from 'react';\n\nimport type { ChatContextValue } from '../../../contexts/chatContext/ChatContext';\nimport type { DefaultStreamChatGenerics } from '../../../types/types';\n\nexport const useCreateChatContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n appSettings,\n channel,\n client,\n connectionRecovering,\n isOnline,\n mutedUsers,\n setActiveChannel,\n}: ChatContextValue<StreamChatGenerics>) => {\n const channelId = channel?.id;\n const clientValues = `${client.clientID}${Object.keys(client.activeChannels).length}${\n Object.keys(client.listeners).length\n }${client.mutedChannels.length}`;\n const mutedUsersLength = mutedUsers.length;\n\n const chatContext: ChatContextValue<StreamChatGenerics> = useMemo(\n () => ({\n appSettings,\n channel,\n client,\n connectionRecovering,\n isOnline,\n mutedUsers,\n setActiveChannel,\n }),\n [channelId, clientValues, connectionRecovering, isOnline, mutedUsersLength],\n );\n\n return chatContext;\n};\n"]}
1
+ {"version":3,"sources":["useCreateChatContext.ts"],"names":["useCreateChatContext","channel","client","connectionRecovering","isOnline","mutedUsers","setActiveChannel","channelId","id","clientValues","clientID","Object","keys","activeChannels","length","listeners","mutedChannels","mutedUsersLength","chatContext"],"mappings":";;;;;AAAA;;AAKO,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB,OASQ;AAAA,MAN1CC,OAM0C,QAN1CA,OAM0C;AAAA,MAL1CC,MAK0C,QAL1CA,MAK0C;AAAA,MAJ1CC,oBAI0C,QAJ1CA,oBAI0C;AAAA,MAH1CC,QAG0C,QAH1CA,QAG0C;AAAA,MAF1CC,UAE0C,QAF1CA,UAE0C;AAAA,MAD1CC,gBAC0C,QAD1CA,gBAC0C;AAC1C,MAAMC,SAAS,GAAGN,OAAH,oBAAGA,OAAO,CAAEO,EAA3B;AACA,MAAMC,YAAY,QAAMP,MAAM,CAACQ,QAAb,GAAwBC,MAAM,CAACC,IAAP,CAAYV,MAAM,CAACW,cAAnB,EAAmCC,MAA3D,GAChBH,MAAM,CAACC,IAAP,CAAYV,MAAM,CAACa,SAAnB,EAA8BD,MADd,GAEfZ,MAAM,CAACc,aAAP,CAAqBF,MAFxB;AAGA,MAAMG,gBAAgB,GAAGZ,UAAU,CAACS,MAApC;AAEA,MAAMI,WAAiD,GAAG,oBACxD;AAAA,WAAO;AACLjB,MAAAA,OAAO,EAAPA,OADK;AAELC,MAAAA,MAAM,EAANA,MAFK;AAGLC,MAAAA,oBAAoB,EAApBA,oBAHK;AAILC,MAAAA,QAAQ,EAARA,QAJK;AAKLC,MAAAA,UAAU,EAAVA,UALK;AAMLC,MAAAA,gBAAgB,EAAhBA;AANK,KAAP;AAAA,GADwD,EASxD,CAACC,SAAD,EAAYE,YAAZ,EAA0BN,oBAA1B,EAAgDC,QAAhD,EAA0Da,gBAA1D,CATwD,CAA1D;AAYA,SAAOC,WAAP;AACD,CA7BM","sourcesContent":["import { useMemo } from 'react';\n\nimport type { ChatContextValue } from '../../../contexts/chatContext/ChatContext';\nimport type { DefaultStreamChatGenerics } from '../../../types/types';\n\nexport const useCreateChatContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n channel,\n client,\n connectionRecovering,\n isOnline,\n mutedUsers,\n setActiveChannel,\n}: ChatContextValue<StreamChatGenerics>) => {\n const channelId = channel?.id;\n const clientValues = `${client.clientID}${Object.keys(client.activeChannels).length}${\n Object.keys(client.listeners).length\n }${client.mutedChannels.length}`;\n const mutedUsersLength = mutedUsers.length;\n\n const chatContext: ChatContextValue<StreamChatGenerics> = useMemo(\n () => ({\n channel,\n client,\n connectionRecovering,\n isOnline,\n mutedUsers,\n setActiveChannel,\n }),\n [channelId, clientValues, connectionRecovering, isOnline, mutedUsersLength],\n );\n\n return chatContext;\n};\n"]}
@@ -32,7 +32,7 @@ var ChatProvider = function ChatProvider(_ref) {
32
32
  __self: _this,
33
33
  __source: {
34
34
  fileName: _jsxFileName,
35
- lineNumber: 71,
35
+ lineNumber: 67,
36
36
  columnNumber: 3
37
37
  }
38
38
  }, children);
@@ -53,7 +53,7 @@ var withChatContext = function withChatContext(Component) {
53
53
  __self: _this,
54
54
  __source: {
55
55
  fileName: _jsxFileName,
56
- lineNumber: 94,
56
+ lineNumber: 90,
57
57
  columnNumber: 12
58
58
  }
59
59
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["ChatContext.tsx"],"names":["ChatContext","React","createContext","ChatProvider","children","value","useChatContext","withChatContext","Component","WithChatContextComponent","props","chatContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAKA;;;;;;;;;AAuDO,IAAMA,WAAW,GAAGC,kBAAMC,aAAN,CAAoB,EAApB,CAApB;;;;AAEA,IAAMC,YAAY,GAAG,SAAfA,YAAe;AAAA,MAG1BC,QAH0B,QAG1BA,QAH0B;AAAA,MAI1BC,KAJ0B,QAI1BA,KAJ0B;AAAA,SAQ1B,gCAAC,WAAD,CAAa,QAAb;AAAsB,IAAA,KAAK,EAAEA,KAA7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACGD,QADH,CAR0B;AAAA,CAArB;;;;AAaA,IAAME,cAAc,GAAG,SAAjBA,cAAiB;AAAA,SAEvB,uBAAWN,WAAX,CAFuB;AAAA,CAAvB;;;;AASA,IAAMO,eAAe,GAAG,SAAlBA,eAAkB,CAI7BC,SAJ6B,EAKqC;AAClE,MAAMC,wBAAwB,GAAG,SAA3BA,wBAA2B,CAACC,KAAD,EAAgE;AAC/F,QAAMC,WAAW,GAAGL,cAAc,EAAlC;AAEA,WAAO,gCAAC,SAAD,gCAAgBI,KAAhB,EAAiCC,WAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAP;AACD,GAJD;;AAKAF,EAAAA,wBAAwB,CAACG,WAAzB,uBAAyD,oCAAeJ,SAAf,CAAzD;AACA,SAAOC,wBAAP;AACD,CAbM","sourcesContent":["import React, { PropsWithChildren, useContext } from 'react';\n\nimport type { AppSettingsAPIResponse, Channel, Mute, StreamChat } from 'stream-chat';\n\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { getDisplayName } from '../utils/getDisplayName';\n\nexport type ChatContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n /**\n * Object of application settings returned from Stream.\n * */\n appSettings: AppSettingsAPIResponse<StreamChatGenerics> | null;\n /**\n * The StreamChat client object\n *\n * ```\n * import { StreamChat } from 'stream-chat';\n * import { Chat } from 'stream-chat-react-native';\n *\n * const client = StreamChat.getInstance('api_key);\n * await client.connectUser('user_id', 'userToken');\n *\n * <Chat client={client}>\n * </Chat>\n * ```\n *\n * @overrideType StreamChat\n * */\n client: StreamChat<StreamChatGenerics>;\n connectionRecovering: boolean;\n isOnline: boolean;\n mutedUsers: Mute<StreamChatGenerics>[];\n /**\n * @param newChannel Channel to set as active.\n *\n * @overrideType Function\n */\n setActiveChannel: (newChannel?: Channel<StreamChatGenerics>) => void;\n /**\n * Instance of channel object from stream-chat package.\n *\n * Please check the docs around how to create or query channel - https://getstream.io/chat/docs/javascript/creating_channels/?language=javascript\n *\n * ```\n * import { StreamChat, Channel } from 'stream-chat';\n * import { Chat, Channel} from 'stream-chat-react-native';\n *\n * const client = StreamChat.getInstance('api_key');\n * await client.connectUser('user_id', 'user_token');\n * const channel = client.channel('messaging', 'channel_id');\n * await channel.watch();\n * ```\n *\n * @overrideType Channel\n */\n channel?: Channel<StreamChatGenerics>;\n};\n\nexport const ChatContext = React.createContext({} as ChatContextValue);\n\nexport const ChatProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n value,\n}: PropsWithChildren<{\n value: ChatContextValue<StreamChatGenerics>;\n}>) => (\n <ChatContext.Provider value={value as unknown as ChatContextValue}>\n {children}\n </ChatContext.Provider>\n);\n\nexport const useChatContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => useContext(ChatContext) as unknown as ChatContextValue<StreamChatGenerics>;\n\n/**\n * Typescript currently does not support partial inference so if ChatContext\n * typing is desired while using the HOC withChatContext the Props for the\n * wrapped component must be provided as the first generic.\n */\nexport const withChatContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof ChatContextValue<StreamChatGenerics>>> => {\n const WithChatContextComponent = (props: Omit<P, keyof ChatContextValue<StreamChatGenerics>>) => {\n const chatContext = useChatContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...chatContext} />;\n };\n WithChatContextComponent.displayName = `WithChatContext${getDisplayName(Component)}`;\n return WithChatContextComponent;\n};\n"]}
1
+ {"version":3,"sources":["ChatContext.tsx"],"names":["ChatContext","React","createContext","ChatProvider","children","value","useChatContext","withChatContext","Component","WithChatContextComponent","props","chatContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAKA;;;;;;;;;AAmDO,IAAMA,WAAW,GAAGC,kBAAMC,aAAN,CAAoB,EAApB,CAApB;;;;AAEA,IAAMC,YAAY,GAAG,SAAfA,YAAe;AAAA,MAG1BC,QAH0B,QAG1BA,QAH0B;AAAA,MAI1BC,KAJ0B,QAI1BA,KAJ0B;AAAA,SAQ1B,gCAAC,WAAD,CAAa,QAAb;AAAsB,IAAA,KAAK,EAAEA,KAA7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACGD,QADH,CAR0B;AAAA,CAArB;;;;AAaA,IAAME,cAAc,GAAG,SAAjBA,cAAiB;AAAA,SAEvB,uBAAWN,WAAX,CAFuB;AAAA,CAAvB;;;;AASA,IAAMO,eAAe,GAAG,SAAlBA,eAAkB,CAI7BC,SAJ6B,EAKqC;AAClE,MAAMC,wBAAwB,GAAG,SAA3BA,wBAA2B,CAACC,KAAD,EAAgE;AAC/F,QAAMC,WAAW,GAAGL,cAAc,EAAlC;AAEA,WAAO,gCAAC,SAAD,gCAAgBI,KAAhB,EAAiCC,WAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAP;AACD,GAJD;;AAKAF,EAAAA,wBAAwB,CAACG,WAAzB,uBAAyD,oCAAeJ,SAAf,CAAzD;AACA,SAAOC,wBAAP;AACD,CAbM","sourcesContent":["import React, { PropsWithChildren, useContext } from 'react';\n\nimport type { Channel, Mute, StreamChat } from 'stream-chat';\n\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { getDisplayName } from '../utils/getDisplayName';\n\nexport type ChatContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n /**\n * The StreamChat client object\n *\n * ```\n * import { StreamChat } from 'stream-chat';\n * import { Chat } from 'stream-chat-react-native';\n *\n * const client = StreamChat.getInstance('api_key);\n * await client.connectUser('user_id', 'userToken');\n *\n * <Chat client={client}>\n * </Chat>\n * ```\n *\n * @overrideType StreamChat\n * */\n client: StreamChat<StreamChatGenerics>;\n connectionRecovering: boolean;\n isOnline: boolean;\n mutedUsers: Mute<StreamChatGenerics>[];\n /**\n * @param newChannel Channel to set as active.\n *\n * @overrideType Function\n */\n setActiveChannel: (newChannel?: Channel<StreamChatGenerics>) => void;\n /**\n * Instance of channel object from stream-chat package.\n *\n * Please check the docs around how to create or query channel - https://getstream.io/chat/docs/javascript/creating_channels/?language=javascript\n *\n * ```\n * import { StreamChat, Channel } from 'stream-chat';\n * import { Chat, Channel} from 'stream-chat-react-native';\n *\n * const client = StreamChat.getInstance('api_key');\n * await client.connectUser('user_id', 'user_token');\n * const channel = client.channel('messaging', 'channel_id');\n * await channel.watch();\n * ```\n *\n * @overrideType Channel\n */\n channel?: Channel<StreamChatGenerics>;\n};\n\nexport const ChatContext = React.createContext({} as ChatContextValue);\n\nexport const ChatProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n value,\n}: PropsWithChildren<{\n value: ChatContextValue<StreamChatGenerics>;\n}>) => (\n <ChatContext.Provider value={value as unknown as ChatContextValue}>\n {children}\n </ChatContext.Provider>\n);\n\nexport const useChatContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => useContext(ChatContext) as unknown as ChatContextValue<StreamChatGenerics>;\n\n/**\n * Typescript currently does not support partial inference so if ChatContext\n * typing is desired while using the HOC withChatContext the Props for the\n * wrapped component must be provided as the first generic.\n */\nexport const withChatContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof ChatContextValue<StreamChatGenerics>>> => {\n const WithChatContextComponent = (props: Omit<P, keyof ChatContextValue<StreamChatGenerics>>) => {\n const chatContext = useChatContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...chatContext} />;\n };\n WithChatContextComponent.displayName = `WithChatContext${getDisplayName(Component)}`;\n return WithChatContextComponent;\n};\n"]}
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "4.3.1-beta.2"
2
+ "version": "4.3.1"
3
3
  }
@@ -17,8 +17,6 @@ var _reactNative = require("react-native");
17
17
 
18
18
  var _dayjs = _interopRequireDefault(require("dayjs"));
19
19
 
20
- var _useAppSettings = require("./hooks/useAppSettings");
21
-
22
20
  var _useCreateChatContext = require("./hooks/useCreateChatContext");
23
21
 
24
22
  var _useIsOnline2 = require("./hooks/useIsOnline");
@@ -96,9 +94,7 @@ var ChatWithContext = function ChatWithContext(props) {
96
94
  return setChannel(newChannel);
97
95
  };
98
96
 
99
- var appSettings = (0, _useAppSettings.useAppSettings)(client, isOnline);
100
97
  var chatContext = (0, _useCreateChatContext.useCreateChatContext)({
101
- appSettings: appSettings,
102
98
  channel: channel,
103
99
  client: client,
104
100
  connectionRecovering: connectionRecovering,
@@ -112,7 +108,7 @@ var ChatWithContext = function ChatWithContext(props) {
112
108
  __self: _this,
113
109
  __source: {
114
110
  fileName: _jsxFileName,
115
- lineNumber: 180,
111
+ lineNumber: 176,
116
112
  columnNumber: 5
117
113
  }
118
114
  }, _react["default"].createElement(_TranslationContext.TranslationProvider, {
@@ -120,7 +116,7 @@ var ChatWithContext = function ChatWithContext(props) {
120
116
  __self: _this,
121
117
  __source: {
122
118
  fileName: _jsxFileName,
123
- lineNumber: 181,
119
+ lineNumber: 177,
124
120
  columnNumber: 7
125
121
  }
126
122
  }, _react["default"].createElement(_ThemeContext.ThemeProvider, {
@@ -128,7 +124,7 @@ var ChatWithContext = function ChatWithContext(props) {
128
124
  __self: _this,
129
125
  __source: {
130
126
  fileName: _jsxFileName,
131
- lineNumber: 182,
127
+ lineNumber: 178,
132
128
  columnNumber: 9
133
129
  }
134
130
  }, children)));
@@ -144,7 +140,7 @@ var Chat = function Chat(props) {
144
140
  __self: _this,
145
141
  __source: {
146
142
  fileName: _jsxFileName,
147
- lineNumber: 216,
143
+ lineNumber: 212,
148
144
  columnNumber: 10
149
145
  }
150
146
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["Chat.tsx"],"names":["ChatWithContext","props","children","client","closeConnectionOnBackground","i18nInstance","style","channel","setChannel","t","key","tDateTimeParser","input","translators","setTranslators","loadingTranslators","connectionRecovering","isOnline","mutedUsers","setUserAgent","SDK","Platform","OS","version","recoverStateOnReconnect","setActiveChannel","newChannel","appSettings","chatContext","Chat"],"mappings":"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","sourcesContent":["import React, { PropsWithChildren, useEffect, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport Dayjs from 'dayjs';\n\nimport type { Channel } 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 { ChatContextValue, ChatProvider } from '../../contexts/chatContext/ChatContext';\nimport { useOverlayContext } from '../../contexts/overlayContext/OverlayContext';\nimport { DeepPartial, ThemeProvider } from '../../contexts/themeContext/ThemeContext';\nimport type { Theme } from '../../contexts/themeContext/utils/theme';\nimport {\n TranslationContextValue,\n TranslationProvider,\n} from '../../contexts/translationContext/TranslationContext';\nimport { useStreami18n } from '../../hooks/useStreami18n';\nimport init from '../../init';\n\nimport { SDK } from '../../native';\nimport type { DefaultStreamChatGenerics } from '../../types/types';\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 /**\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 * 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/master/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 { children, client, closeConnectionOnBackground = true, i18nInstance, style } = props;\n\n const [channel, setChannel] = useState<Channel<StreamChatGenerics>>();\n const [translators, setTranslators] = useState<TranslationContextValue>({\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 /**\n * Setup muted user listener\n */\n const mutedUsers = useMutedUsers<StreamChatGenerics>(client);\n\n useEffect(() => {\n if (client.setUserAgent) {\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 }\n }, []);\n\n const setActiveChannel = (newChannel?: Channel<StreamChatGenerics>) => setChannel(newChannel);\n\n const appSettings = useAppSettings(client, isOnline);\n\n const chatContext = useCreateChatContext({\n appSettings,\n channel,\n client,\n connectionRecovering,\n isOnline,\n mutedUsers,\n setActiveChannel,\n });\n\n if (loadingTranslators) return null;\n\n return (\n <ChatProvider<StreamChatGenerics> value={chatContext}>\n <TranslationProvider value={translators}>\n <ThemeProvider style={style}>{children}</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"]}
1
+ {"version":3,"sources":["Chat.tsx"],"names":["ChatWithContext","props","children","client","closeConnectionOnBackground","i18nInstance","style","channel","setChannel","t","key","tDateTimeParser","input","translators","setTranslators","loadingTranslators","connectionRecovering","isOnline","mutedUsers","setUserAgent","SDK","Platform","OS","version","recoverStateOnReconnect","setActiveChannel","newChannel","chatContext","Chat"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AAIA;;AACA;;AAEA;;AAGA;;;;;;;;;AAEA;;AA+FA,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAGtBC,KAHsB,EAInB;AACH,MAAQC,QAAR,GAAsFD,KAAtF,CAAQC,QAAR;AAAA,MAAkBC,MAAlB,GAAsFF,KAAtF,CAAkBE,MAAlB;AAAA,8BAAsFF,KAAtF,CAA0BG,2BAA1B;AAAA,MAA0BA,2BAA1B,sCAAwD,IAAxD;AAAA,MAA8DC,YAA9D,GAAsFJ,KAAtF,CAA8DI,YAA9D;AAAA,MAA4EC,KAA5E,GAAsFL,KAAtF,CAA4EK,KAA5E;;AAEA,kBAA8B,sBAA9B;AAAA;AAAA,MAAOC,OAAP;AAAA,MAAgBC,UAAhB;;AACA,mBAAsC,qBAAkC;AACtEC,IAAAA,CAAC,EAAE,WAACC,GAAD;AAAA,aAAiBA,GAAjB;AAAA,KADmE;AAEtEC,IAAAA,eAAe,EAAE,yBAACC,KAAD;AAAA,aAAoC,uBAAMA,KAAN,CAApC;AAAA;AAFqD,GAAlC,CAAtC;AAAA;AAAA,MAAOC,WAAP;AAAA,MAAoBC,cAApB;;AAQA,MAAMC,kBAAkB,GAAG,kCAAc;AAAEV,IAAAA,YAAY,EAAZA,YAAF;AAAgBS,IAAAA,cAAc,EAAdA;AAAhB,GAAd,CAA3B;;AAKA,qBAA2C,+BACzCX,MADyC,EAEzCC,2BAFyC,CAA3C;AAAA,MAAQY,oBAAR,gBAAQA,oBAAR;AAAA,MAA8BC,QAA9B,gBAA8BA,QAA9B;;AAQA,MAAMC,UAAU,GAAG,kCAAkCf,MAAlC,CAAnB;AAEA,wBAAU,YAAM;AACd,QAAIA,MAAM,CAACgB,YAAX,EAAyB;AACvBhB,MAAAA,MAAM,CAACgB,YAAP,CAAuBC,WAAvB,SAA8BC,sBAASC,EAAvC,SAA6CC,gBAA7C;AAEApB,MAAAA,MAAM,CAACqB,uBAAP,GAAiC,KAAjC;AACD;AACF,GAND,EAMG,EANH;;AAQA,MAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,UAAD;AAAA,WAA8ClB,UAAU,CAACkB,UAAD,CAAxD;AAAA,GAAzB;;AAEA,MAAMC,WAAW,GAAG,gDAAqB;AACvCpB,IAAAA,OAAO,EAAPA,OADuC;AAEvCJ,IAAAA,MAAM,EAANA,MAFuC;AAGvCa,IAAAA,oBAAoB,EAApBA,oBAHuC;AAIvCC,IAAAA,QAAQ,EAARA,QAJuC;AAKvCC,IAAAA,UAAU,EAAVA,UALuC;AAMvCO,IAAAA,gBAAgB,EAAhBA;AANuC,GAArB,CAApB;AASA,MAAIV,kBAAJ,EAAwB,OAAO,IAAP;AAExB,SACE,gCAAC,yBAAD;AAAkC,IAAA,KAAK,EAAEY,WAAzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACE,gCAAC,uCAAD;AAAqB,IAAA,KAAK,EAAEd,WAA5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACE,gCAAC,2BAAD;AAAe,IAAA,KAAK,EAAEP,KAAtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAA8BJ,QAA9B,CADF,CADF,CADF;AAOD,CA3DD;;AAkFO,IAAM0B,IAAI,GAAG,SAAPA,IAAO,CAGlB3B,KAHkB,EAIf;AACH,2BAAkB,wCAAlB;AAAA,MAAQK,KAAR,sBAAQA,KAAR;;AAEA,SAAO,gCAAC,eAAD;AAAuBA,IAAAA,KAAK,EAALA;AAAvB,KAAoCL,KAApC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAP;AACD,CARM","sourcesContent":["import React, { PropsWithChildren, useEffect, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport Dayjs from 'dayjs';\n\nimport type { Channel } from 'stream-chat';\n\nimport { useCreateChatContext } from './hooks/useCreateChatContext';\nimport { useIsOnline } from './hooks/useIsOnline';\nimport { useMutedUsers } from './hooks/useMutedUsers';\n\nimport { ChatContextValue, ChatProvider } from '../../contexts/chatContext/ChatContext';\nimport { useOverlayContext } from '../../contexts/overlayContext/OverlayContext';\nimport { DeepPartial, ThemeProvider } from '../../contexts/themeContext/ThemeContext';\nimport type { Theme } from '../../contexts/themeContext/utils/theme';\nimport {\n TranslationContextValue,\n TranslationProvider,\n} from '../../contexts/translationContext/TranslationContext';\nimport { useStreami18n } from '../../hooks/useStreami18n';\nimport init from '../../init';\n\nimport { SDK } from '../../native';\nimport type { DefaultStreamChatGenerics } from '../../types/types';\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 /**\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 * 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/master/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 { children, client, closeConnectionOnBackground = true, i18nInstance, style } = props;\n\n const [channel, setChannel] = useState<Channel<StreamChatGenerics>>();\n const [translators, setTranslators] = useState<TranslationContextValue>({\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 /**\n * Setup muted user listener\n */\n const mutedUsers = useMutedUsers<StreamChatGenerics>(client);\n\n useEffect(() => {\n if (client.setUserAgent) {\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 }\n }, []);\n\n const setActiveChannel = (newChannel?: Channel<StreamChatGenerics>) => setChannel(newChannel);\n\n const chatContext = useCreateChatContext({\n channel,\n client,\n connectionRecovering,\n isOnline,\n mutedUsers,\n setActiveChannel,\n });\n\n if (loadingTranslators) return null;\n\n return (\n <ChatProvider<StreamChatGenerics> value={chatContext}>\n <TranslationProvider value={translators}>\n <ThemeProvider style={style}>{children}</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"]}
@@ -6,8 +6,7 @@ exports.useCreateChatContext = void 0;
6
6
  var _react = require("react");
7
7
 
8
8
  var useCreateChatContext = function useCreateChatContext(_ref) {
9
- var appSettings = _ref.appSettings,
10
- channel = _ref.channel,
9
+ var channel = _ref.channel,
11
10
  client = _ref.client,
12
11
  connectionRecovering = _ref.connectionRecovering,
13
12
  isOnline = _ref.isOnline,
@@ -18,7 +17,6 @@ var useCreateChatContext = function useCreateChatContext(_ref) {
18
17
  var mutedUsersLength = mutedUsers.length;
19
18
  var chatContext = (0, _react.useMemo)(function () {
20
19
  return {
21
- appSettings: appSettings,
22
20
  channel: channel,
23
21
  client: client,
24
22
  connectionRecovering: connectionRecovering,
@@ -1 +1 @@
1
- {"version":3,"sources":["useCreateChatContext.ts"],"names":["useCreateChatContext","appSettings","channel","client","connectionRecovering","isOnline","mutedUsers","setActiveChannel","channelId","id","clientValues","clientID","Object","keys","activeChannels","length","listeners","mutedChannels","mutedUsersLength","chatContext"],"mappings":";;;;;AAAA;;AAKO,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB,OAUQ;AAAA,MAP1CC,WAO0C,QAP1CA,WAO0C;AAAA,MAN1CC,OAM0C,QAN1CA,OAM0C;AAAA,MAL1CC,MAK0C,QAL1CA,MAK0C;AAAA,MAJ1CC,oBAI0C,QAJ1CA,oBAI0C;AAAA,MAH1CC,QAG0C,QAH1CA,QAG0C;AAAA,MAF1CC,UAE0C,QAF1CA,UAE0C;AAAA,MAD1CC,gBAC0C,QAD1CA,gBAC0C;AAC1C,MAAMC,SAAS,GAAGN,OAAH,oBAAGA,OAAO,CAAEO,EAA3B;AACA,MAAMC,YAAY,QAAMP,MAAM,CAACQ,QAAb,GAAwBC,MAAM,CAACC,IAAP,CAAYV,MAAM,CAACW,cAAnB,EAAmCC,MAA3D,GAChBH,MAAM,CAACC,IAAP,CAAYV,MAAM,CAACa,SAAnB,EAA8BD,MADd,GAEfZ,MAAM,CAACc,aAAP,CAAqBF,MAFxB;AAGA,MAAMG,gBAAgB,GAAGZ,UAAU,CAACS,MAApC;AAEA,MAAMI,WAAiD,GAAG,oBACxD;AAAA,WAAO;AACLlB,MAAAA,WAAW,EAAXA,WADK;AAELC,MAAAA,OAAO,EAAPA,OAFK;AAGLC,MAAAA,MAAM,EAANA,MAHK;AAILC,MAAAA,oBAAoB,EAApBA,oBAJK;AAKLC,MAAAA,QAAQ,EAARA,QALK;AAMLC,MAAAA,UAAU,EAAVA,UANK;AAOLC,MAAAA,gBAAgB,EAAhBA;AAPK,KAAP;AAAA,GADwD,EAUxD,CAACC,SAAD,EAAYE,YAAZ,EAA0BN,oBAA1B,EAAgDC,QAAhD,EAA0Da,gBAA1D,CAVwD,CAA1D;AAaA,SAAOC,WAAP;AACD,CA/BM","sourcesContent":["import { useMemo } from 'react';\n\nimport type { ChatContextValue } from '../../../contexts/chatContext/ChatContext';\nimport type { DefaultStreamChatGenerics } from '../../../types/types';\n\nexport const useCreateChatContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n appSettings,\n channel,\n client,\n connectionRecovering,\n isOnline,\n mutedUsers,\n setActiveChannel,\n}: ChatContextValue<StreamChatGenerics>) => {\n const channelId = channel?.id;\n const clientValues = `${client.clientID}${Object.keys(client.activeChannels).length}${\n Object.keys(client.listeners).length\n }${client.mutedChannels.length}`;\n const mutedUsersLength = mutedUsers.length;\n\n const chatContext: ChatContextValue<StreamChatGenerics> = useMemo(\n () => ({\n appSettings,\n channel,\n client,\n connectionRecovering,\n isOnline,\n mutedUsers,\n setActiveChannel,\n }),\n [channelId, clientValues, connectionRecovering, isOnline, mutedUsersLength],\n );\n\n return chatContext;\n};\n"]}
1
+ {"version":3,"sources":["useCreateChatContext.ts"],"names":["useCreateChatContext","channel","client","connectionRecovering","isOnline","mutedUsers","setActiveChannel","channelId","id","clientValues","clientID","Object","keys","activeChannels","length","listeners","mutedChannels","mutedUsersLength","chatContext"],"mappings":";;;;;AAAA;;AAKO,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB,OASQ;AAAA,MAN1CC,OAM0C,QAN1CA,OAM0C;AAAA,MAL1CC,MAK0C,QAL1CA,MAK0C;AAAA,MAJ1CC,oBAI0C,QAJ1CA,oBAI0C;AAAA,MAH1CC,QAG0C,QAH1CA,QAG0C;AAAA,MAF1CC,UAE0C,QAF1CA,UAE0C;AAAA,MAD1CC,gBAC0C,QAD1CA,gBAC0C;AAC1C,MAAMC,SAAS,GAAGN,OAAH,oBAAGA,OAAO,CAAEO,EAA3B;AACA,MAAMC,YAAY,QAAMP,MAAM,CAACQ,QAAb,GAAwBC,MAAM,CAACC,IAAP,CAAYV,MAAM,CAACW,cAAnB,EAAmCC,MAA3D,GAChBH,MAAM,CAACC,IAAP,CAAYV,MAAM,CAACa,SAAnB,EAA8BD,MADd,GAEfZ,MAAM,CAACc,aAAP,CAAqBF,MAFxB;AAGA,MAAMG,gBAAgB,GAAGZ,UAAU,CAACS,MAApC;AAEA,MAAMI,WAAiD,GAAG,oBACxD;AAAA,WAAO;AACLjB,MAAAA,OAAO,EAAPA,OADK;AAELC,MAAAA,MAAM,EAANA,MAFK;AAGLC,MAAAA,oBAAoB,EAApBA,oBAHK;AAILC,MAAAA,QAAQ,EAARA,QAJK;AAKLC,MAAAA,UAAU,EAAVA,UALK;AAMLC,MAAAA,gBAAgB,EAAhBA;AANK,KAAP;AAAA,GADwD,EASxD,CAACC,SAAD,EAAYE,YAAZ,EAA0BN,oBAA1B,EAAgDC,QAAhD,EAA0Da,gBAA1D,CATwD,CAA1D;AAYA,SAAOC,WAAP;AACD,CA7BM","sourcesContent":["import { useMemo } from 'react';\n\nimport type { ChatContextValue } from '../../../contexts/chatContext/ChatContext';\nimport type { DefaultStreamChatGenerics } from '../../../types/types';\n\nexport const useCreateChatContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n channel,\n client,\n connectionRecovering,\n isOnline,\n mutedUsers,\n setActiveChannel,\n}: ChatContextValue<StreamChatGenerics>) => {\n const channelId = channel?.id;\n const clientValues = `${client.clientID}${Object.keys(client.activeChannels).length}${\n Object.keys(client.listeners).length\n }${client.mutedChannels.length}`;\n const mutedUsersLength = mutedUsers.length;\n\n const chatContext: ChatContextValue<StreamChatGenerics> = useMemo(\n () => ({\n channel,\n client,\n connectionRecovering,\n isOnline,\n mutedUsers,\n setActiveChannel,\n }),\n [channelId, clientValues, connectionRecovering, isOnline, mutedUsersLength],\n );\n\n return chatContext;\n};\n"]}
@@ -32,7 +32,7 @@ var ChatProvider = function ChatProvider(_ref) {
32
32
  __self: _this,
33
33
  __source: {
34
34
  fileName: _jsxFileName,
35
- lineNumber: 71,
35
+ lineNumber: 67,
36
36
  columnNumber: 3
37
37
  }
38
38
  }, children);
@@ -53,7 +53,7 @@ var withChatContext = function withChatContext(Component) {
53
53
  __self: _this,
54
54
  __source: {
55
55
  fileName: _jsxFileName,
56
- lineNumber: 94,
56
+ lineNumber: 90,
57
57
  columnNumber: 12
58
58
  }
59
59
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["ChatContext.tsx"],"names":["ChatContext","React","createContext","ChatProvider","children","value","useChatContext","withChatContext","Component","WithChatContextComponent","props","chatContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAKA;;;;;;;;;AAuDO,IAAMA,WAAW,GAAGC,kBAAMC,aAAN,CAAoB,EAApB,CAApB;;;;AAEA,IAAMC,YAAY,GAAG,SAAfA,YAAe;AAAA,MAG1BC,QAH0B,QAG1BA,QAH0B;AAAA,MAI1BC,KAJ0B,QAI1BA,KAJ0B;AAAA,SAQ1B,gCAAC,WAAD,CAAa,QAAb;AAAsB,IAAA,KAAK,EAAEA,KAA7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACGD,QADH,CAR0B;AAAA,CAArB;;;;AAaA,IAAME,cAAc,GAAG,SAAjBA,cAAiB;AAAA,SAEvB,uBAAWN,WAAX,CAFuB;AAAA,CAAvB;;;;AASA,IAAMO,eAAe,GAAG,SAAlBA,eAAkB,CAI7BC,SAJ6B,EAKqC;AAClE,MAAMC,wBAAwB,GAAG,SAA3BA,wBAA2B,CAACC,KAAD,EAAgE;AAC/F,QAAMC,WAAW,GAAGL,cAAc,EAAlC;AAEA,WAAO,gCAAC,SAAD,gCAAgBI,KAAhB,EAAiCC,WAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAP;AACD,GAJD;;AAKAF,EAAAA,wBAAwB,CAACG,WAAzB,uBAAyD,oCAAeJ,SAAf,CAAzD;AACA,SAAOC,wBAAP;AACD,CAbM","sourcesContent":["import React, { PropsWithChildren, useContext } from 'react';\n\nimport type { AppSettingsAPIResponse, Channel, Mute, StreamChat } from 'stream-chat';\n\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { getDisplayName } from '../utils/getDisplayName';\n\nexport type ChatContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n /**\n * Object of application settings returned from Stream.\n * */\n appSettings: AppSettingsAPIResponse<StreamChatGenerics> | null;\n /**\n * The StreamChat client object\n *\n * ```\n * import { StreamChat } from 'stream-chat';\n * import { Chat } from 'stream-chat-react-native';\n *\n * const client = StreamChat.getInstance('api_key);\n * await client.connectUser('user_id', 'userToken');\n *\n * <Chat client={client}>\n * </Chat>\n * ```\n *\n * @overrideType StreamChat\n * */\n client: StreamChat<StreamChatGenerics>;\n connectionRecovering: boolean;\n isOnline: boolean;\n mutedUsers: Mute<StreamChatGenerics>[];\n /**\n * @param newChannel Channel to set as active.\n *\n * @overrideType Function\n */\n setActiveChannel: (newChannel?: Channel<StreamChatGenerics>) => void;\n /**\n * Instance of channel object from stream-chat package.\n *\n * Please check the docs around how to create or query channel - https://getstream.io/chat/docs/javascript/creating_channels/?language=javascript\n *\n * ```\n * import { StreamChat, Channel } from 'stream-chat';\n * import { Chat, Channel} from 'stream-chat-react-native';\n *\n * const client = StreamChat.getInstance('api_key');\n * await client.connectUser('user_id', 'user_token');\n * const channel = client.channel('messaging', 'channel_id');\n * await channel.watch();\n * ```\n *\n * @overrideType Channel\n */\n channel?: Channel<StreamChatGenerics>;\n};\n\nexport const ChatContext = React.createContext({} as ChatContextValue);\n\nexport const ChatProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n value,\n}: PropsWithChildren<{\n value: ChatContextValue<StreamChatGenerics>;\n}>) => (\n <ChatContext.Provider value={value as unknown as ChatContextValue}>\n {children}\n </ChatContext.Provider>\n);\n\nexport const useChatContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => useContext(ChatContext) as unknown as ChatContextValue<StreamChatGenerics>;\n\n/**\n * Typescript currently does not support partial inference so if ChatContext\n * typing is desired while using the HOC withChatContext the Props for the\n * wrapped component must be provided as the first generic.\n */\nexport const withChatContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof ChatContextValue<StreamChatGenerics>>> => {\n const WithChatContextComponent = (props: Omit<P, keyof ChatContextValue<StreamChatGenerics>>) => {\n const chatContext = useChatContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...chatContext} />;\n };\n WithChatContextComponent.displayName = `WithChatContext${getDisplayName(Component)}`;\n return WithChatContextComponent;\n};\n"]}
1
+ {"version":3,"sources":["ChatContext.tsx"],"names":["ChatContext","React","createContext","ChatProvider","children","value","useChatContext","withChatContext","Component","WithChatContextComponent","props","chatContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAKA;;;;;;;;;AAmDO,IAAMA,WAAW,GAAGC,kBAAMC,aAAN,CAAoB,EAApB,CAApB;;;;AAEA,IAAMC,YAAY,GAAG,SAAfA,YAAe;AAAA,MAG1BC,QAH0B,QAG1BA,QAH0B;AAAA,MAI1BC,KAJ0B,QAI1BA,KAJ0B;AAAA,SAQ1B,gCAAC,WAAD,CAAa,QAAb;AAAsB,IAAA,KAAK,EAAEA,KAA7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACGD,QADH,CAR0B;AAAA,CAArB;;;;AAaA,IAAME,cAAc,GAAG,SAAjBA,cAAiB;AAAA,SAEvB,uBAAWN,WAAX,CAFuB;AAAA,CAAvB;;;;AASA,IAAMO,eAAe,GAAG,SAAlBA,eAAkB,CAI7BC,SAJ6B,EAKqC;AAClE,MAAMC,wBAAwB,GAAG,SAA3BA,wBAA2B,CAACC,KAAD,EAAgE;AAC/F,QAAMC,WAAW,GAAGL,cAAc,EAAlC;AAEA,WAAO,gCAAC,SAAD,gCAAgBI,KAAhB,EAAiCC,WAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAP;AACD,GAJD;;AAKAF,EAAAA,wBAAwB,CAACG,WAAzB,uBAAyD,oCAAeJ,SAAf,CAAzD;AACA,SAAOC,wBAAP;AACD,CAbM","sourcesContent":["import React, { PropsWithChildren, useContext } from 'react';\n\nimport type { Channel, Mute, StreamChat } from 'stream-chat';\n\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { getDisplayName } from '../utils/getDisplayName';\n\nexport type ChatContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n /**\n * The StreamChat client object\n *\n * ```\n * import { StreamChat } from 'stream-chat';\n * import { Chat } from 'stream-chat-react-native';\n *\n * const client = StreamChat.getInstance('api_key);\n * await client.connectUser('user_id', 'userToken');\n *\n * <Chat client={client}>\n * </Chat>\n * ```\n *\n * @overrideType StreamChat\n * */\n client: StreamChat<StreamChatGenerics>;\n connectionRecovering: boolean;\n isOnline: boolean;\n mutedUsers: Mute<StreamChatGenerics>[];\n /**\n * @param newChannel Channel to set as active.\n *\n * @overrideType Function\n */\n setActiveChannel: (newChannel?: Channel<StreamChatGenerics>) => void;\n /**\n * Instance of channel object from stream-chat package.\n *\n * Please check the docs around how to create or query channel - https://getstream.io/chat/docs/javascript/creating_channels/?language=javascript\n *\n * ```\n * import { StreamChat, Channel } from 'stream-chat';\n * import { Chat, Channel} from 'stream-chat-react-native';\n *\n * const client = StreamChat.getInstance('api_key');\n * await client.connectUser('user_id', 'user_token');\n * const channel = client.channel('messaging', 'channel_id');\n * await channel.watch();\n * ```\n *\n * @overrideType Channel\n */\n channel?: Channel<StreamChatGenerics>;\n};\n\nexport const ChatContext = React.createContext({} as ChatContextValue);\n\nexport const ChatProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n value,\n}: PropsWithChildren<{\n value: ChatContextValue<StreamChatGenerics>;\n}>) => (\n <ChatContext.Provider value={value as unknown as ChatContextValue}>\n {children}\n </ChatContext.Provider>\n);\n\nexport const useChatContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => useContext(ChatContext) as unknown as ChatContextValue<StreamChatGenerics>;\n\n/**\n * Typescript currently does not support partial inference so if ChatContext\n * typing is desired while using the HOC withChatContext the Props for the\n * wrapped component must be provided as the first generic.\n */\nexport const withChatContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof ChatContextValue<StreamChatGenerics>>> => {\n const WithChatContextComponent = (props: Omit<P, keyof ChatContextValue<StreamChatGenerics>>) => {\n const chatContext = useChatContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...chatContext} />;\n };\n WithChatContextComponent.displayName = `WithChatContext${getDisplayName(Component)}`;\n return WithChatContextComponent;\n};\n"]}
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "4.3.1-beta.2"
2
+ "version": "4.3.1"
3
3
  }
@@ -1,3 +1,3 @@
1
1
  import type { ChatContextValue } from '../../../contexts/chatContext/ChatContext';
2
2
  import type { DefaultStreamChatGenerics } from '../../../types/types';
3
- export declare const useCreateChatContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ appSettings, channel, client, connectionRecovering, isOnline, mutedUsers, setActiveChannel, }: ChatContextValue<StreamChatGenerics>) => ChatContextValue<StreamChatGenerics>;
3
+ export declare const useCreateChatContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ channel, client, connectionRecovering, isOnline, mutedUsers, setActiveChannel, }: ChatContextValue<StreamChatGenerics>) => ChatContextValue<StreamChatGenerics>;
@@ -1,11 +1,7 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
- import type { AppSettingsAPIResponse, Channel, Mute, StreamChat } from 'stream-chat';
2
+ import type { Channel, Mute, StreamChat } from 'stream-chat';
3
3
  import type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';
4
4
  export declare type ChatContextValue<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
5
- /**
6
- * Object of application settings returned from Stream.
7
- * */
8
- appSettings: AppSettingsAPIResponse<StreamChatGenerics> | null;
9
5
  /**
10
6
  * The StreamChat client object
11
7
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stream-chat-react-native-core",
3
3
  "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
4
- "version": "4.3.1-beta.2",
4
+ "version": "4.3.1",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -55,7 +55,6 @@ describe('useChannelUpdated', () => {
55
55
  render(
56
56
  <ChatContext.Provider
57
57
  value={{
58
- appSettings: null,
59
58
  client: mockClient,
60
59
  connectionRecovering: false,
61
60
  isOnline: true,
@@ -5,7 +5,6 @@ import Dayjs from 'dayjs';
5
5
 
6
6
  import type { Channel } from 'stream-chat';
7
7
 
8
- import { useAppSettings } from './hooks/useAppSettings';
9
8
  import { useCreateChatContext } from './hooks/useCreateChatContext';
10
9
  import { useIsOnline } from './hooks/useIsOnline';
11
10
  import { useMutedUsers } from './hooks/useMutedUsers';
@@ -162,10 +161,7 @@ const ChatWithContext = <
162
161
 
163
162
  const setActiveChannel = (newChannel?: Channel<StreamChatGenerics>) => setChannel(newChannel);
164
163
 
165
- const appSettings = useAppSettings(client, isOnline);
166
-
167
164
  const chatContext = useCreateChatContext({
168
- appSettings,
169
165
  channel,
170
166
  client,
171
167
  connectionRecovering,
@@ -6,7 +6,6 @@ import type { DefaultStreamChatGenerics } from '../../../types/types';
6
6
  export const useCreateChatContext = <
7
7
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
8
8
  >({
9
- appSettings,
10
9
  channel,
11
10
  client,
12
11
  connectionRecovering,
@@ -22,7 +21,6 @@ export const useCreateChatContext = <
22
21
 
23
22
  const chatContext: ChatContextValue<StreamChatGenerics> = useMemo(
24
23
  () => ({
25
- appSettings,
26
24
  channel,
27
25
  client,
28
26
  connectionRecovering,
@@ -1,6 +1,6 @@
1
1
  import React, { PropsWithChildren, useContext } from 'react';
2
2
 
3
- import type { AppSettingsAPIResponse, Channel, Mute, StreamChat } from 'stream-chat';
3
+ import type { Channel, Mute, StreamChat } from 'stream-chat';
4
4
 
5
5
  import type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';
6
6
  import { getDisplayName } from '../utils/getDisplayName';
@@ -8,10 +8,6 @@ import { getDisplayName } from '../utils/getDisplayName';
8
8
  export type ChatContextValue<
9
9
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
10
10
  > = {
11
- /**
12
- * Object of application settings returned from Stream.
13
- * */
14
- appSettings: AppSettingsAPIResponse<StreamChatGenerics> | null;
15
11
  /**
16
12
  * The StreamChat client object
17
13
  *
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "4.3.1-beta.2"
2
+ "version": "4.3.1"
3
3
  }
@@ -1,80 +0,0 @@
1
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useAppSettings = void 0;
7
-
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
-
10
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
-
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
- var _react = require("react");
15
-
16
- var useAppSettings = function useAppSettings(client, isOnline) {
17
- var _useState = (0, _react.useState)(null),
18
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
19
- appSettings = _useState2[0],
20
- setAppSettings = _useState2[1];
21
-
22
- var isMounted = (0, _react.useRef)(true);
23
- (0, _react.useEffect)(function () {
24
- function getAppSettings() {
25
- return _getAppSettings.apply(this, arguments);
26
- }
27
-
28
- function _getAppSettings() {
29
- _getAppSettings = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee() {
30
- var _appSettings;
31
-
32
- return _regenerator["default"].wrap(function _callee$(_context) {
33
- while (1) {
34
- switch (_context.prev = _context.next) {
35
- case 0:
36
- _context.prev = 0;
37
- _context.next = 3;
38
- return client.getAppSettings();
39
-
40
- case 3:
41
- _appSettings = _context.sent;
42
-
43
- if (isMounted.current) {
44
- setAppSettings(_appSettings);
45
- }
46
-
47
- _context.next = 10;
48
- break;
49
-
50
- case 7:
51
- _context.prev = 7;
52
- _context.t0 = _context["catch"](0);
53
-
54
- if (_context.t0 instanceof Error) {
55
- console.error("An error occurred while getting app settings: " + _context.t0);
56
- }
57
-
58
- case 10:
59
- case "end":
60
- return _context.stop();
61
- }
62
- }
63
- }, _callee, null, [[0, 7]]);
64
- }));
65
- return _getAppSettings.apply(this, arguments);
66
- }
67
-
68
- if (isOnline) {
69
- getAppSettings();
70
- }
71
-
72
- return function () {
73
- isMounted.current = false;
74
- };
75
- }, [client, isOnline]);
76
- return appSettings;
77
- };
78
-
79
- exports.useAppSettings = useAppSettings;
80
- //# sourceMappingURL=useAppSettings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["useAppSettings.ts"],"names":["useAppSettings","client","isOnline","appSettings","setAppSettings","isMounted","getAppSettings","current","Error","console","error"],"mappings":";;;;;;;;;;;;;AAAA;;AAKO,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,CAG5BC,MAH4B,EAI5BC,QAJ4B,EAKM;AAClC,kBAAsC,qBAAwC,IAAxC,CAAtC;AAAA;AAAA,MAAOC,WAAP;AAAA,MAAoBC,cAApB;;AACA,MAAMC,SAAS,GAAG,mBAAO,IAAP,CAAlB;AAEA,wBAAU,YAAM;AAAA,aACCC,cADD;AAAA;AAAA;;AAAA;AAAA,wFACd;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAE8BL,MAAM,CAACK,cAAP,EAF9B;;AAAA;AAEUH,gBAAAA,YAFV;;AAGI,oBAAIE,SAAS,CAACE,OAAd,EAAuB;AACrBH,kBAAAA,cAAc,CAACD,YAAD,CAAd;AACD;;AALL;AAAA;;AAAA;AAAA;AAAA;;AAOI,oBAAI,uBAAiBK,KAArB,EAA4B;AAC1BC,kBAAAA,OAAO,CAACC,KAAR;AACD;;AATL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OADc;AAAA;AAAA;;AAcd,QAAIR,QAAJ,EAAc;AACZI,MAAAA,cAAc;AACf;;AAED,WAAO,YAAM;AACXD,MAAAA,SAAS,CAACE,OAAV,GAAoB,KAApB;AACD,KAFD;AAGD,GArBD,EAqBG,CAACN,MAAD,EAASC,QAAT,CArBH;AAuBA,SAAOC,WAAP;AACD,CAjCM","sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport type { AppSettingsAPIResponse, StreamChat } from 'stream-chat';\nimport type { DefaultStreamChatGenerics } from 'stream-chat-react-native';\n\nexport const useAppSettings = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n client: StreamChat<StreamChatGenerics>,\n isOnline: boolean,\n): AppSettingsAPIResponse | null => {\n const [appSettings, setAppSettings] = useState<AppSettingsAPIResponse | null>(null);\n const isMounted = useRef(true);\n\n useEffect(() => {\n async function getAppSettings() {\n try {\n const appSettings = await client.getAppSettings();\n if (isMounted.current) {\n setAppSettings(appSettings);\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 if (isOnline) {\n getAppSettings();\n }\n\n return () => {\n isMounted.current = false;\n };\n }, [client, isOnline]);\n\n return appSettings;\n};\n"]}
@@ -1,80 +0,0 @@
1
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useAppSettings = void 0;
7
-
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
-
10
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
-
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
- var _react = require("react");
15
-
16
- var useAppSettings = function useAppSettings(client, isOnline) {
17
- var _useState = (0, _react.useState)(null),
18
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
19
- appSettings = _useState2[0],
20
- setAppSettings = _useState2[1];
21
-
22
- var isMounted = (0, _react.useRef)(true);
23
- (0, _react.useEffect)(function () {
24
- function getAppSettings() {
25
- return _getAppSettings.apply(this, arguments);
26
- }
27
-
28
- function _getAppSettings() {
29
- _getAppSettings = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee() {
30
- var _appSettings;
31
-
32
- return _regenerator["default"].wrap(function _callee$(_context) {
33
- while (1) {
34
- switch (_context.prev = _context.next) {
35
- case 0:
36
- _context.prev = 0;
37
- _context.next = 3;
38
- return client.getAppSettings();
39
-
40
- case 3:
41
- _appSettings = _context.sent;
42
-
43
- if (isMounted.current) {
44
- setAppSettings(_appSettings);
45
- }
46
-
47
- _context.next = 10;
48
- break;
49
-
50
- case 7:
51
- _context.prev = 7;
52
- _context.t0 = _context["catch"](0);
53
-
54
- if (_context.t0 instanceof Error) {
55
- console.error("An error occurred while getting app settings: " + _context.t0);
56
- }
57
-
58
- case 10:
59
- case "end":
60
- return _context.stop();
61
- }
62
- }
63
- }, _callee, null, [[0, 7]]);
64
- }));
65
- return _getAppSettings.apply(this, arguments);
66
- }
67
-
68
- if (isOnline) {
69
- getAppSettings();
70
- }
71
-
72
- return function () {
73
- isMounted.current = false;
74
- };
75
- }, [client, isOnline]);
76
- return appSettings;
77
- };
78
-
79
- exports.useAppSettings = useAppSettings;
80
- //# sourceMappingURL=useAppSettings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["useAppSettings.ts"],"names":["useAppSettings","client","isOnline","appSettings","setAppSettings","isMounted","getAppSettings","current","Error","console","error"],"mappings":";;;;;;;;;;;;;AAAA;;AAKO,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,CAG5BC,MAH4B,EAI5BC,QAJ4B,EAKM;AAClC,kBAAsC,qBAAwC,IAAxC,CAAtC;AAAA;AAAA,MAAOC,WAAP;AAAA,MAAoBC,cAApB;;AACA,MAAMC,SAAS,GAAG,mBAAO,IAAP,CAAlB;AAEA,wBAAU,YAAM;AAAA,aACCC,cADD;AAAA;AAAA;;AAAA;AAAA,wFACd;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAE8BL,MAAM,CAACK,cAAP,EAF9B;;AAAA;AAEUH,gBAAAA,YAFV;;AAGI,oBAAIE,SAAS,CAACE,OAAd,EAAuB;AACrBH,kBAAAA,cAAc,CAACD,YAAD,CAAd;AACD;;AALL;AAAA;;AAAA;AAAA;AAAA;;AAOI,oBAAI,uBAAiBK,KAArB,EAA4B;AAC1BC,kBAAAA,OAAO,CAACC,KAAR;AACD;;AATL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OADc;AAAA;AAAA;;AAcd,QAAIR,QAAJ,EAAc;AACZI,MAAAA,cAAc;AACf;;AAED,WAAO,YAAM;AACXD,MAAAA,SAAS,CAACE,OAAV,GAAoB,KAApB;AACD,KAFD;AAGD,GArBD,EAqBG,CAACN,MAAD,EAASC,QAAT,CArBH;AAuBA,SAAOC,WAAP;AACD,CAjCM","sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport type { AppSettingsAPIResponse, StreamChat } from 'stream-chat';\nimport type { DefaultStreamChatGenerics } from 'stream-chat-react-native';\n\nexport const useAppSettings = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n client: StreamChat<StreamChatGenerics>,\n isOnline: boolean,\n): AppSettingsAPIResponse | null => {\n const [appSettings, setAppSettings] = useState<AppSettingsAPIResponse | null>(null);\n const isMounted = useRef(true);\n\n useEffect(() => {\n async function getAppSettings() {\n try {\n const appSettings = await client.getAppSettings();\n if (isMounted.current) {\n setAppSettings(appSettings);\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 if (isOnline) {\n getAppSettings();\n }\n\n return () => {\n isMounted.current = false;\n };\n }, [client, isOnline]);\n\n return appSettings;\n};\n"]}
@@ -1,3 +0,0 @@
1
- import type { AppSettingsAPIResponse, StreamChat } from 'stream-chat';
2
- import type { DefaultStreamChatGenerics } from 'stream-chat-react-native';
3
- export declare const useAppSettings: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(client: StreamChat<StreamChatGenerics>, isOnline: boolean) => AppSettingsAPIResponse | null;
@@ -1,34 +0,0 @@
1
- import React from 'react';
2
- import { Text } from 'react-native';
3
-
4
- import { render, waitFor } from '@testing-library/react-native';
5
-
6
- import type { StreamChat } from 'stream-chat';
7
-
8
- import { useAppSettings } from '../useAppSettings';
9
-
10
- describe('useAppSettings', () => {
11
- it('will return a settings object if the backend call is successful', async () => {
12
- const TestComponent = () => {
13
- const isOnline = true;
14
- const appSettings = useAppSettings(
15
- {
16
- getAppSettings: jest.fn().mockReturnValue(
17
- Promise.resolve({
18
- auto_translation_enabled: true,
19
- }),
20
- ),
21
- } as unknown as StreamChat,
22
- isOnline,
23
- );
24
-
25
- return <Text>{JSON.stringify(appSettings)}</Text>;
26
- };
27
-
28
- const { getByText } = render(<TestComponent />);
29
-
30
- await waitFor(() => {
31
- expect(getByText(JSON.stringify({ auto_translation_enabled: true }))).toBeTruthy();
32
- });
33
- });
34
- });
@@ -1,39 +0,0 @@
1
- import { useEffect, useRef, useState } from 'react';
2
-
3
- import type { AppSettingsAPIResponse, StreamChat } from 'stream-chat';
4
- import type { DefaultStreamChatGenerics } from 'stream-chat-react-native';
5
-
6
- export const useAppSettings = <
7
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
8
- >(
9
- client: StreamChat<StreamChatGenerics>,
10
- isOnline: boolean,
11
- ): AppSettingsAPIResponse | null => {
12
- const [appSettings, setAppSettings] = useState<AppSettingsAPIResponse | null>(null);
13
- const isMounted = useRef(true);
14
-
15
- useEffect(() => {
16
- async function getAppSettings() {
17
- try {
18
- const appSettings = await client.getAppSettings();
19
- if (isMounted.current) {
20
- setAppSettings(appSettings);
21
- }
22
- } catch (error: unknown) {
23
- if (error instanceof Error) {
24
- console.error(`An error occurred while getting app settings: ${error}`);
25
- }
26
- }
27
- }
28
-
29
- if (isOnline) {
30
- getAppSettings();
31
- }
32
-
33
- return () => {
34
- isMounted.current = false;
35
- };
36
- }, [client, isOnline]);
37
-
38
- return appSettings;
39
- };