2022-12-20 00:44:14 +09:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { UserLogin } from '~/types'
|
|
|
|
|
|
|
|
const all = useUsers()
|
|
|
|
|
|
|
|
const router = useRouter()
|
2022-12-21 00:56:54 +09:00
|
|
|
const masto = useMasto()
|
2022-12-20 00:44:14 +09:00
|
|
|
const switchUser = (user: UserLogin) => {
|
|
|
|
if (user.account.id === currentUser.value?.account.id)
|
|
|
|
router.push(getAccountRoute(user.account))
|
|
|
|
else
|
2022-12-21 00:56:54 +09:00
|
|
|
masto.loginTo(user)
|
2022-12-20 00:44:14 +09:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div flex="~ col" pb8 px4 gap-6 w-20 h-full justify-end>
|
|
|
|
<template v-for="user of all" :key="user.id">
|
|
|
|
<button
|
|
|
|
flex rounded
|
|
|
|
cursor-pointer
|
|
|
|
aria-label="Switch user"
|
|
|
|
:class="user.account.id === currentUser?.account.id ? '' : 'grayscale'"
|
|
|
|
hover:filter-none
|
|
|
|
@click="switchUser(user)"
|
|
|
|
>
|
|
|
|
<AccountAvatar w-12 h-12 :account="user.account" :hover-card="false" />
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|