hippofish/packages/frontend/src/pages/user/following.vue

63 lines
1.6 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
2022-07-01 11:55:45 +02:00
<template>
<MkStickyContainer>
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
2023-05-19 13:52:15 +02:00
<MkSpacer :contentMax="1000">
2022-12-30 05:37:14 +01:00
<Transition name="fade" mode="out-in">
2022-07-01 11:55:45 +02:00
<div v-if="user">
<XFollowList :user="user" type="following"/>
</div>
<MkError v-else-if="error" @retry="fetchUser()"/>
2022-07-01 11:55:45 +02:00
<MkLoading v-else/>
2022-12-30 05:37:14 +01:00
</Transition>
2022-07-01 11:55:45 +02:00
</MkSpacer>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import { computed, watch, ref } from 'vue';
import * as Misskey from 'misskey-js';
2022-07-01 11:55:45 +02:00
import XFollowList from './follow-list.vue';
2023-09-19 09:37:43 +02:00
import * as os from '@/os.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { i18n } from '@/i18n.js';
2022-07-01 11:55:45 +02:00
const props = withDefaults(defineProps<{
acct: string;
}>(), {
});
const user = ref<null | Misskey.entities.UserDetailed>(null);
const error = ref<any>(null);
2022-07-01 11:55:45 +02:00
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;
2022-07-01 11:55:45 +02:00
}).catch(err => {
error.value = err;
2022-07-01 11:55:45 +02:00
});
}
watch(() => props.acct, fetchUser, {
immediate: true,
});
const headerActions = computed(() => []);
2022-07-01 11:55:45 +02:00
const headerTabs = computed(() => []);
2022-07-01 11:55:45 +02:00
definePageMetadata(computed(() => user.value ? {
2023-09-30 21:53:52 +02:00
icon: 'ph-user ph-bold ph-lg',
title: user.value.name ? `${user.value.name} (@${user.value.username})` : `@${user.value.username}`,
2022-07-01 11:55:45 +02:00
subtitle: i18n.ts.following,
userName: user.value,
avatar: user.value,
2022-07-01 11:55:45 +02:00
} : null));
</script>