Skip to content

Commit

Permalink
Merge pull request #19316 from dannon/activity-bar-fixes
Browse files Browse the repository at this point in the history
[24.2] Fix activity-bar-id handling wrt activityStore
  • Loading branch information
davelopez authored Dec 12, 2024
2 parents b2cf660 + 79f663c commit 3fec678
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions client/src/components/ActivityBar/ActivityBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,15 @@ defineExpose({
v-if="activity.id === 'upload'"
:id="`${activity.id}`"
:key="activity.id"
:activity-bar-id="props.activityBarId"
:icon="activity.icon"
:title="activity.title"
:tooltip="activity.tooltip" />
<InteractiveItem
v-else-if="activity.to && activity.id === 'interactivetools'"
:id="`${activity.id}`"
:key="activity.id"
:activity-bar-id="props.activityBarId"
:icon="activity.icon"
:is-active="isActiveRoute(activity.to)"
:title="activity.title"
Expand Down Expand Up @@ -274,6 +276,7 @@ defineExpose({
<NotificationItem
v-if="isConfigLoaded && config.enable_notification_system"
id="notifications"
:activity-bar-id="props.activityBarId"
:icon="faBell"
:is-active="isActiveSideBar('notifications') || isActiveRoute('/user/notifications')"
title="Notifications"
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/ActivityBar/Items/InteractiveItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface Props {
icon: IconDefinition;
isActive: boolean;
to: string;
activityBarId: string;
}
defineProps<Props>();
Expand All @@ -27,7 +28,7 @@ const emit = defineEmits<{
const tooltip = computed(() =>
totalCount.value === 1
? `You currently have 1 active interactive tool`
? "You currently have 1 active interactive tool"
: `You currently have ${totalCount.value} active interactive tools`
);
</script>
Expand All @@ -36,7 +37,7 @@ const tooltip = computed(() =>
<ActivityItem
v-if="totalCount > 0"
:id="id"
:activity-bar-id="id"
:activity-bar-id="activityBarId"
:icon="icon"
:indicator="totalCount"
:is-active="isActive"
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/ActivityBar/Items/NotificationItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const { totalUnreadCount } = storeToRefs(useNotificationsStore());
export interface Props {
id: string;
activityBarId: string;
title: string;
icon: IconDefinition;
isActive: boolean;
Expand All @@ -32,7 +33,7 @@ const tooltip = computed(() =>
<template>
<ActivityItem
:id="id"
:activity-bar-id="'notifications'"
:activity-bar-id="activityBarId"
:icon="icon"
:indicator="totalUnreadCount"
:is-active="isActive"
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/ActivityBar/Items/UploadItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface Props {
title: string;
icon: IconDefinition;
tooltip: string;
activityBarId: string;
}
defineProps<Props>();
Expand All @@ -40,7 +41,7 @@ function onUploadModal() {
<template>
<ActivityItem
:id="id"
:activity-bar-id="id"
:activity-bar-id="activityBarId"
:title="title"
:tooltip="tooltip"
:icon="icon"
Expand Down
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 3fec678

Please sign in to comment.