@messenger-box/platform-mobile 10.0.3-alpha.36 → 10.0.3-alpha.38

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 (34) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib/screens/inbox/components/CachedImage/index.js +125 -93
  3. package/lib/screens/inbox/components/CachedImage/index.js.map +1 -1
  4. package/lib/screens/inbox/components/DialogsListItem.js +74 -288
  5. package/lib/screens/inbox/components/DialogsListItem.js.map +1 -1
  6. package/lib/screens/inbox/components/ServiceDialogsListItem.js +184 -415
  7. package/lib/screens/inbox/components/ServiceDialogsListItem.js.map +1 -1
  8. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js +0 -2
  9. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js.map +1 -1
  10. package/lib/screens/inbox/containers/ConversationView.js +621 -951
  11. package/lib/screens/inbox/containers/ConversationView.js.map +1 -1
  12. package/lib/screens/inbox/containers/Dialogs.js +212 -628
  13. package/lib/screens/inbox/containers/Dialogs.js.map +1 -1
  14. package/lib/screens/inbox/containers/ThreadConversationView.js +409 -1364
  15. package/lib/screens/inbox/containers/ThreadConversationView.js.map +1 -1
  16. package/package.json +3 -3
  17. package/src/screens/inbox/components/CachedImage/index.tsx +191 -140
  18. package/src/screens/inbox/components/DialogsListItem.tsx +122 -386
  19. package/src/screens/inbox/components/ServiceDialogsListItem.tsx +69 -377
  20. package/src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx +2 -4
  21. package/src/screens/inbox/containers/ConversationView.tsx +793 -1064
  22. package/src/screens/inbox/containers/ConversationView.tsx.bk +1467 -0
  23. package/src/screens/inbox/containers/Dialogs.tsx +301 -763
  24. package/src/screens/inbox/containers/ThreadConversationView.tsx +661 -1887
  25. package/lib/screens/inbox/components/workflow/dialogs-list-item-xstate.js +0 -175
  26. package/lib/screens/inbox/components/workflow/dialogs-list-item-xstate.js.map +0 -1
  27. package/lib/screens/inbox/components/workflow/service-dialogs-list-item-xstate.js +0 -191
  28. package/lib/screens/inbox/components/workflow/service-dialogs-list-item-xstate.js.map +0 -1
  29. package/lib/screens/inbox/containers/workflow/conversation-xstate.js +0 -380
  30. package/lib/screens/inbox/containers/workflow/conversation-xstate.js.map +0 -1
  31. package/lib/screens/inbox/containers/workflow/dialogs-xstate.js +0 -211
  32. package/lib/screens/inbox/containers/workflow/dialogs-xstate.js.map +0 -1
  33. package/lib/screens/inbox/containers/workflow/thread-conversation-xstate.js +0 -438
  34. package/lib/screens/inbox/containers/workflow/thread-conversation-xstate.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [10.0.3-alpha.38](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.37...v10.0.3-alpha.38) (2025-04-25)
7
+
8
+ **Note:** Version bump only for package @messenger-box/platform-mobile
9
+
10
+ ## [10.0.3-alpha.37](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.36...v10.0.3-alpha.37) (2025-04-25)
11
+
12
+ **Note:** Version bump only for package @messenger-box/platform-mobile
13
+
6
14
  ## [10.0.3-alpha.36](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.35...v10.0.3-alpha.36) (2025-04-23)
7
15
 
8
16
  **Note:** Version bump only for package @messenger-box/platform-mobile
@@ -1,4 +1,4 @@
1
- import React__default,{useState,useRef,useEffect}from'react';import {Image,View,Text}from'react-native';import*as FileSystem from'expo-file-system';import {IMAGE_CACHE_FOLDER}from'./consts.js';var __defProp = Object.defineProperty;
1
+ import React__default,{useState,useRef,useCallback,useEffect,useMemo}from'react';import {View,Text,Image}from'react-native';import*as FileSystem from'expo-file-system';import {IMAGE_CACHE_FOLDER}from'./consts.js';var __defProp = Object.defineProperty;
2
2
  var __defProps = Object.defineProperties;
3
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -17,17 +17,30 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ const downloadTracker = /* @__PURE__ */ new Map();
20
33
  const ensureCacheDirectory = async () => {
21
34
  try {
22
35
  const dirInfo = await FileSystem.getInfoAsync(IMAGE_CACHE_FOLDER);
23
36
  if (!dirInfo.exists) {
24
- console.log("Creating cache directory:", IMAGE_CACHE_FOLDER);
25
37
  await FileSystem.makeDirectoryAsync(IMAGE_CACHE_FOLDER, {
26
38
  intermediates: true
27
39
  });
28
40
  }
41
+ return true;
29
42
  } catch (error) {
30
- console.error("Failed to create cache directory:", error);
43
+ return false;
31
44
  }
32
45
  };
33
46
  const validateImageUri = (uri) => {
@@ -37,143 +50,162 @@ const validateImageUri = (uri) => {
37
50
  try {
38
51
  new URL(uri);
39
52
  } catch (e) {
40
- console.log("Invalid URL format:", uri);
41
53
  return null;
42
54
  }
43
55
  return uri;
44
56
  };
45
- const CachedImage = (props) => {
46
- const {
57
+ const CachedImage = React__default.memo((props) => {
58
+ const _a = props, {
47
59
  source,
48
60
  cacheKey,
49
- placeholderContent
50
- } = props;
61
+ placeholderContent,
62
+ style,
63
+ resizeMode,
64
+ alt
65
+ } = _a, restProps = __objRest(_a, [
66
+ "source",
67
+ "cacheKey",
68
+ "placeholderContent",
69
+ "style",
70
+ "resizeMode",
71
+ "alt"
72
+ ]);
51
73
  const {
52
74
  uri: originalUri,
53
75
  headers,
54
- expiresIn
76
+ expiresIn = 86400
55
77
  } = source;
56
78
  const uri = validateImageUri(originalUri);
57
79
  const fileURI = `${IMAGE_CACHE_FOLDER}${cacheKey}`;
58
- const [imgUri, setImgUri] = useState(fileURI);
80
+ const [imgUri, setImgUri] = useState(null);
59
81
  const [loadError, setLoadError] = useState(false);
60
82
  const [useFallbackUri, setUseFallbackUri] = useState(false);
83
+ const [isLoading, setIsLoading] = useState(true);
61
84
  const componentIsMounted = useRef(true);
85
+ const hasAttemptedLoad = useRef(false);
62
86
  const requestOption = headers ? {
63
87
  headers
64
88
  } : {};
65
- const _callback = (downloadProgress) => {
66
- var _a;
89
+ const downloadCallback = useCallback((downloadProgress) => {
90
+ var _a2;
67
91
  if (componentIsMounted.current === false) {
68
- (_a = downloadResumableRef.current) == null ? void 0 : _a.pauseAsync();
92
+ downloadTracker.delete(cacheKey);
93
+ (_a2 = downloadResumableRef.current) == null ? void 0 : _a2.pauseAsync();
69
94
  FileSystem.deleteAsync(fileURI, {
70
95
  idempotent: true
71
96
  });
72
97
  }
73
- };
74
- const downloadResumableRef = useRef(uri ? FileSystem.createDownloadResumable(uri, fileURI, requestOption, _callback) : null);
75
- useEffect(() => {
76
- const initCache = async () => {
77
- await ensureCacheDirectory();
78
- if (uri) {
79
- loadImage();
80
- } else {
81
- console.log("Image URI is invalid, not loading");
82
- setLoadError(true);
83
- }
84
- };
85
- console.log("Cache key:", cacheKey);
86
- initCache();
87
- return () => {
88
- componentIsMounted.current = false;
89
- };
90
- }, []);
91
- const loadImage = async () => {
98
+ }, [fileURI, cacheKey]);
99
+ const downloadResumableRef = useRef(uri ? FileSystem.createDownloadResumable(uri, fileURI, requestOption, downloadCallback) : null);
100
+ const loadImage = useCallback(async () => {
101
+ if (!uri || hasAttemptedLoad.current)
102
+ return;
103
+ hasAttemptedLoad.current = true;
104
+ setIsLoading(true);
92
105
  try {
106
+ if (downloadTracker.has(cacheKey)) {
107
+ await downloadTracker.get(cacheKey);
108
+ if (componentIsMounted.current) {
109
+ setImgUri(fileURI);
110
+ setIsLoading(false);
111
+ }
112
+ return;
113
+ }
93
114
  const metadata = await FileSystem.getInfoAsync(fileURI);
94
115
  const expired = expiresIn && new Date().getTime() / 1e3 - (metadata == null ? void 0 : metadata.modificationTime) > expiresIn;
95
- console.log({
96
- expiresIn,
97
- expired
98
- });
99
116
  if (!metadata.exists || (metadata == null ? void 0 : metadata.size) === 0 || expired) {
100
- if (componentIsMounted.current) {
101
- setImgUri(null);
102
- if (expired) {
103
- await FileSystem.deleteAsync(fileURI, {
104
- idempotent: true
105
- });
106
- }
107
- setImgUri(null);
108
- if (!uri) {
109
- setLoadError(true);
110
- return;
111
- }
112
- if (!downloadResumableRef.current) {
113
- console.log("Download resumable is null");
114
- setUseFallbackUri(true);
115
- setImgUri(uri);
116
- return;
117
- }
118
- try {
119
- const response = await downloadResumableRef.current.downloadAsync();
120
- if (componentIsMounted.current && response && response.status === 200) {
121
- setImgUri(`${fileURI}?`);
117
+ if (!componentIsMounted.current)
118
+ return;
119
+ if (expired && metadata.exists) {
120
+ await FileSystem.deleteAsync(fileURI, {
121
+ idempotent: true
122
+ });
123
+ }
124
+ if (!uri) {
125
+ setLoadError(true);
126
+ setIsLoading(false);
127
+ return;
128
+ }
129
+ if (!downloadResumableRef.current) {
130
+ setUseFallbackUri(true);
131
+ setImgUri(uri);
132
+ setIsLoading(false);
133
+ return;
134
+ }
135
+ try {
136
+ const downloadPromise = downloadResumableRef.current.downloadAsync();
137
+ downloadTracker.set(cacheKey, downloadPromise);
138
+ const response = await downloadPromise;
139
+ downloadTracker.delete(cacheKey);
140
+ if (componentIsMounted.current) {
141
+ if (response && response.status === 200) {
142
+ setImgUri(fileURI);
122
143
  } else {
123
- console.log("Failed to download image, status:", response == null ? void 0 : response.status);
124
- console.log("Falling back to original URI");
125
144
  setUseFallbackUri(true);
126
145
  setImgUri(uri);
127
146
  FileSystem.deleteAsync(fileURI, {
128
147
  idempotent: true
129
148
  });
130
149
  }
131
- } catch (downloadError) {
132
- console.log("Error downloading image:", downloadError);
133
- console.log("Falling back to original URI");
150
+ setIsLoading(false);
151
+ }
152
+ } catch (downloadError) {
153
+ downloadTracker.delete(cacheKey);
154
+ if (componentIsMounted.current) {
134
155
  setUseFallbackUri(true);
135
156
  setImgUri(uri);
157
+ setIsLoading(false);
136
158
  }
137
159
  }
138
160
  } else {
161
+ setImgUri(fileURI);
162
+ setIsLoading(false);
139
163
  }
140
164
  } catch (err) {
141
- console.log({
142
- err
143
- });
144
- console.log("Falling back to original URI");
145
- setUseFallbackUri(true);
146
- setImgUri(uri);
165
+ if (componentIsMounted.current) {
166
+ setUseFallbackUri(true);
167
+ setImgUri(uri);
168
+ setIsLoading(false);
169
+ }
147
170
  }
148
- };
149
- const defaultPlaceholder = /* @__PURE__ */ React__default.createElement(View, { style: {
171
+ }, [uri, fileURI, cacheKey, expiresIn]);
172
+ useEffect(() => {
173
+ const setup = async () => {
174
+ const directoryExists = await ensureCacheDirectory();
175
+ if (directoryExists && uri) {
176
+ loadImage();
177
+ } else {
178
+ setLoadError(true);
179
+ setIsLoading(false);
180
+ }
181
+ };
182
+ setup();
183
+ return () => {
184
+ componentIsMounted.current = false;
185
+ };
186
+ }, [uri, loadImage]);
187
+ const defaultPlaceholder = useMemo(() => /* @__PURE__ */ React__default.createElement(View, { style: [{
150
188
  width: "100%",
151
189
  height: "100%",
152
190
  backgroundColor: "#e1e1e1",
153
191
  justifyContent: "center",
154
192
  alignItems: "center",
155
193
  borderRadius: 3
156
- } }, /* @__PURE__ */ React__default.createElement(Text, null, "Image not available"));
157
- if (!imgUri) {
194
+ }, style] }, /* @__PURE__ */ React__default.createElement(Text, null, "Image not available")), [style]);
195
+ if (isLoading || loadError || !imgUri) {
158
196
  return placeholderContent || defaultPlaceholder;
159
197
  }
160
- return /* @__PURE__ */ React__default.createElement(
161
- Image,
162
- __spreadProps(__spreadValues({}, props), {
163
- source: __spreadProps(__spreadValues({}, source), {
164
- uri: useFallbackUri ? uri : imgUri
165
- }),
166
- onError: (e) => {
167
- console.log("Image loading error:", e.nativeEvent.error);
168
- if (useFallbackUri) {
169
- setLoadError(true);
170
- setImgUri(null);
171
- } else {
172
- console.log("Falling back to original URI after onError");
173
- setUseFallbackUri(true);
174
- setImgUri(uri);
175
- }
176
- }
177
- })
178
- );
179
- };export{CachedImage as default};//# sourceMappingURL=index.js.map
198
+ return /* @__PURE__ */ React__default.createElement(Image, __spreadProps(__spreadValues({}, restProps), { style, source: __spreadProps(__spreadValues({}, source), {
199
+ uri: useFallbackUri ? uri : imgUri
200
+ }), resizeMode, onError: (e) => {
201
+ if (useFallbackUri) {
202
+ setLoadError(true);
203
+ setImgUri(null);
204
+ } else {
205
+ setUseFallbackUri(true);
206
+ setImgUri(uri);
207
+ }
208
+ } }));
209
+ }, (prevProps, nextProps) => {
210
+ return prevProps.cacheKey === nextProps.cacheKey && prevProps.source.uri === nextProps.source.uri && prevProps.style === nextProps.style;
211
+ });export{CachedImage as default};//# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/screens/inbox/components/CachedImage/index.tsx"],"sourcesContent":["import React, { useEffect, useState, useRef } from 'react';\nimport { Image, View, Text } from 'react-native';\n// import { Image } from \"react-native\"\nimport * as FileSystem from 'expo-file-system';\n\nimport * as CONST from './consts';\n\n// Ensure the cache directory exists\nconst ensureCacheDirectory = async () => {\n try {\n const dirInfo = await FileSystem.getInfoAsync(CONST.IMAGE_CACHE_FOLDER);\n if (!dirInfo.exists) {\n console.log('Creating cache directory:', CONST.IMAGE_CACHE_FOLDER);\n await FileSystem.makeDirectoryAsync(CONST.IMAGE_CACHE_FOLDER, { intermediates: true });\n }\n } catch (error) {\n console.error('Failed to create cache directory:', error);\n }\n};\n\n// Validate and sanitize the image URL\nconst validateImageUri = (uri: string): string | null => {\n if (!uri) return null;\n\n // Trim whitespace\n uri = uri.trim();\n\n // Check if it's a valid URL format\n try {\n new URL(uri);\n } catch (e) {\n console.log('Invalid URL format:', uri);\n return null;\n }\n\n // Add more validation as needed for your specific case\n return uri;\n};\n\nconst CachedImage = (props: any) => {\n const { source, cacheKey, placeholderContent } = props;\n const { uri: originalUri, headers, expiresIn } = source;\n\n // Validate and sanitize the URI\n const uri = validateImageUri(originalUri);\n\n const fileURI = `${CONST.IMAGE_CACHE_FOLDER}${cacheKey}`;\n\n const [imgUri, setImgUri] = useState<any>(fileURI);\n const [loadError, setLoadError] = useState<boolean>(false);\n const [useFallbackUri, setUseFallbackUri] = useState<boolean>(false);\n\n const componentIsMounted = useRef(true);\n const requestOption = headers ? { headers } : {};\n\n const _callback = (downloadProgress: any) => {\n if (componentIsMounted.current === false) {\n downloadResumableRef.current?.pauseAsync();\n FileSystem.deleteAsync(fileURI, { idempotent: true }); // delete file locally if it was not downloaded properly\n }\n };\n\n const downloadResumableRef = useRef(\n uri ? FileSystem.createDownloadResumable(uri, fileURI, requestOption, _callback) : null,\n );\n\n useEffect(() => {\n const initCache = async () => {\n await ensureCacheDirectory();\n if (uri) {\n loadImage();\n } else {\n console.log('Image URI is invalid, not loading');\n setLoadError(true);\n }\n };\n\n // console.log('CachedImage loading with URI:', uri);\n console.log('Cache key:', cacheKey);\n\n initCache();\n\n return () => {\n componentIsMounted.current = false;\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n const loadImage = async () => {\n try {\n // Use the cached image if it exists\n const metadata: any = await FileSystem.getInfoAsync(fileURI);\n const expired = expiresIn && new Date().getTime() / 1000 - metadata?.modificationTime > expiresIn;\n console.log({ expiresIn, expired });\n\n // console.log({ modificationTime: metadata.modificationTime, currentTime: new Date().getTime() / 1000 });\n // console.log({ metadata });\n\n if (!metadata.exists || metadata?.size === 0 || expired) {\n if (componentIsMounted.current) {\n setImgUri(null);\n\n if (expired) {\n await FileSystem.deleteAsync(fileURI, { idempotent: true });\n }\n // download to cache\n setImgUri(null);\n\n // console.log('Downloading image from URI:', uri);\n if (!uri) {\n // console.log('Image URI is undefined or null');\n setLoadError(true);\n return;\n }\n\n if (!downloadResumableRef.current) {\n console.log('Download resumable is null');\n setUseFallbackUri(true);\n setImgUri(uri);\n return;\n }\n\n try {\n const response: any = await downloadResumableRef.current.downloadAsync();\n // console.log('Download response:', response);\n\n if (componentIsMounted.current && response && response.status === 200) {\n setImgUri(`${fileURI}?`); // deep clone to force re-render\n // console.log('Image cached successfully, new URI:', `${fileURI}?`);\n } else {\n console.log('Failed to download image, status:', response?.status);\n console.log('Falling back to original URI');\n setUseFallbackUri(true);\n setImgUri(uri);\n FileSystem.deleteAsync(fileURI, { idempotent: true }); // delete file locally if it was not downloaded properly\n }\n } catch (downloadError) {\n console.log('Error downloading image:', downloadError);\n console.log('Falling back to original URI');\n setUseFallbackUri(true);\n setImgUri(uri);\n }\n }\n } else {\n //console.log('Using cached image at:', fileURI);\n }\n } catch (err) {\n console.log({ err });\n console.log('Falling back to original URI');\n setUseFallbackUri(true);\n setImgUri(uri);\n }\n };\n\n //console.log({ placeholderContent, imgUri, loadError, useFallbackUri });\n\n // Default placeholder if none is provided\n const defaultPlaceholder = (\n <View\n style={{\n width: '100%',\n height: '100%',\n backgroundColor: '#e1e1e1',\n justifyContent: 'center',\n alignItems: 'center',\n borderRadius: 3,\n }}\n >\n <Text>Image not available</Text>\n </View>\n );\n\n if (!imgUri) {\n return placeholderContent || defaultPlaceholder;\n }\n\n return (\n <Image\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n source={{\n ...source,\n uri: useFallbackUri ? uri : imgUri,\n }}\n onError={(e) => {\n console.log('Image loading error:', e.nativeEvent.error);\n // If we're already using the fallback URI and still getting an error,\n // then show the placeholder\n if (useFallbackUri) {\n setLoadError(true);\n setImgUri(null);\n } else {\n console.log('Falling back to original URI after onError');\n setUseFallbackUri(true);\n setImgUri(uri);\n }\n }}\n />\n );\n};\n\nexport const CacheManager = {\n addToCache: async ({ file, key }: any) => {\n await FileSystem.copyAsync({\n from: file,\n to: `${CONST.IMAGE_CACHE_FOLDER}${key}`,\n });\n // const uri = await FileSystem.getContentUriAsync(`${CONST.IMAGE_CACHE_FOLDER}${key}`)\n // return uri\n const uri = await CacheManager.getCachedUri({ key });\n return uri;\n },\n\n getCachedUri: async ({ key }: any) => {\n const uri = await FileSystem.getContentUriAsync(`${CONST.IMAGE_CACHE_FOLDER}${key}`);\n return uri;\n },\n\n downloadAsync: async ({ uri, key, options }: any) => {\n return await FileSystem.downloadAsync(uri, `${CONST.IMAGE_CACHE_FOLDER}${key}`, options);\n },\n};\n\nexport default CachedImage;\n"],"names":["CONST.IMAGE_CACHE_FOLDER","React"],"mappings":";;;;;;;;;;;;;;;;;;;AAOA,MAAM,uBAAuB,YAAY;AACvC,EAAI,IAAA;AACF,IAAA,MAAM,OAAU,GAAA,MAAM,UAAW,CAAA,YAAA,CAAaA,kBAAwB,CAAA;AACtE,IAAI,IAAA,CAAC,QAAQ,MAAQ,EAAA;AACnB,MAAQ,OAAA,CAAA,GAAA,CAAI,2BAA6B,EAAAA,kBAAwB,CAAA;AACjE,MAAM,MAAA,UAAA,CAAW,kBAAmB,CAAAA,kBAA0B,EAAA;AAAA,QAC5D,aAAe,EAAA;AAAA,OAChB,CAAA;AAAA;AACH,WACO,KAAP,EAAA;AACA,IAAQ,OAAA,CAAA,KAAA,CAAM,qCAAqC,KAAK,CAAA;AAAA;AAE5D,CAAA;AAGA,MAAM,gBAAA,GAAmB,CAAC,GAA+B,KAAA;AACvD,EAAA,IAAI,CAAC,GAAA;AAAK,IAAO,OAAA,IAAA;AAGjB,EAAA,GAAA,GAAM,IAAI,IAAK,EAAA;AAGf,EAAI,IAAA;AACF,IAAA,IAAI,IAAI,GAAG,CAAA;AAAA,WACJ,CAAP,EAAA;AACA,IAAQ,OAAA,CAAA,GAAA,CAAI,uBAAuB,GAAG,CAAA;AACtC,IAAO,OAAA,IAAA;AAAA;AAIT,EAAO,OAAA,GAAA;AACT,CAAA;AACM,MAAA,WAAA,GAAc,CAAC,KAAe,KAAA;AAClC,EAAM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AA,EAAA,EAAK,KAAO,EAAA;AAAA,IACtC,KAAO,EAAA,MAAA;AAAA,IACP,MAAQ,EAAA,MAAA;AAAA,IACR,eAAiB,EAAA,SAAA;AAAA,IACjB,cAAgB,EAAA,QAAA;AAAA,IAChB,UAAY,EAAA,QAAA;AAAA,IACZ,YAAc,EAAA;AAAA,GAEN,EAAA,kBAAAA,cAAA,CAAA,aAAA,CAAC,IAAK,EAAA,IAAA,EAAA,qBAAmB,CAC7B,CAAA;AACN,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAA,OAAO,kBAAsB,IAAA,kBAAA;AAAA;AAE/B,EAAO,uBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EAEJ,KAFI,CAAA,EAAA;AAAA,MAEG,MAAA,EAAQ,iCACd,MADc,CAAA,EAAA;AAAA,QAEjB,GAAA,EAAK,iBAAiB,GAAM,GAAA;AAAA,OAC9B,CAAA;AAAA,MAAG,SAAS,CAAK,CAAA,KAAA;AACf,QAAA,OAAA,CAAQ,GAAI,CAAA,sBAAA,EAAwB,CAAE,CAAA,WAAA,CAAY,KAAK,CAAA;AAGvD,QAAA,IAAI,cAAgB,EAAA;AAClB,UAAA,YAAA,CAAa,IAAI,CAAA;AACjB,UAAA,SAAA,CAAU,IAAI,CAAA;AAAA,SACT,MAAA;AACL,UAAA,OAAA,CAAQ,IAAI,4CAA4C,CAAA;AACxD,UAAA,iBAAA,CAAkB,IAAI,CAAA;AACtB,UAAA,SAAA,CAAU,GAAG,CAAA;AAAA;AACf;AACF,KAAA;AAAA,GAAG;AACL"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/screens/inbox/components/CachedImage/index.tsx"],"sourcesContent":["import React, { useEffect, useState, useRef, useMemo, useCallback } from 'react';\nimport { Image, View, Text } from 'react-native';\n// import { Image } from \"react-native\"\nimport * as FileSystem from 'expo-file-system';\n\nimport * as CONST from './consts';\n\n// Global download tracking to prevent duplicate downloads\nconst downloadTracker = new Map();\n\n// Ensure the cache directory exists\nconst ensureCacheDirectory = async () => {\n try {\n const dirInfo = await FileSystem.getInfoAsync(CONST.IMAGE_CACHE_FOLDER);\n if (!dirInfo.exists) {\n // console.log('Creating cache directory:', CONST.IMAGE_CACHE_FOLDER);\n await FileSystem.makeDirectoryAsync(CONST.IMAGE_CACHE_FOLDER, { intermediates: true });\n }\n return true;\n } catch (error) {\n // console.error('Failed to create cache directory:', error);\n return false;\n }\n};\n\n// Validate and sanitize the image URL\nconst validateImageUri = (uri: string): string | null => {\n if (!uri) return null;\n\n // Trim whitespace\n uri = uri.trim();\n\n // Check if it's a valid URL format\n try {\n new URL(uri);\n } catch (e) {\n // console.log('Invalid URL format:', uri);\n return null;\n }\n\n // Add more validation as needed for your specific case\n return uri;\n};\n\nconst CachedImage = React.memo(\n (props: any) => {\n const { source, cacheKey, placeholderContent, style, resizeMode, alt, ...restProps } = props;\n const { uri: originalUri, headers, expiresIn = 86400 } = source;\n\n // Validate and sanitize the URI\n const uri = validateImageUri(originalUri);\n const fileURI = `${CONST.IMAGE_CACHE_FOLDER}${cacheKey}`;\n\n const [imgUri, setImgUri] = useState<string | null>(null);\n const [loadError, setLoadError] = useState<boolean>(false);\n const [useFallbackUri, setUseFallbackUri] = useState<boolean>(false);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n\n const componentIsMounted = useRef(true);\n const hasAttemptedLoad = useRef(false);\n const requestOption = headers ? { headers } : {};\n\n // Create a memoized download callback\n const downloadCallback = useCallback(\n (downloadProgress: any) => {\n if (componentIsMounted.current === false) {\n downloadTracker.delete(cacheKey);\n downloadResumableRef.current?.pauseAsync();\n FileSystem.deleteAsync(fileURI, { idempotent: true });\n }\n },\n [fileURI, cacheKey],\n );\n\n // Create a memoized download resumable\n const downloadResumableRef = useRef(\n uri ? FileSystem.createDownloadResumable(uri, fileURI, requestOption, downloadCallback) : null,\n );\n\n // Memoized load image function to avoid recreating on every render\n const loadImage = useCallback(async () => {\n if (!uri || hasAttemptedLoad.current) return;\n\n hasAttemptedLoad.current = true;\n setIsLoading(true);\n\n try {\n // Check if this image is already being downloaded\n if (downloadTracker.has(cacheKey)) {\n // Wait for the existing download to complete\n await downloadTracker.get(cacheKey);\n if (componentIsMounted.current) {\n setImgUri(fileURI);\n setIsLoading(false);\n }\n return;\n }\n\n // Use the cached image if it exists\n const metadata: any = await FileSystem.getInfoAsync(fileURI);\n const expired = expiresIn && new Date().getTime() / 1000 - metadata?.modificationTime > expiresIn;\n\n if (!metadata.exists || metadata?.size === 0 || expired) {\n if (!componentIsMounted.current) return;\n\n if (expired && metadata.exists) {\n await FileSystem.deleteAsync(fileURI, { idempotent: true });\n }\n\n if (!uri) {\n setLoadError(true);\n setIsLoading(false);\n return;\n }\n\n if (!downloadResumableRef.current) {\n setUseFallbackUri(true);\n setImgUri(uri);\n setIsLoading(false);\n return;\n }\n\n try {\n // Record this download in the global tracker\n const downloadPromise = downloadResumableRef.current.downloadAsync();\n downloadTracker.set(cacheKey, downloadPromise);\n\n const response: any = await downloadPromise;\n\n // Remove from tracker when done\n downloadTracker.delete(cacheKey);\n\n if (componentIsMounted.current) {\n if (response && response.status === 200) {\n setImgUri(fileURI);\n } else {\n setUseFallbackUri(true);\n setImgUri(uri);\n FileSystem.deleteAsync(fileURI, { idempotent: true });\n }\n setIsLoading(false);\n }\n } catch (downloadError) {\n downloadTracker.delete(cacheKey);\n if (componentIsMounted.current) {\n setUseFallbackUri(true);\n setImgUri(uri);\n setIsLoading(false);\n }\n }\n } else {\n // Use cached version\n setImgUri(fileURI);\n setIsLoading(false);\n }\n } catch (err) {\n if (componentIsMounted.current) {\n setUseFallbackUri(true);\n setImgUri(uri);\n setIsLoading(false);\n }\n }\n }, [uri, fileURI, cacheKey, expiresIn]);\n\n // Setup effect\n useEffect(() => {\n const setup = async () => {\n const directoryExists = await ensureCacheDirectory();\n if (directoryExists && uri) {\n loadImage();\n } else {\n setLoadError(true);\n setIsLoading(false);\n }\n };\n\n setup();\n\n return () => {\n componentIsMounted.current = false;\n };\n }, [uri, loadImage]);\n\n // Default placeholder\n const defaultPlaceholder = useMemo(\n () => (\n <View\n style={[\n {\n width: '100%',\n height: '100%',\n backgroundColor: '#e1e1e1',\n justifyContent: 'center',\n alignItems: 'center',\n borderRadius: 3,\n },\n style,\n ]}\n >\n <Text>Image not available</Text>\n </View>\n ),\n [style],\n );\n\n // Show placeholder while loading or if there's an error\n if (isLoading || loadError || !imgUri) {\n return placeholderContent || defaultPlaceholder;\n }\n\n // Actual image component\n return (\n <Image\n {...restProps}\n style={style}\n source={{\n ...source,\n uri: useFallbackUri ? uri : imgUri,\n }}\n resizeMode={resizeMode}\n onError={(e) => {\n if (useFallbackUri) {\n setLoadError(true);\n setImgUri(null);\n } else {\n setUseFallbackUri(true);\n setImgUri(uri);\n }\n }}\n />\n );\n },\n (prevProps, nextProps) => {\n // Custom comparison function for memoization\n return (\n prevProps.cacheKey === nextProps.cacheKey &&\n prevProps.source.uri === nextProps.source.uri &&\n prevProps.style === nextProps.style\n );\n },\n);\n\nexport const CacheManager = {\n addToCache: async ({ file, key }: any) => {\n await ensureCacheDirectory();\n await FileSystem.copyAsync({\n from: file,\n to: `${CONST.IMAGE_CACHE_FOLDER}${key}`,\n });\n const uri = await CacheManager.getCachedUri({ key });\n return uri;\n },\n\n getCachedUri: async ({ key }: any) => {\n const uri = await FileSystem.getContentUriAsync(`${CONST.IMAGE_CACHE_FOLDER}${key}`);\n return uri;\n },\n\n downloadAsync: async ({ uri, key, options }: any) => {\n await ensureCacheDirectory();\n return await FileSystem.downloadAsync(uri, `${CONST.IMAGE_CACHE_FOLDER}${key}`, options);\n },\n\n clearCache: async () => {\n try {\n await FileSystem.deleteAsync(CONST.IMAGE_CACHE_FOLDER, { idempotent: true });\n await ensureCacheDirectory();\n } catch (error) {\n console.error('Error clearing cache:', error);\n }\n },\n};\n\nexport default CachedImage;\n"],"names":["CONST.IMAGE_CACHE_FOLDER","React","_a"],"mapp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