Files
litlyx/dashboard/composables/useAppStart.ts
2025-11-28 16:49:20 +01:00

34 lines
994 B
TypeScript

import { toast } from 'vue-sonner';
async function loadData() {
const { loggedIn } = useUserSession();
if (!loggedIn.value) return;
const router = useRouter();
const projectStore = useProjectStore();
const snapshotStore = useSnapshotStore();
const domainStore = useDomainStore();
const premiumStore = usePremiumStore();
try {
await projectStore.fetchProjects();
if (projectStore.projects.length == 0) {
router.push('/create_project?first=true');
return false;
}
await projectStore.fetchActivePermissions();
await projectStore.fetchPendingInvites();
await snapshotStore.fetchSnapshots();
await domainStore.fetchDomains();
await premiumStore.fetchPremium();
return true;
} catch (ex: any) {
console.error(ex);
toast('Error', { description: ex.message, position: 'top-right' });
}
}
export function useAppStart() {
return { loadData }
}