hippofish/packages/frontend/src/pages/user/following.vue
zyoshoka 8daff4a998
refactor(frontend): Reactivityで型を明示するように (#12791)
* refactor(frontend): Reactivityで型を明示するように

* fix: プロパティの参照が誤っているのを修正

* fix: 初期化の値を空配列に書き換えていた部分をnullに置き換え
2023-12-28 09:45:15 +01:00

62 lines
1.6 KiB
Vue

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<MkStickyContainer>
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
<MkSpacer :contentMax="1000">
<Transition name="fade" mode="out-in">
<div v-if="user">
<XFollowList :user="user" type="following"/>
</div>
<MkError v-else-if="error" @retry="fetchUser()"/>
<MkLoading v-else/>
</Transition>
</MkSpacer>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import { computed, watch, ref } from 'vue';
import * as Misskey from 'misskey-js';
import XFollowList from './follow-list.vue';
import * as os from '@/os.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { i18n } from '@/i18n.js';
const props = withDefaults(defineProps<{
acct: string;
}>(), {
});
const user = ref<null | Misskey.entities.UserDetailed>(null);
const error = ref<any>(null);
function fetchUser(): void {
if (props.acct == null) return;
user.value = null;
os.api('users/show', Misskey.acct.parse(props.acct)).then(u => {
user.value = u;
}).catch(err => {
error.value = err;
});
}
watch(() => props.acct, fetchUser, {
immediate: true,
});
const headerActions = computed(() => []);
const headerTabs = computed(() => []);
definePageMetadata(computed(() => user.value ? {
icon: 'ph-user ph-bold ph-lg',
title: user.value.name ? `${user.value.name} (@${user.value.username})` : `@${user.value.username}`,
subtitle: i18n.ts.following,
userName: user.value,
avatar: user.value,
} : null));
</script>