mirror of
https://github.com/versia-pub/frontend.git
synced 2026-03-13 03:29:16 +01:00
feat: ✨ Make whole app client-only, add noscript fallback
This commit is contained in:
parent
961eccafa0
commit
2266dcd725
19 changed files with 597 additions and 604 deletions
|
|
@ -2,10 +2,9 @@ import type { LysandClient } from "@lysand-org/client";
|
|||
import { type RolePermissions, useCurrentIdentity } from "./Identities";
|
||||
|
||||
export const useCacheRefresh = (client: MaybeRef<LysandClient | null>) => {
|
||||
if (process.server) return;
|
||||
if (import.meta.server) return;
|
||||
|
||||
const identity = useCurrentIdentity();
|
||||
const instance = useInstance();
|
||||
|
||||
// Refresh custom emojis and instance data and me on every reload
|
||||
watchEffect(async () => {
|
||||
|
|
@ -56,7 +55,7 @@ export const useCacheRefresh = (client: MaybeRef<LysandClient | null>) => {
|
|||
toValue(client)
|
||||
?.getInstance()
|
||||
.then((res) => {
|
||||
instance.value = res.data;
|
||||
if (identity.value) identity.value.instance = res.data;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,15 +1,10 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import { StorageSerializers } from "@vueuse/core";
|
||||
|
||||
// Return type of LysandClient.getInstance
|
||||
export type Instance = Awaited<ReturnType<LysandClient["getInstance"]>>["data"];
|
||||
|
||||
export const useInstance = () => {
|
||||
if (process.server) {
|
||||
return ref(null);
|
||||
}
|
||||
const identity = useCurrentIdentity();
|
||||
|
||||
return useLocalStorage<Instance | null>("lysand:instance", null, {
|
||||
serializer: StorageSerializers.object,
|
||||
});
|
||||
return computed(() => identity.value?.instance);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue