fix(trash & sidebar): isolate trash view, sync list task counts in real-time, and fix restore/delete actions
Build and Push Docker Image / build-and-push (push) Successful in 10m24s
Build and Push Docker Image / build-and-push (push) Successful in 10m24s
This commit is contained in:
@@ -116,7 +116,7 @@ export function AppShell({ user, isDemo = false }: AppShellProps) {
|
||||
return () => document.removeEventListener("checkflow:openCommandPalette", handler);
|
||||
}, []);
|
||||
|
||||
// Demo tasks filter & reconstruct hierarchical structure
|
||||
// Task filter & reconstruct hierarchical structure for Demo and API modes
|
||||
useEffect(() => {
|
||||
if (isDemo) {
|
||||
const store = getDemoStore();
|
||||
@@ -130,6 +130,23 @@ export function AppShell({ user, isDemo = false }: AppShellProps) {
|
||||
(t) => !t.isDeleted && t.listId === selectedListId && (showCompleted ? true : !t.completed)
|
||||
);
|
||||
setTasks(listTasks);
|
||||
} else {
|
||||
setTasks([]);
|
||||
}
|
||||
} else {
|
||||
// Authenticated API mode
|
||||
if (isTrashActive) {
|
||||
setTasks([]);
|
||||
} else if (selectedTag) {
|
||||
fetch(`/api/tasks?tag=${encodeURIComponent(selectedTag)}&showCompleted=${showCompleted}`)
|
||||
.then((r) => (r.ok ? r.json() : []))
|
||||
.then((data) => setTasks(Array.isArray(data) ? data : []))
|
||||
.catch((err) => console.error("Failed to load tag tasks", err));
|
||||
} else if (selectedListId) {
|
||||
fetch(`/api/tasks?listId=${selectedListId}&showCompleted=${showCompleted}`)
|
||||
.then((r) => (r.ok ? r.json() : []))
|
||||
.then((data) => setTasks(Array.isArray(data) ? data : []))
|
||||
.catch((err) => console.error("Failed to load list tasks", err));
|
||||
}
|
||||
}
|
||||
}, [isDemo, selectedListId, isTrashActive, selectedTag, showCompleted, refreshKey]);
|
||||
@@ -161,18 +178,25 @@ export function AppShell({ user, isDemo = false }: AppShellProps) {
|
||||
|
||||
const handleTagSelect = useCallback((tagName: string | null) => {
|
||||
setIsTrashActive(false);
|
||||
setSelectedListId(null);
|
||||
setSelectedTag(tagName);
|
||||
setSelectedTask(null);
|
||||
setSidebarOpen(false);
|
||||
}, []);
|
||||
|
||||
const handleTrashSelect = useCallback(() => {
|
||||
setIsTrashActive(true);
|
||||
setSelectedTag(null);
|
||||
setSelectedListId(null);
|
||||
setSelectedTag(null);
|
||||
setIsTrashActive(true);
|
||||
setSelectedTask(null);
|
||||
setSidebarOpen(false);
|
||||
}, []);
|
||||
if (isDemo) {
|
||||
const store = getDemoStore();
|
||||
setTasks(getAllTrashTasks(store.tasks) as Task[]);
|
||||
} else {
|
||||
setTasks([]);
|
||||
}
|
||||
}, [isDemo]);
|
||||
|
||||
// Update List Name
|
||||
const handleUpdateListName = async (id: string, newName: string) => {
|
||||
|
||||
Reference in New Issue
Block a user