Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.
TypeScript albumsexif-extractiongeocodinglive-photomotion-photophoto-galleryphoto-sharingwebgl-viewer
fix(i18n): avoid useI18n() outside setup in async composables
Alexander Sysoev9ac088352463
diff --git a/app/composables/useImageLoader.ts b/app/composables/useImageLoader.tsindex c1ec1da9..33793b3b 100644--- a/app/composables/useImageLoader.ts+++ b/app/composables/useImageLoader.ts@@ -15,7 +15,12 @@ export const useImageLoader = (updateHighResImageRendered?: (isRendered: boolean) => void,onImageLoaded?: () => void,) => {- const { t } = useI18n()+ // useImageLoader() is invoked from loadImage(), which also runs inside watch+ // callbacks (outside the synchronous setup context) — useI18n() would throw+ // "Must be called at the top of a `setup` function". Use the Nuxt-global+ // i18n instead, which is safe to access outside setup.+ const { $i18n } = useNuxtApp()+ const t = $i18n.tif (highResLoaded || !isCurrentImage || error) return nullconst loaderManager = new ImageLoaderManager()diff --git a/app/composables/useUpload.ts b/app/composables/useUpload.tsindex 5b38be78..580e50c7 100644--- a/app/composables/useUpload.ts+++ b/app/composables/useUpload.ts@@ -33,7 +33,12 @@ export interface UseUploadOptions {}export function useUpload(options: UseUploadOptions = {}) {- const { t } = useI18n()+ // useUpload() is invoked from within an async upload handler (outside the+ // synchronous setup context), so useI18n() would throw "Must be called at+ // the top of a `setup` function". Use the Nuxt-global i18n instead, which is+ // safe to access outside setup (see useExifLocalization).+ const { $i18n } = useNuxtApp()+ const t = $i18n.tconst {timeout = 0,withCredentials = false,