Skip to content

Commit

Permalink
pkp/pkp-lib#10969 Fix reactivity madness
Browse files Browse the repository at this point in the history
  • Loading branch information
jardakotesovec committed Feb 27, 2025
1 parent 03bf8ac commit 8e3368a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/components/SideNav/SideNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ if (reviewAssignmentMenuItem) {
}
// helper to attach count to the menu item
function enrichMenuItemWithCounts(page, itemsCount) {
function enrichMenuItemWithCounts(menuItems, page, itemsCount) {
if (itemsCount.value) {
const menuItem = menuItems.value.find((item) => item.key === page);
const menuItem = menuItems.find((item) => item.key === page);
if (menuItem) {
const menuItemsEnriched = menuItem.items.map((item) => ({
...item,
Expand All @@ -105,14 +105,21 @@ function enrichMenuItemWithCounts(page, itemsCount) {
menuItem.items = menuItemsEnriched;
}
}
return menuItems;
}
const menuItemsEnriched = computed(() => {
enrichMenuItemWithCounts('dashboards', dashboardCount);
enrichMenuItemWithCounts('mySubmissions', mySubmissionsCount);
enrichMenuItemWithCounts('reviewAssignments', reviewAssignmentCount);
const menuItemsCopy = JSON.parse(JSON.stringify(menuItems.value));
return menuItems.value;
enrichMenuItemWithCounts(menuItemsCopy, 'dashboards', dashboardCount);
enrichMenuItemWithCounts(menuItemsCopy, 'mySubmissions', mySubmissionsCount);
enrichMenuItemWithCounts(
menuItemsCopy,
'reviewAssignments',
reviewAssignmentCount,
);
return menuItemsCopy;
});
function convertLinksToArray(links, level = 1, parentKey = '') {
Expand Down Expand Up @@ -179,6 +186,7 @@ const {sideMenuProps} = useSideMenu(menuItemsEnriched, {
watch(
() => props.links,
(newLinks) => {
console.log('SideNav watch');
menuItems.value = convertLinksToArray(newLinks);
},
);
Expand Down

0 comments on commit 8e3368a

Please sign in to comment.