Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
webfansplz committed Jan 8, 2024
1 parent 0b9212f commit a24819f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/client/src/composables/state-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ export interface CommandItem {
action: () => void | CommandItem[] | Promise<CommandItem[] | void>
}

function uniqueById(items: CommandItem[]): CommandItem[] {
const unique = new Map<number | string, CommandItem>()
items.forEach(item => unique.set(item.id, item))
return Array.from(unique.values())
}

const registeredCommands = reactive(new Map<string, MaybeRefOrGetter<CommandItem[]>>())

// @unocss-include
Expand Down Expand Up @@ -68,13 +74,13 @@ export function useCommands() {
}))

return computed(() => {
return [
return uniqueById([
...fixedCommands,
...tabCommands.value,
...resolveCustomCommands(customCommands.value),
...Array.from(registeredCommands.values())
.flatMap(i => toValue(i)),
]
])
})
}

Expand Down

0 comments on commit a24819f

Please sign in to comment.