feat(ui): back and forward also step through task lists and lists
The open task list and the open list are part of the place in the browser history; the app's own choice of a first list replaces the entry. Going back to a task list shows its tasks from memory right away. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
83bba8d20b
commit
b3767ab387
3 files changed
+42
-5
No files matched your search
@@ -42,6 +42,7 @@ import { AvatarStack, AvatarPerson } from '../../components/AvatarStack';
|
||||
import { CountBadge } from '../../components/CountBadge';
|
||||
import { ListSwitcher } from '../../components/ListSwitcher';
|
||||
import { isPhoneWidth } from '../../lib/breakpoints';
|
||||
import { reportNav, onNavStep, restoringNavPlace } from '../../lib/navHistory';
|
||||
import { LivePill } from '../../components/LivePill';
|
||||
import { FormSheet } from '../../components/FormSheet';
|
||||
import { EmojiIconButton } from '../../components/EmojiIconButton';
|
||||
@@ -181,7 +182,11 @@ export const TasksView: React.FC<TasksViewProps> = ({
|
||||
const [tasks, setTasks] = useState<Thought[]>([]);
|
||||
const [taskLists, setTaskLists] = useState<TaskList[]>([]);
|
||||
const [selectedListId, setSelectedListIdState] = useState<string>(
|
||||
() => remembered.listId || 'all'
|
||||
() => {
|
||||
// Coming back here by the browser's back/forward: the list of that step
|
||||
const step = restoringNavPlace();
|
||||
return (step?.tab === 'tasks' && step.taskList) || remembered.listId || 'all';
|
||||
}
|
||||
);
|
||||
const viewMode: ViewMode = viewModes[selectedListId] || 'list';
|
||||
// Only Kanban is stored; the list view is the default
|
||||
@@ -365,6 +370,16 @@ export const TasksView: React.FC<TasksViewProps> = ({
|
||||
setSelectedListIdState(id);
|
||||
}, []);
|
||||
|
||||
// Switching task lists is a step of the browser history (lib/navHistory.ts)
|
||||
useEffect(() => reportNav({ taskList: selectedListId }), [selectedListId]);
|
||||
useEffect(
|
||||
() =>
|
||||
onNavStep((place) => {
|
||||
if (place.tab === 'tasks' && place.taskList) setSelectedListId(place.taskList);
|
||||
}),
|
||||
[setSelectedListId]
|
||||
);
|
||||
|
||||
const onRefreshStatsRef = useRef(onRefreshStats);
|
||||
onRefreshStatsRef.current = onRefreshStats;
|
||||
// The realtime handler is registered once; it must reload with the current list, not the first one
|
||||
|
||||
Reference in new issue
Block a user