Lock the right pane while focused, add project focus, quiet lead
This commit is contained in:
Vendored
+6
-10
@@ -2,20 +2,16 @@ import { get, post } from "./api.js";
|
||||
import { errorText, h, replace, showAlert } from "./dom.js";
|
||||
import { markdown } from "./markdown.js";
|
||||
import { models } from "./task.js";
|
||||
import { currentSession, findTask, focusTask, on, onEach, state } from "./state.js";
|
||||
import { currentSession, focusedProject, focusTask, on, onEach, state } from "./state.js";
|
||||
const refreshKinds = new Set(["task.merged", "project.created"]);
|
||||
export function mountTodo(root) {
|
||||
const todos = new Map();
|
||||
const starting = new Set();
|
||||
let disposed = false;
|
||||
const project = () => {
|
||||
const task = state.selectedTaskId ? findTask(state.selectedTaskId) : undefined;
|
||||
return state.projects.find((p) => p.id === task?.project_id);
|
||||
};
|
||||
const render = () => {
|
||||
const scrollTop = root.querySelector(".todo-view")?.scrollTop ?? 0;
|
||||
const p = project();
|
||||
replace(root, h("div", { class: "todo-view" }, p ? projectBlock(p, todos.get(p.id), starting, start) : h("div", { class: "empty" }, "No task selected.")));
|
||||
const p = focusedProject();
|
||||
replace(root, h("div", { class: "todo-view" }, p ? projectBlock(p, todos.get(p.id), starting, start) : h("div", { class: "empty" }, "No project selected.")));
|
||||
root.querySelector(".todo-view").scrollTop = scrollTop;
|
||||
};
|
||||
const load = async (projectId) => {
|
||||
@@ -31,7 +27,7 @@ export function mountTodo(root) {
|
||||
}
|
||||
};
|
||||
const refresh = () => {
|
||||
const p = project();
|
||||
const p = focusedProject();
|
||||
if (p) {
|
||||
void load(p.id);
|
||||
}
|
||||
@@ -68,9 +64,9 @@ export function mountTodo(root) {
|
||||
}
|
||||
}),
|
||||
on("projects", refresh),
|
||||
on("selection", () => {
|
||||
onEach(["focus", "selection"], () => {
|
||||
render();
|
||||
const p = project();
|
||||
const p = focusedProject();
|
||||
if (p && !todos.has(p.id)) {
|
||||
void load(p.id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user