From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server-vie001.gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_DBL_BLOCKED_OPENDNS, URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1741375603; bh=odTKkntrrTt/UFaou5HCv2QqaNKF5BI3qCgaiffneWc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Message-ID:Date:From: Reply-To:Subject:To:Cc:In-Reply-To:References:Resent-Date: Resent-From:Resent-To:Resent-Cc:User-Agent:Content-Type: Content-Transfer-Encoding; b=hCX8uww65akpNcp8yiG/nxaOgwcwbJMUcozicoJsxWBG/DEuJSe7If/hGANp1RkTg eu0ODK3qtLyNziFTeeST+HhJ/W/oaW25ouTSIWqC35gjhEeLpFd4mp923Utp4US/CA EQdWgoDzedztvWXhp1CbLWGAoW4deeVyscOuSlZanKulG7z5EWbh/0C50q1bGM22rY E8sntdcvwnlv3IdQNyclKg10/quDiGARqe9jKNHWbkBSQrLihGA2MWzkOHHpFfW6nO axoHfAOjyHsWNkqMn94nsmL0Dl9l/Yqimhv1bPa1JZueR4aZzquRkKDgfcp61VJmii GXU0e9GYGevzg== Received: from localhost.localdomain (unknown [101.128.125.112]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id B1DA720B48E3; Fri, 7 Mar 2025 19:26:42 +0000 (UTC) From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 02/10] fix(avatar): change avatarImg state to use from auth.user.photo state Date: Sat, 8 Mar 2025 02:26:12 +0700 Message-ID: <20250307192622.1172-3-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.45.2.windows.1 In-Reply-To: <20250307192622.1172-1-kiizuha@gnuweeb.org> References: <20250307192622.1172-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Previously, avatar image is kinda buggy when a user has an avatar photo and then deleted the avatar photo; the user avatar is updated asynchronously in sveltekit load() function which makes the /settings/profile page is loaded firstly before trying to get_user_info in /settings layout and make the avatar value uses the previous value (avatar value with an avatar image url exists). To fix this issue, we need to pass the auth.user.photo state to the avatarImg state in the /settings/profile +page.svelte file instead on load(). Signed-off-by: Muhammad Rizki --- src/routes/(protected)/settings/profile/+page.svelte | 2 +- src/routes/(protected)/settings/profile/+page.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/(protected)/settings/profile/+page.svelte b/src/routes/(protected)/settings/profile/+page.svelte index b61601b..fc1d641 100644 --- a/src/routes/(protected)/settings/profile/+page.svelte +++ b/src/routes/(protected)/settings/profile/+page.svelte @@ -105,7 +105,7 @@ const auth = useAuth(); - let avatarImg = $state(data.avatar); + let avatarImg = $state(auth.user?.photo); const avatar = $derived(avatarImg); const getShortName = () => { diff --git a/src/routes/(protected)/settings/profile/+page.ts b/src/routes/(protected)/settings/profile/+page.ts index 7b25a4f..c3f9bd3 100644 --- a/src/routes/(protected)/settings/profile/+page.ts +++ b/src/routes/(protected)/settings/profile/+page.ts @@ -17,5 +17,5 @@ export const load: PageLoad = async () => { }; const form = await superValidate(data, zod(profileSchema)); - return { form, avatar: auth.user?.photo }; + return { form }; }; -- Muhammad Rizki