auto cancel fixes

This commit is contained in:
2026-02-27 16:41:37 -06:00
parent b420533214
commit 299eb03b05
+10 -4
View File
@@ -188,6 +188,7 @@ export interface Bucket {
interface TaskStore {
tasks: Task[];
isInitializing: boolean;
pWeight: number;
uWeight: number;
matrixScaleDays: number;
@@ -206,6 +207,7 @@ interface TaskStore {
// Initial empty state
export const [store, setStore] = createStore<TaskStore>({
tasks: [],
isInitializing: false,
pWeight: 1.0,
uWeight: 1.0,
matrixScaleDays: 30,
@@ -757,7 +759,8 @@ export const subscribeToRealtime = async () => {
};
export const initStore = async () => {
if (!pb.authStore.isValid) return;
if (!pb.authStore.isValid || store.isInitializing) return;
setStore("isInitializing", true);
// 0. Synchronous hydration from localStorage for "instant" first paint
const key = getStorageKey();
@@ -862,7 +865,7 @@ export const initStore = async () => {
const focusRecords = await pb.collection(TASGRID_COLLECTION).getList(1, 30, {
filter: `user = "${currentUserId}" && completed = false && deletedAt = ""`,
sort: '-priority,dueDate',
requestKey: 'initial_focus'
requestKey: null
});
// Filter out templates client-side to ensure tasks with empty/null tags aren't excluded by DB
@@ -1062,7 +1065,7 @@ export const initStore = async () => {
try {
const templates = await pb.collection(TASGRID_COLLECTION).getFullList({
filter: `user = "${currentUserId}" && tags ~ "__template__"`,
requestKey: 'templates_load'
requestKey: null
});
const loadedTemplates = templates.map(r => {
let meta: any = {};
@@ -1090,6 +1093,8 @@ export const initStore = async () => {
console.error("Failed to load data:", err);
toast.error("Failed to sync with server.");
}
} finally {
setStore("isInitializing", false);
}
};
@@ -2143,7 +2148,8 @@ export const loadShareRules = async () => {
try {
const currentUserId = pb.authStore.model?.id;
const records = await pb.collection(SHARE_RULES_COLLECTION).getFullList({
filter: `ownerId = "${currentUserId}" || targetUserId = "${currentUserId}"`
filter: `ownerId = "${currentUserId}" || targetUserId = "${currentUserId}"`,
requestKey: null
});
const rules: ShareRule[] = records.map(r => ({