Something went wrong. Try again.
A simple to-do app focused on tasks that can be completed within a specific time span. taskline.tobinio.dev
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758import { useCategoryStore } from "~/stores/useCategoryStore";import { useTagStore } from "~/stores/useTagStore";
export async function useInitdata(id: Ref<string | undefined>) { const todoStore = useTodoStore(); const tagStore = useTagStore(); const categoryStore = useCategoryStore();
const Init = { client() { todoStore.initSSE(); tagStore.initSSE(); categoryStore.initSSE(); }, async data() { await Promise.all([ todoStore.fetch(), tagStore.fetch(), categoryStore.fetch(), ]); }, async all() { Init.client(); await Init.data(); }, };
function reset() { todoStore.reset(); tagStore.reset(); categoryStore.reset(); }
onMounted(async () => { // Timeout to to avoid betterAuth id flicker (undefined -> value) setTimeout(() => { Init.client();
watch(id, async () => { console.log(id.value); if (id.value) Init.all(); else reset(); }); }, 1000); });
await callOnce(async () => { if (id.value) await Init.data(); });
const focus = useWindowFocus(); watch([focus], async ([focus]) => { if (focus && id.value) { await Init.data(); } });}