Skip to content

Commit

Permalink
fix initial value overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectronicBlueberry authored and dannon committed Dec 12, 2024
1 parent f2eca1b commit 79f663c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 4 additions & 1 deletion client/src/composables/userLocalStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { useHashedUserId } from "./hashedUserId";
export function useUserLocalStorage<T>(key: string, initialValue: T, user?: Ref<AnyUser>) {
const { hashedUserId } = useHashedUserId(user);

let refSyncedRawValue = initialValue;

const storedRef = computed(() => {
if (hashedUserId.value) {
return useLocalStorage(`${key}-${hashedUserId.value}`, initialValue);
return useLocalStorage(`${key}-${hashedUserId.value}`, refSyncedRawValue);
} else {
return ref(initialValue);
}
Expand All @@ -28,6 +30,7 @@ export function useUserLocalStorage<T>(key: string, initialValue: T, user?: Ref<
},
set(newValue) {
storedRef.value.value = newValue;
refSyncedRawValue = newValue as T;
trigger();
},
}));
Expand Down
5 changes: 1 addition & 4 deletions client/src/stores/activityStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 !== "") {
Expand Down

0 comments on commit 79f663c

Please sign in to comment.