refactor: ♻️ Rewrite state system to use Pinia for composer and auth

This commit is contained in:
Jesse Wierzbinski 2025-08-28 07:41:51 +02:00
parent a6db9e059d
commit b510782a30
No known key found for this signature in database
80 changed files with 999 additions and 1011 deletions

View file

@ -33,8 +33,8 @@
{{ m.active_trite_lark_inspire() }}
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator v-if="isLoggedIn && !isMe" />
<DropdownMenuGroup v-if="isLoggedIn && !isMe">
<DropdownMenuSeparator v-if="authStore.isSignedIn && !isMe" />
<DropdownMenuGroup v-if="authStore.isSignedIn && !isMe">
<DropdownMenuItem as="button" @click="muteUser(account.id)">
<VolumeX />
{{ m.spare_wild_mole_intend() }}
@ -51,8 +51,8 @@
{{ m.slow_chunky_chipmunk_hush() }}
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator v-if="isLoggedIn && !isMe" />
<DropdownMenuGroup v-if="isLoggedIn && !isMe">
<DropdownMenuSeparator v-if="authStore.isSignedIn && !isMe" />
<DropdownMenuGroup v-if="authStore.isSignedIn && !isMe">
<DropdownMenuItem as="button" :disabled="true">
<Flag />
{{ m.great_few_jaguar_rise() }}
@ -91,8 +91,8 @@ const { account } = defineProps<{
account: z.infer<typeof Account>;
}>();
const isMe = identity.value?.account.id === account.id;
const isLoggedIn = !!identity.value;
const authStore = useAuthStore();
const isMe = authStore.account?.id === account.id;
const { copy } = useClipboard();
const copyText = (text: string) => {
@ -105,7 +105,7 @@ const isRemote = account.acct.includes("@");
const muteUser = async (userId: string) => {
const id = toast.loading(m.ornate_tidy_coyote_grow());
await client.value.muteAccount(userId);
await authStore.client.muteAccount(userId);
toast.dismiss(id);
toast.success("User muted");
@ -113,7 +113,7 @@ const muteUser = async (userId: string) => {
const blockUser = async (userId: string) => {
const id = toast.loading(m.empty_smug_raven_bloom());
await client.value.blockAccount(userId);
await authStore.client.blockAccount(userId);
toast.dismiss(id);
toast.success("User blocked");
@ -121,7 +121,7 @@ const blockUser = async (userId: string) => {
const refresh = async () => {
const id = toast.loading(m.real_every_macaw_wish());
await client.value.refetchAccount(account.id);
await authStore.client.refetchAccount(account.id);
toast.dismiss(id);
toast.success(m.many_cool_fox_love());

View file

@ -33,15 +33,14 @@ import ProfileBadge from "./profile-badge.vue";
const { account } = defineProps<{
account: z.infer<typeof Account>;
}>();
const authStore = useAuthStore();
const config = useConfig();
const roles = account.roles.filter((r) => r.visible);
// Get user handle in username@instance format
const handle = account.acct.includes("@")
? account.acct
: `${account.acct}@${
identity.value?.instance.domain ?? window.location.host
}`;
: `${account.acct}@${authStore.instance?.domain ?? window.location.host}`;
const isDeveloper = config.DEVELOPER_HANDLES.includes(handle);
</script>

View file

@ -1,5 +1,5 @@
<template>
<Button variant="secondary" :disabled="isLoading || relationship?.requested" v-if="!isMe && identity"
<Button variant="secondary" :disabled="isLoading || relationship?.requested" v-if="!isMe && authStore.isSignedIn"
@click="relationship?.following ? unfollow() : follow()">
<Loader v-if="isLoading" class="animate-spin" />
<span v-else>
@ -27,8 +27,9 @@ const { account } = defineProps<{
account: z.infer<typeof Account>;
}>();
const { relationship, isLoading } = useRelationship(client, account.id);
const isMe = identity.value?.account.id === account.id;
const { relationship, isLoading } = useRelationship(account.id);
const authStore = useAuthStore();
const isMe = authStore.account?.id === account.id;
const follow = async () => {
if (preferences.confirm_actions.value.includes("follow")) {
@ -47,7 +48,7 @@ const follow = async () => {
}
const id = toast.loading(m.quick_basic_peacock_bubble());
const { data } = await client.value.followAccount(account.id);
const { data } = await authStore.client.followAccount(account.id);
toast.dismiss(id);
relationship.value = data;
@ -71,7 +72,7 @@ const unfollow = async () => {
}
const id = toast.loading(m.big_safe_guppy_mix());
const { data } = await client.value.unfollowAccount(account.id);
const { data } = await authStore.client.unfollowAccount(account.id);
toast.dismiss(id);
relationship.value = data;