Lock the right pane while focused, add project focus, quiet lead
This commit is contained in:
+6
-11
@@ -2,7 +2,7 @@ import { get, post, type ByreEvent, type Project, type Schemas } 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";
|
||||
|
||||
type Todo = Schemas["Todo"];
|
||||
type TodoItem = Schemas["TodoItem"];
|
||||
@@ -14,15 +14,10 @@ export function mountTodo(root: HTMLElement): () => void {
|
||||
const starting = new Set<string>();
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -39,7 +34,7 @@ export function mountTodo(root: HTMLElement): () => void {
|
||||
};
|
||||
|
||||
const refresh = () => {
|
||||
const p = project();
|
||||
const p = focusedProject();
|
||||
if (p) {
|
||||
void load(p.id);
|
||||
}
|
||||
@@ -77,9 +72,9 @@ export function mountTodo(root: HTMLElement): () => void {
|
||||
}
|
||||
}),
|
||||
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