refactor: move updateNavbar() into ./utils function
This commit is contained in:
parent
3ac8595af6
commit
19c562f460
5 changed files with 42 additions and 22 deletions
22
utils/updateNavbar.ts
Normal file
22
utils/updateNavbar.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import type { NavbarInterface, NavbarOptions } from "~/types/interfaces";
|
||||
|
||||
const navbar = useState<NavbarInterface>("navbar")
|
||||
|
||||
export default async (options: NavbarOptions) => {
|
||||
await nextTick()
|
||||
|
||||
if (navbar.value) {
|
||||
if (options.guild) {
|
||||
navbar.value.channelItems = []
|
||||
navbar.value.contextName = options.guild?.name
|
||||
navbar.value.contextIcon = options.guild?.icon ?? undefined
|
||||
navbar.value.guildUuid = options.guild?.uuid
|
||||
}
|
||||
else if (options.isDirectMessages) {
|
||||
navbar.value.channelItems = []
|
||||
navbar.value.contextName = "Direct Messages"
|
||||
navbar.value.contextIcon = undefined
|
||||
navbar.value.guildUuid = undefined
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue