From 68290a667604f8506e2470d3c7b2f06c5c7f16a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3rey=20J=C3=B3na?= Date: Wed, 9 Oct 2024 08:52:06 +0000 Subject: [PATCH] fix(native-app): support dynamic formats of hello image graphic (#16238) * fix: support dynamic formats of hello image graphics * fix: cover all endings * fix: include dot in extension --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- apps/native/app/src/screens/home/hello-module.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/native/app/src/screens/home/hello-module.tsx b/apps/native/app/src/screens/home/hello-module.tsx index dbdef1720410..7bab98b63b9b 100644 --- a/apps/native/app/src/screens/home/hello-module.tsx +++ b/apps/native/app/src/screens/home/hello-module.tsx @@ -18,6 +18,11 @@ const ImageWrapper = styled.View` margin-top: ${({ theme }) => theme.spacing[3]}px; ` +const getFileExtension = (url: string): string => { + const extension = url.split('.').pop() + return extension ? `.${extension}` : '' +} + export const HelloModule = React.memo(() => { const theme = useTheme() const { dismissed, graphicWidgetEnabled } = usePreferencesStore() @@ -31,8 +36,12 @@ export const HelloModule = React.memo(() => { const cacheDirectory = `${FileSystem.cacheDirectory}homeScreenImages` // Need to add extension to the title due to an issue in react native https://github.com/facebook/react-native/issues/42234 + const fileExtension = image?.getFrontpage?.imageMobile?.url + ? getFileExtension(image?.getFrontpage?.imageMobile?.url) + : '' + const titleWithExtension = image?.getFrontpage?.imageMobile?.title - ? `${image?.getFrontpage?.imageMobile?.title}.jpg` + ? `${image?.getFrontpage?.imageMobile?.title}${fileExtension}` : undefined const handleImage = async () => {