feat: Make whole app client-only, add noscript fallback

This commit is contained in:
Jesse Wierzbinski 2024-06-15 11:18:58 -10:00
parent 961eccafa0
commit 2266dcd725
No known key found for this signature in database
19 changed files with 597 additions and 604 deletions

View file

@ -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;
});
});
};

View file

@ -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);
};