From 665de8d61f9a814e650a3a669bb7fcf2285bdc29 Mon Sep 17 00:00:00 2001 From: Laila Los <44241786+ElectronicBlueberry@users.noreply.github.com> Date: Wed, 11 Dec 2024 23:43:08 +0100 Subject: [PATCH] fix initial value overwrite --- client/src/composables/userLocalStorage.ts | 5 ++++- client/src/stores/activityStore.ts | 5 +---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/composables/userLocalStorage.ts b/client/src/composables/userLocalStorage.ts index f97388cd2d59..b0aa58b1a9ca 100644 --- a/client/src/composables/userLocalStorage.ts +++ b/client/src/composables/userLocalStorage.ts @@ -13,9 +13,11 @@ import { usePersistentRef } from "./persistentRef"; export function useUserLocalStorage(key: string, initialValue: T, user?: Ref) { const { hashedUserId } = useHashedUserId(user); + let refSyncedRawValue = initialValue; + const storedRef = computed(() => { if (hashedUserId.value) { - return usePersistentRef(`${key}-${hashedUserId.value}`, initialValue); + return usePersistentRef(`${key}-${hashedUserId.value}`, refSyncedRawValue); } else { return ref(initialValue); } @@ -28,6 +30,7 @@ export function useUserLocalStorage(key: string, initialValue: T, user?: Ref< }, set(newValue) { storedRef.value.value = newValue; + refSyncedRawValue = newValue as T; trigger(); }, })); diff --git a/client/src/stores/activityStore.ts b/client/src/stores/activityStore.ts index 466ee226bf00..b74a66286f4d 100644 --- a/client/src/stores/activityStore.ts +++ b/client/src/stores/activityStore.ts @@ -127,10 +127,7 @@ export const useActivityStore = defineScopedStore("activityStore", (scope) => { } }); - // update activities stored in local cache only if changes were applied - if (JSON.stringify(activities.value) !== JSON.stringify(newActivities)) { - activities.value = newActivities; - } + activities.value = newActivities; // if toggled side-bar does not exist, choose the first option if (toggledSideBar.value !== "") {