perf: ♻️ Use global instance of composable instead of an instance per component for identities, client and settings

This commit is contained in:
Jesse Wierzbinski 2024-07-21 15:33:32 +02:00
parent f1ada1745d
commit 3428e4b5b6
No known key found for this signature in database
38 changed files with 104 additions and 131 deletions

View file

@ -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>

View file

@ -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>

View file

@ -176,9 +176,6 @@ useListen("composer:send-edit", (note) => {
}
});
const client = useClient();
const identity = useCurrentIdentity();
const settings = useSettings();
const {
loaded,
note: outputtedNote,

View file

@ -18,6 +18,5 @@ const props = defineProps<{
account_id: string | null;
}>();
const client = useClient();
const account = useAccount(client, props.account_id);
</script>

View file

@ -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(() => {

View file

@ -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,