stream-chat-react-native-core 5.27.0-beta.1 → 5.27.0-beta.10

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 (108) hide show
  1. package/lib/commonjs/components/Attachment/Gallery.js +6 -7
  2. package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
  3. package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerIOSSelectMorePhotos.js +30 -5
  4. package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerIOSSelectMorePhotos.js.map +1 -1
  5. package/lib/commonjs/components/Chat/Chat.js +25 -16
  6. package/lib/commonjs/components/Chat/Chat.js.map +1 -1
  7. package/lib/commonjs/components/Chat/hooks/useAppSettings.js +18 -12
  8. package/lib/commonjs/components/Chat/hooks/useAppSettings.js.map +1 -1
  9. package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
  10. package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
  11. package/lib/commonjs/components/Indicators/LoadingIndicator.js +8 -2
  12. package/lib/commonjs/components/Indicators/LoadingIndicator.js.map +1 -1
  13. package/lib/commonjs/components/MessageInput/SendButton.js +1 -1
  14. package/lib/commonjs/components/MessageInput/SendButton.js.map +1 -1
  15. package/lib/commonjs/components/MessageInput/SendMessageDisallowedIndicator.js +3 -1
  16. package/lib/commonjs/components/MessageInput/SendMessageDisallowedIndicator.js.map +1 -1
  17. package/lib/commonjs/components/MessageList/MessageList.js +45 -40
  18. package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
  19. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +73 -56
  20. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  21. package/lib/commonjs/i18n/en.json +1 -1
  22. package/lib/commonjs/i18n/es.json +46 -46
  23. package/lib/commonjs/i18n/fr.json +46 -46
  24. package/lib/commonjs/i18n/he.json +46 -46
  25. package/lib/commonjs/i18n/hi.json +47 -47
  26. package/lib/commonjs/i18n/it.json +47 -47
  27. package/lib/commonjs/i18n/ja.json +47 -47
  28. package/lib/commonjs/i18n/ko.json +47 -47
  29. package/lib/commonjs/i18n/nl.json +47 -47
  30. package/lib/commonjs/i18n/pt-BR.json +47 -47
  31. package/lib/commonjs/i18n/ru.json +47 -47
  32. package/lib/commonjs/i18n/tr.json +47 -47
  33. package/lib/commonjs/utils/addReactionToLocalState.js +3 -2
  34. package/lib/commonjs/utils/addReactionToLocalState.js.map +1 -1
  35. package/lib/commonjs/version.json +1 -1
  36. package/lib/module/components/Attachment/Gallery.js +6 -7
  37. package/lib/module/components/Attachment/Gallery.js.map +1 -1
  38. package/lib/module/components/AttachmentPicker/components/AttachmentPickerIOSSelectMorePhotos.js +30 -5
  39. package/lib/module/components/AttachmentPicker/components/AttachmentPickerIOSSelectMorePhotos.js.map +1 -1
  40. package/lib/module/components/Chat/Chat.js +25 -16
  41. package/lib/module/components/Chat/Chat.js.map +1 -1
  42. package/lib/module/components/Chat/hooks/useAppSettings.js +18 -12
  43. package/lib/module/components/Chat/hooks/useAppSettings.js.map +1 -1
  44. package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
  45. package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
  46. package/lib/module/components/Indicators/LoadingIndicator.js +8 -2
  47. package/lib/module/components/Indicators/LoadingIndicator.js.map +1 -1
  48. package/lib/module/components/MessageInput/SendButton.js +1 -1
  49. package/lib/module/components/MessageInput/SendButton.js.map +1 -1
  50. package/lib/module/components/MessageInput/SendMessageDisallowedIndicator.js +3 -1
  51. package/lib/module/components/MessageInput/SendMessageDisallowedIndicator.js.map +1 -1
  52. package/lib/module/components/MessageList/MessageList.js +45 -40
  53. package/lib/module/components/MessageList/MessageList.js.map +1 -1
  54. package/lib/module/contexts/messageInputContext/MessageInputContext.js +73 -56
  55. package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  56. package/lib/module/i18n/en.json +1 -1
  57. package/lib/module/i18n/es.json +46 -46
  58. package/lib/module/i18n/fr.json +46 -46
  59. package/lib/module/i18n/he.json +46 -46
  60. package/lib/module/i18n/hi.json +47 -47
  61. package/lib/module/i18n/it.json +47 -47
  62. package/lib/module/i18n/ja.json +47 -47
  63. package/lib/module/i18n/ko.json +47 -47
  64. package/lib/module/i18n/nl.json +47 -47
  65. package/lib/module/i18n/pt-BR.json +47 -47
  66. package/lib/module/i18n/ru.json +47 -47
  67. package/lib/module/i18n/tr.json +47 -47
  68. package/lib/module/utils/addReactionToLocalState.js +3 -2
  69. package/lib/module/utils/addReactionToLocalState.js.map +1 -1
  70. package/lib/module/version.json +1 -1
  71. package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +3 -1
  72. package/lib/typescript/i18n/en.json +1 -1
  73. package/lib/typescript/i18n/es.json +46 -46
  74. package/lib/typescript/i18n/fr.json +46 -46
  75. package/lib/typescript/i18n/he.json +46 -46
  76. package/lib/typescript/i18n/hi.json +47 -47
  77. package/lib/typescript/i18n/it.json +47 -47
  78. package/lib/typescript/i18n/ja.json +47 -47
  79. package/lib/typescript/i18n/ko.json +47 -47
  80. package/lib/typescript/i18n/nl.json +47 -47
  81. package/lib/typescript/i18n/pt-BR.json +47 -47
  82. package/lib/typescript/i18n/ru.json +47 -47
  83. package/lib/typescript/i18n/tr.json +47 -47
  84. package/package.json +1 -1
  85. package/src/components/Attachment/Gallery.tsx +9 -9
  86. package/src/components/AttachmentPicker/components/AttachmentPickerIOSSelectMorePhotos.tsx +24 -2
  87. package/src/components/Chat/Chat.tsx +17 -6
  88. package/src/components/Chat/hooks/useAppSettings.ts +3 -1
  89. package/src/components/ImageGallery/ImageGallery.tsx +1 -1
  90. package/src/components/Indicators/LoadingIndicator.tsx +3 -3
  91. package/src/components/MessageInput/SendButton.tsx +1 -1
  92. package/src/components/MessageInput/SendMessageDisallowedIndicator.tsx +2 -1
  93. package/src/components/MessageList/MessageList.tsx +19 -13
  94. package/src/contexts/messageInputContext/MessageInputContext.tsx +9 -3
  95. package/src/i18n/en.json +1 -1
  96. package/src/i18n/es.json +46 -46
  97. package/src/i18n/fr.json +46 -46
  98. package/src/i18n/he.json +46 -46
  99. package/src/i18n/hi.json +47 -47
  100. package/src/i18n/it.json +47 -47
  101. package/src/i18n/ja.json +47 -47
  102. package/src/i18n/ko.json +47 -47
  103. package/src/i18n/nl.json +47 -47
  104. package/src/i18n/pt-BR.json +47 -47
  105. package/src/i18n/ru.json +47 -47
  106. package/src/i18n/tr.json +47 -47
  107. package/src/utils/addReactionToLocalState.ts +7 -2
  108. package/src/version.json +1 -1
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.AttachmentPickerIOSSelectMorePhotos = void 0;
6
6
  var _react = _interopRequireDefault(require("react"));
7
7
  var _reactNative = require("react-native");
8
+ var _ThemeContext = require("../../../contexts/themeContext/ThemeContext");
8
9
  var _TranslationContext = require("../../../contexts/translationContext/TranslationContext");
9
10
  var _native = require("../../../native");
10
11
  var _this = this,
@@ -12,16 +13,40 @@ var _this = this,
12
13
  var AttachmentPickerIOSSelectMorePhotos = function AttachmentPickerIOSSelectMorePhotos() {
13
14
  var _useTranslationContex = (0, _TranslationContext.useTranslationContext)(),
14
15
  t = _useTranslationContex.t;
15
- return _react["default"].createElement(_reactNative.Button, {
16
+ var _useTheme = (0, _ThemeContext.useTheme)(),
17
+ _useTheme$theme$color = _useTheme.theme.colors,
18
+ accent_blue = _useTheme$theme$color.accent_blue,
19
+ white = _useTheme$theme$color.white;
20
+ return _react["default"].createElement(_reactNative.Pressable, {
16
21
  onPress: _native.iOS14RefreshGallerySelection,
17
- title: t('Select More Photos'),
22
+ style: [styles.container, {
23
+ backgroundColor: white
24
+ }],
18
25
  __self: _this,
19
26
  __source: {
20
27
  fileName: _jsxFileName,
21
- lineNumber: 9,
22
- columnNumber: 10
28
+ lineNumber: 16,
29
+ columnNumber: 5
23
30
  }
24
- });
31
+ }, _react["default"].createElement(_reactNative.Text, {
32
+ style: [styles.text, {
33
+ color: accent_blue
34
+ }],
35
+ __self: _this,
36
+ __source: {
37
+ fileName: _jsxFileName,
38
+ lineNumber: 20,
39
+ columnNumber: 7
40
+ }
41
+ }, t('Select More Photos')));
25
42
  };
26
43
  exports.AttachmentPickerIOSSelectMorePhotos = AttachmentPickerIOSSelectMorePhotos;
44
+ var styles = _reactNative.StyleSheet.create({
45
+ container: {},
46
+ text: {
47
+ fontSize: 16,
48
+ paddingVertical: 10,
49
+ textAlign: 'center'
50
+ }
51
+ });
27
52
  //# sourceMappingURL=AttachmentPickerIOSSelectMorePhotos.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_TranslationContext","_native","_this","_jsxFileName","AttachmentPickerIOSSelectMorePhotos","_useTranslationContex","useTranslationContext","t","createElement","Button","onPress","iOS14RefreshGallerySelection","title","__self","__source","fileName","lineNumber","columnNumber","exports"],"sources":["AttachmentPickerIOSSelectMorePhotos.tsx"],"sourcesContent":["import React from 'react';\nimport { Button } from 'react-native';\n\nimport { useTranslationContext } from '../../../contexts/translationContext/TranslationContext';\nimport { iOS14RefreshGallerySelection } from '../../../native';\n\nexport const AttachmentPickerIOSSelectMorePhotos = () => {\n const { t } = useTranslationContext();\n return <Button onPress={iOS14RefreshGallerySelection} title={t('Select More Photos')} />;\n};\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAA+D,IAAAI,KAAA;EAAAC,YAAA;AAExD,IAAMC,mCAAmC,GAAG,SAAtCA,mCAAmCA,CAAA,EAAS;EACvD,IAAAC,qBAAA,GAAc,IAAAC,yCAAqB,EAAC,CAAC;IAA7BC,CAAC,GAAAF,qBAAA,CAADE,CAAC;EACT,OAAOX,MAAA,YAAAY,aAAA,CAACT,YAAA,CAAAU,MAAM;IAACC,OAAO,EAAEC,oCAA6B;IAACC,KAAK,EAAEL,CAAC,CAAC,oBAAoB,CAAE;IAAAM,MAAA,EAAAX,KAAA;IAAAY,QAAA;MAAAC,QAAA,EAAAZ,YAAA;MAAAa,UAAA;MAAAC,YAAA;IAAA;EAAA,CAAE,CAAC;AAC1F,CAAC;AAACC,OAAA,CAAAd,mCAAA,GAAAA,mCAAA"}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_ThemeContext","_TranslationContext","_native","_this","_jsxFileName","AttachmentPickerIOSSelectMorePhotos","_useTranslationContex","useTranslationContext","t","_useTheme","useTheme","_useTheme$theme$color","theme","colors","accent_blue","white","createElement","Pressable","onPress","iOS14RefreshGallerySelection","style","styles","container","backgroundColor","__self","__source","fileName","lineNumber","columnNumber","Text","text","color","exports","StyleSheet","create","fontSize","paddingVertical","textAlign"],"sources":["AttachmentPickerIOSSelectMorePhotos.tsx"],"sourcesContent":["import React from 'react';\nimport { Pressable, StyleSheet, Text } from 'react-native';\n\nimport { useTheme } from '../../../contexts/themeContext/ThemeContext';\nimport { useTranslationContext } from '../../../contexts/translationContext/TranslationContext';\nimport { iOS14RefreshGallerySelection } from '../../../native';\n\nexport const AttachmentPickerIOSSelectMorePhotos = () => {\n const { t } = useTranslationContext();\n const {\n theme: {\n colors: { accent_blue, white },\n },\n } = useTheme();\n return (\n <Pressable\n onPress={iOS14RefreshGallerySelection}\n style={[styles.container, { backgroundColor: white }]}\n >\n <Text style={[styles.text, { color: accent_blue }]}>{t('Select More Photos')}</Text>\n </Pressable>\n );\n};\n\nconst styles = StyleSheet.create({\n container: {},\n text: {\n fontSize: 16,\n paddingVertical: 10,\n textAlign: 'center',\n },\n});\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAA+D,IAAAK,KA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(nodeInterop) { if (typeof WeakMap !== "functio
32
32
  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; }
33
33
  (0, _init["default"])();
34
34
  var ChatWithContext = function ChatWithContext(props) {
35
- var _client$user2, _client$user3;
35
+ var _client$user;
36
36
  var children = props.children,
37
37
  client = props.client,
38
38
  _props$closeConnectio = props.closeConnectionOnBackground,
@@ -53,13 +53,16 @@ var ChatWithContext = function ChatWithContext(props) {
53
53
  var _useIsOnline = (0, _useIsOnline2.useIsOnline)(client, closeConnectionOnBackground),
54
54
  connectionRecovering = _useIsOnline.connectionRecovering,
55
55
  isOnline = _useIsOnline.isOnline;
56
- var _useState3 = (0, _react.useState)(false),
56
+ var _useState3 = (0, _react.useState)({
57
+ initialised: false
58
+ }),
57
59
  _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
58
- initialisedDatabase = _useState4[0],
59
- setInitialisedDatabase = _useState4[1];
60
+ initialisedDatabaseConfig = _useState4[0],
61
+ setInitialisedDatabaseConfig = _useState4[1];
60
62
  var mutedUsers = (0, _useMutedUsers.useMutedUsers)(client);
61
63
  var debugRef = (0, _DebugContext.useDebugContext)();
62
64
  var isDebugModeEnabled = __DEV__ && debugRef && debugRef.current;
65
+ var userID = client.userID;
63
66
  _StreamChatRN.StreamChatRN.setConfig({
64
67
  resizableCDNHosts: resizableCDNHosts
65
68
  });
@@ -81,14 +84,20 @@ var ChatWithContext = function ChatWithContext(props) {
81
84
  return setChannel(newChannel);
82
85
  };
83
86
  (0, _react.useEffect)(function () {
84
- var _client$user;
85
- if ((_client$user = client.user) != null && _client$user.id && enableOfflineSupport) {
86
- setInitialisedDatabase(false);
87
+ if (userID && enableOfflineSupport) {
88
+ setInitialisedDatabaseConfig({
89
+ initialised: false,
90
+ userID: userID
91
+ });
87
92
  _QuickSqliteClient.QuickSqliteClient.initializeDatabase();
88
93
  _DBSyncManager.DBSyncManager.init(client);
89
- setInitialisedDatabase(true);
94
+ setInitialisedDatabaseConfig({
95
+ initialised: true,
96
+ userID: userID
97
+ });
90
98
  }
91
- }, [client == null ? void 0 : (_client$user2 = client.user) == null ? void 0 : _client$user2.id, enableOfflineSupport]);
99
+ }, [userID, enableOfflineSupport]);
100
+ var initialisedDatabase = initialisedDatabaseConfig.initialised && userID === initialisedDatabaseConfig.userID;
92
101
  var appSettings = (0, _useAppSettings.useAppSettings)(client, isOnline, enableOfflineSupport, initialisedDatabase);
93
102
  var chatContext = (0, _useCreateChatContext.useCreateChatContext)({
94
103
  appSettings: appSettings,
@@ -107,7 +116,7 @@ var ChatWithContext = function ChatWithContext(props) {
107
116
  enableOfflineSupport: enableOfflineSupport,
108
117
  initialisedDatabase: initialisedDatabase
109
118
  });
110
- if (enableOfflineSupport && !initialisedDatabase) {
119
+ if (userID && enableOfflineSupport && !initialisedDatabase) {
111
120
  return null;
112
121
  }
113
122
  return _react["default"].createElement(_ChatContext.ChatProvider, {
@@ -115,17 +124,17 @@ var ChatWithContext = function ChatWithContext(props) {
115
124
  __self: _this,
116
125
  __source: {
117
126
  fileName: _jsxFileName,
118
- lineNumber: 232,
127
+ lineNumber: 243,
119
128
  columnNumber: 5
120
129
  }
121
130
  }, _react["default"].createElement(_TranslationContext.TranslationProvider, {
122
131
  value: (0, _extends2["default"])({}, translators, {
123
- userLanguage: ((_client$user3 = client.user) == null ? void 0 : _client$user3.language) || _TranslationContext.DEFAULT_USER_LANGUAGE
132
+ userLanguage: ((_client$user = client.user) == null ? void 0 : _client$user.language) || _TranslationContext.DEFAULT_USER_LANGUAGE
124
133
  }),
125
134
  __self: _this,
126
135
  __source: {
127
136
  fileName: _jsxFileName,
128
- lineNumber: 233,
137
+ lineNumber: 244,
129
138
  columnNumber: 7
130
139
  }
131
140
  }, _react["default"].createElement(_ThemeContext.ThemeProvider, {
@@ -133,14 +142,14 @@ var ChatWithContext = function ChatWithContext(props) {
133
142
  __self: _this,
134
143
  __source: {
135
144
  fileName: _jsxFileName,
136
- lineNumber: 236,
145
+ lineNumber: 247,
137
146
  columnNumber: 9
138
147
  }
139
148
  }, _react["default"].createElement(_ChannelsStateContext.ChannelsStateProvider, {
140
149
  __self: _this,
141
150
  __source: {
142
151
  fileName: _jsxFileName,
143
- lineNumber: 237,
152
+ lineNumber: 248,
144
153
  columnNumber: 11
145
154
  }
146
155
  }, children))));
@@ -154,7 +163,7 @@ var Chat = function Chat(props) {
154
163
  __self: _this,
155
164
  __source: {
156
165
  fileName: _jsxFileName,
157
- lineNumber: 272,
166
+ lineNumber: 283,
158
167
  columnNumber: 10
159
168
  }
160
169
  }));
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_useAppSettings","_useCreateChatContext","_useIsOnline2","_useMutedUsers","_useSyncDatabase","_ChannelsStateContext","_ChatContext","_DebugContext","_OverlayContext","_ThemeContext","_TranslationContext","_useStreami18n","_init","_interopRequireDefault","_native","_QuickSqliteClient","_DBSyncManager","_StreamChatRN","_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","_props$resizableCDNHo","resizableCDNHosts","style","_useState","useState","_useState2","_slicedToArray2","channel","setChannel","translators","useStreami18n","_useIsOnline","useIsOnline","connectionRecovering","isOnline","_useState3","_useState4","initialisedDatabase","setInitialisedDatabase","mutedUsers","useMutedUsers","debugRef","useDebugContext","isDebugModeEnabled","__DEV__","current","StreamChatRN","setConfig","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 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} 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 { StreamChatRN } from '../../utils/StreamChatRN';\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' | 'resizableCDNHosts'>> & {\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 resizableCDNHosts = ['.stream-io-cdn.com'],\n style,\n } = props;\n\n const [channel, setChannel] = useState<Channel<StreamChatGenerics>>();\n\n // Setup translators\n const translators = useStreami18n(i18nInstance);\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 // Set the `resizableCDNHosts` as per the prop.\n StreamChatRN.setConfig({ resizableCDNHosts });\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 resizableCDNHosts,\n setActiveChannel,\n });\n\n useSyncDatabase({\n client,\n enableOfflineSupport,\n initialisedDatabase,\n });\n\n if (enableOfflineSupport && !initialisedDatabase) {\n return null;\n }\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;AAIA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AAEA,IAAAM,gBAAA,GAAAN,OAAA;AAEA,IAAAO,qBAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AACA,IAAAU,eAAA,GAAAV,OAAA;AACA,IAAAW,aAAA,GAAAX,OAAA;AAEA,IAAAY,mBAAA,GAAAZ,OAAA;AAIA,IAAAa,cAAA,GAAAb,OAAA;AACA,IAAAc,KAAA,GAAAC,sBAAA,CAAAf,OAAA;AAEA,IAAAgB,OAAA,GAAAhB,OAAA;AACA,IAAAiB,kBAAA,GAAAjB,OAAA;AAEA,IAAAkB,cAAA,GAAAlB,OAAA;AACA,IAAAmB,aAAA,GAAAnB,OAAA;AAEA,IAAAoB,QAAA,GAAApB,OAAA;AAA6C,IAAAqB,KAAA;EAAAC,YAAA;AAAA,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBA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AAA;MAAAiG,UAAA;MAAAC,YAAA;IAAA;EAAA,GAC1B1H,MAAA,YAAAmH,aAAA,CAAC1G,qBAAA,CAAAwH,qBAAqB;IAAAX,MAAA,EAAA/F,KAAA;IAAAgG,QAAA;MAAAC,QAAA,EAAAhG,YAAA;MAAAiG,UAAA;MAAAC,YAAA;IAAA;EAAA,GAAsBtE,QAAgC,CAC/D,CACI,CACT,CAAC;AAEnB,CAAC;AAuBM,IAAM8E,IAAI,GAAG,SAAPA,IAAIA,CAGfjF,KAAuD,EACpD;EACH,IAAAkF,kBAAA,GAAkB,IAAAC,iCAAiB,EAAC,CAAC;IAA7BpE,KAAK,GAAAmE,kBAAA,CAALnE,KAAK;EAEb,OAAOhE,MAAA,YAAAmH,aAAA,CAACnE,eAAe,MAAA4E,SAAA;IAAO5D,KAAK,EAALA;EAAK,GAAQf,KAAK;IAAAqE,MAAA,EAAA/F,KAAA;IAAAgG,QAAA;MAAAC,QAAA,EAAAhG,YAAA;MAAAiG,UAAA;MAAAC,YAAA;IAAA;EAAA,EAAG,CAAC;AACtD,CAAC;AAACW,OAAA,CAAAH,IAAA,GAAAA,IAAA"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_useAppSettings","_useCreateChatContext","_useIsOnline2","_useMutedUsers","_useSyncDatabase","_ChannelsStateContext","_ChatContext","_DebugContext","_OverlayContext","_ThemeContext","_TranslationContext","_useStreami18n","_init","_interopRequireDefault","_native","_QuickSqliteClient","_DBSyncManager","_StreamChatRN","_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$user","children","client","_props$closeConnectio","closeConnectionOnBackground","_props$enableOfflineS","enableOfflineSupport","i18nInstance","_props$ImageComponent","ImageComponent","Image","_props$resizableCDNHo","resizableCDNHosts","style","_useState","useState","_useState2","_slicedToArray2","channel","setChannel","translators","useStreami18n","_useIsOnline","useIsOnline","connectionRecovering","isOnline","_useState3","initialised","_useState4","initialisedDatabaseConfig","setInitialisedDatabaseConfig","mutedUsers","useMutedUsers","debugRef","useDebugContext","isDebugModeEnabled","__DEV__","current","userID","StreamChatRN","setConfig","useEffect","setUserAgent","SDK","Platform","OS","version","recoverStateOnReconnect","persistUserOnConnectionFailure","setEventType","setSendEventParams","action","data","user","setActiveChannel","newChannel","QuickSqliteClient","initializeDatabase","DBSyncManager","initialisedDatabase","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 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} 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 { StreamChatRN } from '../../utils/StreamChatRN';\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' | 'resizableCDNHosts'>> & {\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 resizableCDNHosts = ['.stream-io-cdn.com'],\n style,\n } = props;\n\n const [channel, setChannel] = useState<Channel<StreamChatGenerics>>();\n\n // Setup translators\n const translators = useStreami18n(i18nInstance);\n\n /**\n * Setup connection event listeners\n */\n const { connectionRecovering, isOnline } = useIsOnline<StreamChatGenerics>(\n client,\n closeConnectionOnBackground,\n );\n\n const [initialisedDatabaseConfig, setInitialisedDatabaseConfig] = useState<{\n initialised: boolean;\n userID?: string;\n }>({\n initialised: false,\n });\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 const userID = client.userID;\n\n // Set the `resizableCDNHosts` as per the prop.\n StreamChatRN.setConfig({ resizableCDNHosts });\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 (userID && enableOfflineSupport) {\n setInitialisedDatabaseConfig({ initialised: false, userID });\n QuickSqliteClient.initializeDatabase();\n DBSyncManager.init(client as unknown as StreamChat);\n setInitialisedDatabaseConfig({ initialised: true, userID });\n }\n }, [userID, enableOfflineSupport]);\n\n const initialisedDatabase =\n initialisedDatabaseConfig.initialised && userID === initialisedDatabaseConfig.userID;\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 resizableCDNHosts,\n setActiveChannel,\n });\n\n useSyncDatabase({\n client,\n enableOfflineSupport,\n initialisedDatabase,\n });\n\n if (userID && enableOfflineSupport && !initialisedDatabase) {\n // if user id has been set and offline support is enabled, we need to wait for database to be initialised\n return null;\n }\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;AAIA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AAEA,IAAAM,gBAAA,GAAAN,OAAA;AAEA,IAAAO,qBAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AACA,IAAAU,eAAA,GAAAV,OAAA;AACA,IAAAW,aAAA,GAAAX,OAAA;AAEA,IAAAY,mBAAA,GAAAZ,OAAA;AAIA,IAAAa,cAAA,GAAAb,OAAA;AACA,IAAAc,KAAA,GAAAC,sBAAA,CAAAf,OAAA;AAEA,IAAAgB,OAAA,GAAAhB,OAAA;AACA,IAAAiB,kBAAA,GAAAjB,OAAA;AAEA,IAAAkB,cAAA,GAAAlB,OAAA;AACA,IAAAmB,aAAA,GAAAnB,OAAA;AAEA,IAAAoB,QAAA,GAAApB,OAAA;AAA6C,IAAAqB,KAAA;EAAAC,Y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AAIC;IAAqB,EAAG;IAAAT,MAAA,EAAA/F,KAAA;IAAAgG,QAAA;MAAAC,QAAA,EAAAhG,YAAA;MAAAiG,UAAA;MAAAC,YAAA;IAAA;EAAA,GAExF1H,MAAA,YAAAmH,aAAA,CAACtG,aAAA,CAAAmH,aAAa;IAACjE,KAAK,EAAEA,KAAM;IAAAuD,MAAA,EAAA/F,KAAA;IAAAgG,QAAA;MAAAC,QAAA,EAAAhG,YAAA;MAAAiG,UAAA;MAAAC,YAAA;IAAA;EAAA,GAC1B1H,MAAA,YAAAmH,aAAA,CAAC1G,qBAAA,CAAAwH,qBAAqB;IAAAX,MAAA,EAAA/F,KAAA;IAAAgG,QAAA;MAAAC,QAAA,EAAAhG,YAAA;MAAAiG,UAAA;MAAAC,YAAA;IAAA;EAAA,GAAsBvE,QAAgC,CAC/D,CACI,CACT,CAAC;AAEnB,CAAC;AAuBM,IAAM+E,IAAI,GAAG,SAAPA,IAAIA,CAGfjF,KAAuD,EACpD;EACH,IAAAkF,kBAAA,GAAkB,IAAAC,iCAAiB,EAAC,CAAC;IAA7BrE,KAAK,GAAAoE,kBAAA,CAALpE,KAAK;EAEb,OAAO/D,MAAA,YAAAmH,aAAA,CAACnE,eAAe,MAAA4E,SAAA;IAAO7D,KAAK,EAALA;EAAK,GAAQd,KAAK;IAAAqE,MAAA,EAAA/F,KAAA;IAAAgG,QAAA;MAAAC,QAAA,EAAAhG,YAAA;MAAAiG,UAAA;MAAAC,YAAA;IAAA;EAAA,EAAG,CAAC;AACtD,CAAC;AAACW,OAAA,CAAAH,IAAA,GAAAA,IAAA"}
@@ -33,8 +33,14 @@ var useAppSettings = function useAppSettings(client, isOnline, enableOfflineSupp
33
33
  }
34
34
  return _context.abrupt("return");
35
35
  case 2:
36
- if (!(!isOnline && enableOfflineSupport && initialisedDatabase)) {
37
- _context.next = 6;
36
+ if (!(enableOfflineSupport && !initialisedDatabase)) {
37
+ _context.next = 4;
38
+ break;
39
+ }
40
+ return _context.abrupt("return");
41
+ case 4:
42
+ if (!(!isOnline && enableOfflineSupport)) {
43
+ _context.next = 8;
38
44
  break;
39
45
  }
40
46
  _appSettings = dbApi.getAppSettings({
@@ -42,11 +48,11 @@ var useAppSettings = function useAppSettings(client, isOnline, enableOfflineSupp
42
48
  });
43
49
  setAppSettings(_appSettings);
44
50
  return _context.abrupt("return");
45
- case 6:
46
- _context.prev = 6;
47
- _context.next = 9;
51
+ case 8:
52
+ _context.prev = 8;
53
+ _context.next = 11;
48
54
  return client.getAppSettings();
49
- case 9:
55
+ case 11:
50
56
  _appSettings2 = _context.sent;
51
57
  if (isMounted.current) {
52
58
  setAppSettings(_appSettings2);
@@ -55,19 +61,19 @@ var useAppSettings = function useAppSettings(client, isOnline, enableOfflineSupp
55
61
  currentUserId: client.userID
56
62
  });
57
63
  }
58
- _context.next = 16;
64
+ _context.next = 18;
59
65
  break;
60
- case 13:
61
- _context.prev = 13;
62
- _context.t0 = _context["catch"](6);
66
+ case 15:
67
+ _context.prev = 15;
68
+ _context.t0 = _context["catch"](8);
63
69
  if (_context.t0 instanceof Error) {
64
70
  console.error("An error occurred while getting app settings: " + _context.t0);
65
71
  }
66
- case 16:
72
+ case 18:
67
73
  case "end":
68
74
  return _context.stop();
69
75
  }
70
- }, _callee, null, [[6, 13]]);
76
+ }, _callee, null, [[8, 15]]);
71
77
  }));
72
78
  return _enforeAppSettings.apply(this, arguments);
73
79
  }
@@ -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","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,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K,EAAE;gBAC1BC,OAAO,CAACC,KAAK,oDAAAb,QAAA,CAAAU,EAAyD,CAAC;cACzE;YAAC;YAAA;cAAA,OAAAV,QAAA,CAAAc,IAAA;UAAA;QAAA,GAAAnB,OAAA;MAAA,CAEJ;MAAA,OAAAN,kBAAA,CAAAC,KAAA,OAAAC,SAAA;IAAA;IAEDH,iBAAiB,CAAC,CAAC;IAEnB,OAAO,YAAM;MACXH,SAAS,CAACuB,OAAO,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"}
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 (enableOfflineSupport && !initialisedDatabase) return;\n\n if (!isOnline && enableOfflineSupport) {\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,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAA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AAK;IAC3B,CAAC;EACH,CAAC,EAAE,CAACjC,MAAM,EAAEC,QAAQ,EAAEE,mBAAmB,CAAC,CAAC;EAE3C,OAAOK,WAAW;AACpB,CAAC;AAACgC,OAAA,CAAAzC,cAAA,GAAAA,cAAA"}
@@ -138,7 +138,7 @@ var ImageGallery = function ImageGallery(props) {
138
138
  var _cur$attachments;
139
139
  var attachmentImages = ((_cur$attachments = cur.attachments) == null ? void 0 : _cur$attachments.filter(function (attachment) {
140
140
  var _attachment$giphy, _attachment$giphy$gip;
141
- return attachment.type === 'giphy' && (((_attachment$giphy = attachment.giphy) == null ? void 0 : (_attachment$giphy$gip = _attachment$giphy[giphyVersion]) == null ? void 0 : _attachment$giphy$gip.url) || attachment.thumb_url || attachment.image_url) || attachment.type === 'image' && !attachment.title_link && !attachment.og_scrape_url && (0, _getUrlOfImageAttachment.getUrlOfImageAttachment)(attachment) || ((0, _native.isVideoPackageAvailable)() && attachment.type) === 'video' && attachment.thumb_url;
141
+ return attachment.type === 'giphy' && (((_attachment$giphy = attachment.giphy) == null ? void 0 : (_attachment$giphy$gip = _attachment$giphy[giphyVersion]) == null ? void 0 : _attachment$giphy$gip.url) || attachment.thumb_url || attachment.image_url) || attachment.type === 'image' && !attachment.title_link && !attachment.og_scrape_url && (0, _getUrlOfImageAttachment.getUrlOfImageAttachment)(attachment) || (0, _native.isVideoPackageAvailable)() && attachment.type === 'video';
142
142
  }).reverse()) || [];
143
143
  var attachmentPhotos = attachmentImages.map(function (a) {
144
144
  var _a$giphy, _a$giphy$giphyVersion;