diff --git a/platforms/pictique/src/lib/fragments/BottomNav/BottomNav.svelte b/platforms/pictique/src/lib/fragments/BottomNav/BottomNav.svelte index 3a4ff9eb..28021d65 100644 --- a/platforms/pictique/src/lib/fragments/BottomNav/BottomNav.svelte +++ b/platforms/pictique/src/lib/fragments/BottomNav/BottomNav.svelte @@ -2,8 +2,8 @@ import { goto } from '$app/navigation'; import { page } from '$app/state'; import { Camera, CommentsTwo, Home, Search } from '$lib/icons'; - import { isNavigatingThroughNav } from '$lib/store/store.svelte'; - import { uploadedImages } from '$lib/store/store.svelte'; + import { isNavigatingThroughNav, ownerId } from '$lib/store/store.svelte'; + import { uploadedImages } from '$lib/store/store.svelte'; import { getAuthId, revokeImageUrls } from '$lib/utils'; import type { HTMLAttributes } from 'svelte/elements'; @@ -25,7 +25,7 @@ let fullPath = $derived(page.url.pathname); let imageInput: HTMLInputElement; - let images: FileList | null = $state(null); + let images: FileList | null = $state(null); const handleNavClick = (newTab: string) => { // activeTab = newTab; @@ -37,9 +37,9 @@ previousTab = newTab; if (newTab === 'profile') { goto(`/profile/${ownerId}`); - } else if (newTab === "post") { - uploadedImages.value = null; - imageInput.value = ""; + } else if (newTab === 'post') { + uploadedImages.value = null; + imageInput.value = ''; imageInput.click(); } else { goto(`/${newTab}`); @@ -49,22 +49,34 @@ $effect(() => { ownerId = getAuthId() activeTab = _activeTab.split('/').pop() ?? ''; - if (images && images.length > 0 && activeTab !== 'post' && previousTab === 'post' && !_activeTab.includes('post/audience')) { - if (uploadedImages.value) - revokeImageUrls(uploadedImages.value); - uploadedImages.value = Array.from(images).map(file => ({ - url: URL.createObjectURL(file), - alt: file.name - })); + if ( + images && + images.length > 0 && + activeTab !== 'post' && + previousTab === 'post' && + !_activeTab.includes('post/audience') + ) { + if (uploadedImages.value) revokeImageUrls(uploadedImages.value); + uploadedImages.value = Array.from(images).map((file) => ({ + url: URL.createObjectURL(file), + alt: file.name + })); images = null; // To prevent re-triggering the effect and thus making an infinite loop with /post route's effect when the length of uploadedImages goes to 0 - if (uploadedImages.value.length > 0) { - goto("/post"); - } + if (uploadedImages.value.length > 0) { + goto('/post'); + } } }); - +