mirror of
https://github.com/versia-pub/frontend.git
synced 2026-03-13 03:29:16 +01:00
refactor: ♻️ Make auth store require less null checks
This commit is contained in:
parent
68e23a818a
commit
b23ed66401
32 changed files with 111 additions and 124 deletions
|
|
@ -3,7 +3,7 @@ import * as m from "~~/paraglide/messages.js";
|
|||
|
||||
export const useCacheRefresh = () => {
|
||||
const authStore = useAuthStore();
|
||||
const { identity } = storeToRefs(authStore);
|
||||
const { identityOptional } = storeToRefs(authStore);
|
||||
|
||||
authStore.client.getInstance().then((res) => {
|
||||
authStore.updateActiveIdentity({
|
||||
|
|
@ -13,7 +13,7 @@ export const useCacheRefresh = () => {
|
|||
|
||||
// Refresh custom emojis and instance data and me on every reload
|
||||
watch(
|
||||
identity,
|
||||
identityOptional,
|
||||
async (oldIdentity, newIdentity) => {
|
||||
if (newIdentity && newIdentity.id !== oldIdentity?.id) {
|
||||
console.info("Refreshing emoji, instance and account cache");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { Client, Output } from "@versia/client";
|
||||
import type { Output } from "@versia/client";
|
||||
import type { Notification, Status } from "@versia/client/schemas";
|
||||
import { useIntervalFn } from "@vueuse/core";
|
||||
import type { z } from "zod";
|
||||
|
|
@ -17,7 +17,7 @@ export function useTimeline<
|
|||
const hasReachedEnd = ref(false);
|
||||
const error = ref<Error | null>(null);
|
||||
const authStore = useAuthStore();
|
||||
const { identity } = storeToRefs(authStore);
|
||||
const { identityOptional } = storeToRefs(authStore);
|
||||
|
||||
const nextMaxId = ref<string | undefined>(undefined);
|
||||
const prevMinId = ref<string | undefined>(undefined);
|
||||
|
|
@ -101,7 +101,7 @@ export function useTimeline<
|
|||
pause();
|
||||
});
|
||||
|
||||
watch(identity, (newIdentity, oldIdentity) => {
|
||||
watch(identityOptional, (newIdentity, oldIdentity) => {
|
||||
if (newIdentity?.id !== oldIdentity?.id) {
|
||||
// Reload timeline when identity changes
|
||||
items.value = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue