Page MenuHomePhabricator

D10310.id34621.diff
No OneTemporary

D10310.id34621.diff

diff --git a/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/thumbhash/ThumbhashModule.kt b/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/thumbhash/ThumbhashModule.kt
--- a/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/thumbhash/ThumbhashModule.kt
+++ b/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/thumbhash/ThumbhashModule.kt
@@ -53,7 +53,7 @@
val rgba = bitmap.toRGBA()
val thumbHash = ThumbHash.rgbaToThumbHash(bitmap.width, bitmap.height, rgba)
- return Base64.encodeToString(thumbHash, Base64.DEFAULT)
+ return Base64.encodeToString(thumbHash, Base64.NO_WRAP)
}
// endregion
diff --git a/native/utils/thumbhash-module.js b/native/utils/thumbhash-module.js
--- a/native/utils/thumbhash-module.js
+++ b/native/utils/thumbhash-module.js
@@ -7,12 +7,18 @@
+generateThumbHash: (photoURI: string) => Promise<string>,
} = requireNativeModule('Thumbhash');
+const newLineRegex = /\n/g;
async function generateThumbHash(photoURI: string): Promise<string> {
invariant(
platformUtilsModule.generateThumbHash,
'generateThumbHash() unavailable. Check if Thumbhash expo-module is autolinked',
);
- return await platformUtilsModule.generateThumbHash(photoURI);
+
+ const rawThumbHash = await platformUtilsModule.generateThumbHash(photoURI);
+
+ // Sometimes native base64 modules encode the string with newlines,
+ // which breaks the thumbhash format
+ return rawThumbHash.replace(newLineRegex, '');
}
export { generateThumbHash };

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 3, 10:16 AM (3 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2611309
Default Alt Text
D10310.id34621.diff (1 KB)

Event Timeline