rudeshark.net/packages/client/src/pages/user/followers.vue

82 lines
1.6 KiB
Vue
Raw Normal View History

2022-07-01 11:55:45 +02:00
<template>
2023-04-08 02:01:42 +02:00
<MkStickyContainer>
<template #header
><MkPageHeader :actions="headerActions" :tabs="headerTabs"
/></template>
<MkSpacer :content-max="1000">
<transition name="fade" mode="out-in">
<div v-if="user">
<XFollowList :user="user" type="followers" />
</div>
<MkError v-else-if="error" @retry="fetchUser()" />
<MkLoading v-else />
</transition>
</MkSpacer>
</MkStickyContainer>
2022-07-01 11:55:45 +02:00
</template>
<script lang="ts" setup>
2023-04-08 02:01:42 +02:00
import {
defineAsyncComponent,
computed,
inject,
onMounted,
onUnmounted,
watch,
} from "vue";
import * as Acct from "calckey-js/built/acct";
import * as misskey from "calckey-js";
import XFollowList from "./follow-list.vue";
import * as os from "@/os";
import { definePageMetadata } from "@/scripts/page-metadata";
import { i18n } from "@/i18n";
const props = withDefaults(
defineProps<{
acct: string;
}>(),
{}
);
2022-07-01 11:55:45 +02:00
let user = $ref<null | misskey.entities.UserDetailed>(null);
let error = $ref(null);
function fetchUser(): void {
if (props.acct == null) return;
user = null;
2023-04-08 02:01:42 +02:00
os.api("users/show", Acct.parse(props.acct))
.then((u) => {
user = u;
})
.catch((err) => {
error = err;
});
2022-07-01 11:55:45 +02:00
}
watch(() => props.acct, fetchUser, {
immediate: true,
});
const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);
2023-04-08 02:01:42 +02:00
definePageMetadata(
computed(() =>
user
? {
icon: "ph-user ph-bold ph-lg",
title: user.name
? `${user.name} (@${user.username})`
: `@${user.username}`,
subtitle: i18n.ts.followers,
userName: user,
avatar: user,
}
: null
)
);
2022-07-01 11:55:45 +02:00
</script>
2023-04-08 02:01:42 +02:00
<style lang="scss" scoped></style>