Sharkey/packages/frontend/src/pages/user/followers.vue

63 lines
1.6 KiB
Vue
Raw Normal View History

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