Merge pull request #12 from abhi1693/jarvis/realtime-polling
Kanban: optional live updates (5s polling)
This commit is contained in:
@@ -21,10 +21,20 @@ export default function KanbanPage() {
|
|||||||
|
|
||||||
const [projectId, setProjectId] = useState<string>("");
|
const [projectId, setProjectId] = useState<string>("");
|
||||||
const [assigneeId, setAssigneeId] = useState<string>("");
|
const [assigneeId, setAssigneeId] = useState<string>("");
|
||||||
|
const [live, setLive] = useState(false);
|
||||||
|
|
||||||
const tasks = useListTasksTasksGet({
|
const tasks = useListTasksTasksGet(
|
||||||
...(projectId ? { project_id: Number(projectId) } : {}),
|
{
|
||||||
});
|
...(projectId ? { project_id: Number(projectId) } : {}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
query: {
|
||||||
|
enabled: true,
|
||||||
|
refetchInterval: live ? 5000 : false,
|
||||||
|
refetchIntervalInBackground: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
const taskList = useMemo(() => tasks.data ?? [], [tasks.data]);
|
const taskList = useMemo(() => tasks.data ?? [], [tasks.data]);
|
||||||
|
|
||||||
const updateTask = useUpdateTaskTasksTaskIdPatch({
|
const updateTask = useUpdateTaskTasksTaskIdPatch({
|
||||||
@@ -112,6 +122,16 @@ export default function KanbanPage() {
|
|||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between gap-2 rounded-md border p-2 text-sm">
|
||||||
|
<div>
|
||||||
|
<div className="font-medium">Live updates</div>
|
||||||
|
<div className="text-xs text-muted-foreground">Auto-refresh tasks every 5s on this page.</div>
|
||||||
|
</div>
|
||||||
|
<Button variant="outline" size="sm" onClick={() => setLive((v) => !v)}>
|
||||||
|
{live ? "On" : "Off"}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="text-xs text-muted-foreground">
|
<div className="text-xs text-muted-foreground">
|
||||||
Showing {filtered.length} / {taskList.length} tasks
|
Showing {filtered.length} / {taskList.length} tasks
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user