2022-12-19 18:44:14 +03:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { UserLogin } from '~/types'
|
|
|
|
|
|
|
|
const all = useUsers()
|
|
|
|
|
|
|
|
const router = useRouter()
|
2022-12-20 18:56:54 +03:00
|
|
|
const masto = useMasto()
|
2022-12-19 18:44:14 +03:00
|
|
|
const switchUser = (user: UserLogin) => {
|
2023-01-03 04:23:16 +03:00
|
|
|
if (!user.guest && !isGuest.value && user.account.id === currentUser.value!.account!.id)
|
2022-12-19 18:44:14 +03:00
|
|
|
router.push(getAccountRoute(user.account))
|
|
|
|
else
|
2022-12-20 18:56:54 +03:00
|
|
|
masto.loginTo(user)
|
2022-12-19 18:44:14 +03:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-12-27 23:07:19 +03:00
|
|
|
<div flex justify-start items-end px-2 gap-5>
|
|
|
|
<div flex="~ wrap-reverse" gap-5>
|
|
|
|
<template v-for="user of all" :key="user.id">
|
|
|
|
<button
|
|
|
|
flex rounded
|
|
|
|
cursor-pointer
|
|
|
|
aria-label="Switch user"
|
2023-01-03 03:11:10 +03:00
|
|
|
:class="user.account?.id === currentUser?.account?.id ? '' : 'op25 grayscale'"
|
2022-12-27 23:07:19 +03:00
|
|
|
hover="filter-none op100"
|
|
|
|
@click="switchUser(user)"
|
|
|
|
>
|
2023-01-03 04:23:16 +03:00
|
|
|
<AccountAvatar v-if="!user.guest" w-13 h-13 :account="user.account" />
|
|
|
|
<span v-else>TODO: Guest</span>
|
2022-12-27 23:07:19 +03:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
<div flex items-center justify-center w-13 h-13>
|
|
|
|
<UserDropdown />
|
|
|
|
</div>
|
2022-12-19 18:44:14 +03:00
|
|
|
</div>
|
|
|
|
</template>
|