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

63 lines
1.5 KiB
Vue
Raw Normal View History

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