mirror of
https://github.com/versia-pub/frontend.git
synced 2026-03-13 11:39:16 +01:00
perf: ♻️ Use global instance of composable instead of an instance per component for identities, client and settings
This commit is contained in:
parent
f1ada1745d
commit
3428e4b5b6
38 changed files with 104 additions and 131 deletions
|
|
@ -60,7 +60,6 @@ const { Control_Enter, Command_Enter, Control_Alt } = useMagicKeys();
|
|||
const content = ref("");
|
||||
const respondingTo = ref<Status | null>(null);
|
||||
const respondingType = ref<"reply" | "quote" | "edit" | null>(null);
|
||||
const identity = useCurrentIdentity();
|
||||
const cw = ref(false);
|
||||
const cwContent = ref("");
|
||||
const markdown = ref(true);
|
||||
|
|
@ -178,7 +177,6 @@ const canSubmit = computed(
|
|||
(content.value?.trim().length > 0 || files.value.length > 0) &&
|
||||
content.value?.trim().length <= characterLimit.value,
|
||||
);
|
||||
const client = useClient();
|
||||
|
||||
const send = async () => {
|
||||
loading.value = true;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ defineProps<{
|
|||
textarea: HTMLTextAreaElement | undefined;
|
||||
}>();
|
||||
|
||||
const identity = useCurrentIdentity();
|
||||
const emojis = computed(
|
||||
() =>
|
||||
identity.value?.emojis.map((emoji) => ({
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ const files = defineModel<
|
|||
required: true,
|
||||
});
|
||||
|
||||
const client = useClient();
|
||||
const fileInput = ref<HTMLInputElement | null>(null);
|
||||
|
||||
const openFilePicker = () => {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ const props = defineProps<{
|
|||
textarea: HTMLTextAreaElement | undefined;
|
||||
}>();
|
||||
|
||||
const client = useClient();
|
||||
const mentions = ref<{ key: string; value: Account }[]>([]);
|
||||
|
||||
watch(
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import { Dialog } from "@ark-ui/vue";
|
|||
import Composer from "./composer.vue";
|
||||
const open = ref(false);
|
||||
|
||||
const identity = useCurrentIdentity();
|
||||
useListen("note:reply", async (note) => {
|
||||
open.value = true;
|
||||
await nextTick();
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@
|
|||
<script lang="ts" setup>
|
||||
import Avatar from "../avatars/avatar.vue";
|
||||
|
||||
const identity = useCurrentIdentity();
|
||||
const settings = useSettings();
|
||||
const { display_name } = useParsedAccount(
|
||||
computed(() => identity.value?.account),
|
||||
settings,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import type { ResponseError } from "@lysand-org/client";
|
|||
import Button from "~/packages/ui/components/buttons/button.vue";
|
||||
import Avatar from "../avatars/avatar.vue";
|
||||
|
||||
const client = useClient();
|
||||
const ssoConfig = useSSOConfig();
|
||||
const linkedProviders = useLinkedSSO(client);
|
||||
const loading = ref(false);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ import RichTextboxInput from "../inputs/rich-textbox-input.vue";
|
|||
import TextInput from "../inputs/text-input.vue";
|
||||
import Oidc from "./oidc.vue";
|
||||
|
||||
const identity = useCurrentIdentity();
|
||||
const account = computed(() => identity.value?.account);
|
||||
const note = ref(account.value?.source?.note ?? "");
|
||||
const displayName = ref(account.value?.display_name ?? "");
|
||||
|
|
@ -61,7 +60,6 @@ const bio = computed(
|
|||
() => identity.value?.instance.configuration.statuses.max_characters ?? 0,
|
||||
);
|
||||
|
||||
const client = useClient();
|
||||
const loading = ref(false);
|
||||
|
||||
const revert = () => {
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@
|
|||
<template #button>
|
||||
<slot>
|
||||
<div class="rounded text-left flex flex-row gap-x-2 hover:scale-[95%] duration-100"
|
||||
v-if="currentIdentity">
|
||||
v-if="identity">
|
||||
<div class="shrink-0">
|
||||
<Avatar class="size-12 rounded ring-1 ring-white/5" :src="currentIdentity.account.avatar"
|
||||
:alt="`${currentIdentity.account.acct}'s avatar'`" />
|
||||
<Avatar class="size-12 rounded ring-1 ring-white/5" :src="identity.account.avatar"
|
||||
:alt="`${identity.account.acct}'s avatar'`" />
|
||||
</div>
|
||||
<div class="flex flex-col items-start p-1 justify-around grow overflow-hidden">
|
||||
<div class="flex flex-row items-center justify-between w-full">
|
||||
<div class="font-semibold text-gray-200 text-sm line-clamp-1 break-all">
|
||||
{{
|
||||
currentIdentity.account.display_name }}
|
||||
identity.account.display_name }}
|
||||
</div>
|
||||
</div>
|
||||
<span class="text-gray-400 text-xs line-clamp-1 break-all w-full">
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
</button>
|
||||
</div>
|
||||
</Menu.Item>
|
||||
<Menu.Item value="" v-if="currentIdentity">
|
||||
<Menu.Item value="" v-if="identity">
|
||||
<NuxtLink href="/settings" class="w-full">
|
||||
<ButtonBase theme="outline" class="w-full !justify-start">
|
||||
<Icon icon="tabler:adjustments" class="!size-6" />
|
||||
|
|
@ -73,7 +73,7 @@
|
|||
<span class="shrink-0 line-clamp-1">Add new account</span>
|
||||
</ButtonBase>
|
||||
</Menu.Item>
|
||||
<Menu.Item value="" v-if="!currentIdentity">
|
||||
<Menu.Item value="" v-if="!identity">
|
||||
<NuxtLink href="/register" class="w-full">
|
||||
<ButtonBase theme="outline" class="w-full !justify-start">
|
||||
<Icon icon="tabler:certificate" class="!size-6" />
|
||||
|
|
@ -92,9 +92,6 @@ import ButtonBase from "~/packages/ui/components/buttons/button.vue";
|
|||
import Icon from "~/packages/ui/components/icons/icon.vue";
|
||||
import Avatar from "../avatars/avatar.vue";
|
||||
import AdaptiveDropdown from "../dropdowns/AdaptiveDropdown.vue";
|
||||
const identities = useIdentities();
|
||||
|
||||
const currentIdentity = useCurrentIdentity();
|
||||
|
||||
defineEmits<{
|
||||
signIn: [];
|
||||
|
|
|
|||
|
|
@ -139,9 +139,6 @@ const visibleTimelines = computed(() =>
|
|||
const loadingAuth = ref(false);
|
||||
|
||||
const appData = useAppData();
|
||||
const identity = useCurrentIdentity();
|
||||
const identities = useIdentities();
|
||||
const client = useClient();
|
||||
const instance = useInstance();
|
||||
|
||||
const compose = () => {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
<script lang="ts" setup>
|
||||
import SmallCard from "../users/SmallCard.vue";
|
||||
|
||||
const client = useClient();
|
||||
const instance = useInstance();
|
||||
const description = useExtendedDescription(client);
|
||||
</script>
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
<template>
|
||||
<a :href="`/@${account.acct}`"
|
||||
class="shrink break-all rounded bg-primary-700/80 text-primary-200 px-2 py-1 not-prose font-semibold cursor-pointer [&:not(:last-child)]:mr-1 duration-200 hover:bg-primary-600/30">
|
||||
class="shrink break-all rounded bg-dark-200 ring-1 ring-white/5 ring-inset text-primary-200 px-2 py-1 not-prose font-semibold cursor-pointer [&:not(:last-child)]:mr-1 duration-200 hover:bg-primary-600/30">
|
||||
<img class="size-[1em] rounded ring-1 ring-white/5 !inline align-middle mb-1 mr-1" :src="account.avatar"
|
||||
:alt="`${account.acct}'s avatar'`" />
|
||||
{{ account.display_name }}
|
||||
{{ account.display_name || account.acct }}
|
||||
</a>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
|
|
@ -176,9 +176,6 @@ useListen("composer:send-edit", (note) => {
|
|||
}
|
||||
});
|
||||
|
||||
const client = useClient();
|
||||
const identity = useCurrentIdentity();
|
||||
const settings = useSettings();
|
||||
const {
|
||||
loaded,
|
||||
note: outputtedNote,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,5 @@ const props = defineProps<{
|
|||
account_id: string | null;
|
||||
}>();
|
||||
|
||||
const client = useClient();
|
||||
const account = useAccount(client, props.account_id);
|
||||
</script>
|
||||
|
|
@ -39,7 +39,6 @@ const props = defineProps<{
|
|||
element?: Notification;
|
||||
}>();
|
||||
|
||||
const client = useClient();
|
||||
const isWorkingOnFollowRequest = ref(false);
|
||||
const { relationship } = useRelationship(
|
||||
client,
|
||||
|
|
@ -70,7 +69,6 @@ const rejectFollowRequest = async () => {
|
|||
isWorkingOnFollowRequest.value = false;
|
||||
};
|
||||
|
||||
const settings = useSettings();
|
||||
const { display_name } = useParsedAccount(props.element?.account, settings);
|
||||
|
||||
const text = computed(() => {
|
||||
|
|
|
|||
|
|
@ -109,8 +109,6 @@ const props = defineProps<{
|
|||
}>();
|
||||
|
||||
const skeleton = computed(() => !props.account);
|
||||
const identity = useCurrentIdentity();
|
||||
const client = useClient();
|
||||
const config = useConfig();
|
||||
const accountId = computed(() => props.account?.id ?? null);
|
||||
const { relationship, isLoading } = useRelationship(client, accountId);
|
||||
|
|
@ -155,7 +153,6 @@ const visibleRoles = computed(
|
|||
() => props.account?.roles.filter((r) => r.visible) ?? [],
|
||||
);
|
||||
|
||||
const settings = useSettings();
|
||||
const { display_name, fields, note } = useParsedAccount(
|
||||
computed(() => props.account),
|
||||
settings,
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
import type { Status } from "@lysand-org/client/types";
|
||||
import Timeline from "./timeline.vue";
|
||||
|
||||
const client = useClient();
|
||||
|
||||
const props = defineProps<{
|
||||
id: string;
|
||||
}>();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
import type { Status } from "@lysand-org/client/types";
|
||||
import { useHomeTimeline } from "~/composables/HomeTimeline";
|
||||
import Timeline from "./timeline.vue";
|
||||
const client = useClient();
|
||||
|
||||
const {
|
||||
error,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
import type { Status } from "@lysand-org/client/types";
|
||||
import { useLocalTimeline } from "~/composables/LocalTimeline";
|
||||
import Timeline from "./timeline.vue";
|
||||
const client = useClient();
|
||||
|
||||
const {
|
||||
error,
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ import type { Notification } from "@lysand-org/client/types";
|
|||
import { useNotificationTimeline } from "~/composables/NotificationTimeline";
|
||||
import Timeline from "./timeline.vue";
|
||||
|
||||
const client = useClient();
|
||||
|
||||
const {
|
||||
error,
|
||||
hasReachedEnd,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
import type { Status } from "@lysand-org/client/types";
|
||||
import { usePublicTimeline } from "~/composables/PublicTimeline";
|
||||
import Timeline from "./timeline.vue";
|
||||
const client = useClient();
|
||||
|
||||
const {
|
||||
error,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue