diff --git a/components/sidebars/account-switcher.vue b/components/sidebars/account-switcher.vue index ee3e169..a948d9f 100644 --- a/components/sidebars/account-switcher.vue +++ b/components/sidebars/account-switcher.vue @@ -17,7 +17,7 @@ -
+
+ Add account @@ -64,6 +64,7 @@ import { import { toast } from "vue-sonner"; import { NuxtLink } from "#components"; import Avatar from "../profiles/avatar.vue"; +import { Button } from "../ui/button"; import { DropdownMenu, DropdownMenuContent, @@ -152,4 +153,28 @@ const signOut = async (userId?: string) => { toast.dismiss(id); toast.success("Signed out"); }; + +const switchAccount = async (userId: string) => { + if (userId === identity.value?.account.id) { + return await navigateTo(`/@${identity.value.account.username}`); + } + + const id = toast.loading("Switching account..."); + + const identityToSwitch = identities.value.find( + (i) => i.account.id === userId, + ); + + if (!identityToSwitch) { + toast.dismiss(id); + toast.error("No identity to switch to"); + return; + } + + identity.value = identityToSwitch; + toast.dismiss(id); + toast.success("Switched account"); + + window.location.href = "/"; +}; \ No newline at end of file