Skip to content

Commit

Permalink
fix(native-app): support dynamic formats of hello image graphic (#16238)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
thoreyjona and kodiakhq[bot] authored Oct 9, 2024
1 parent 8e6c0e3 commit 68290a6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/native/app/src/screens/home/hello-module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 () => {
Expand Down

0 comments on commit 68290a6

Please sign in to comment.