Skip to content

Commit

Permalink
feat: Add event to highlight active menu
Browse files Browse the repository at this point in the history
Signed-off-by: Kostiantyn Miakshyn <[email protected]>
  • Loading branch information
Koc committed Mar 3, 2025
1 parent 6cd3046 commit 15a1b00
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/src/components/AppMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ export default defineComponent({

mounted() {
subscribe('nextcloud:app-menu.refresh', this.setApps)
subscribe('nextcloud:app-menu.active', this.setActive)
},

beforeDestroy() {
unsubscribe('nextcloud:app-menu.refresh', this.setApps)
unsubscribe('nextcloud:app-menu.active', this.setActive)
},

methods: {
Expand All @@ -104,6 +106,19 @@ export default defineComponent({
}
},

setActive(id: string) {
this.appList.forEach((app) => {
this.$set(app, 'active', false)
})

const app = this.appList.find(({ id: menuItemId }) => menuItemId === id)
if (app) {
this.$set(app, 'active', true)
} else {
logger.warn(`Could not find app "${id}" for setting navigation count`)
}
},

setApps({ apps }: { apps: INavigationEntry[]}) {
this.appList = apps
},
Expand Down

0 comments on commit 15a1b00

Please sign in to comment.