Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/collections/board: fix some issues
Adorian Doran8ba66afe278f
diff --git a/apps/client/src/widgets/collections/board/api.ts b/apps/client/src/widgets/collections/board/api.tsindex a61144f45a..8483f5051d 100644--- a/apps/client/src/widgets/collections/board/api.ts+++ b/apps/client/src/widgets/collections/board/api.ts@@ -54,14 +54,6 @@ interface ColumnClaim {records: boolean;}-/**- * The columns a board has in flight.- *- * Every write claims the columns it touches, and `renames` is what the last claim on each says.- * Claims are kept rather than a value and its predecessor because writes finish in any order: one- * taken back from under another leaves the one above it standing, and a column with no claims left- * has no record at all, whichever of the two failed first.- *//*** The collapse state the board draws while a filter narrows it, in place of the stored flags.*@@ -75,6 +67,14 @@ export interface VolatileCollapse {setCollapsed(column: string | null, collapsed: boolean): void;}+/**+ * The columns a board has in flight.+ *+ * Every write claims the columns it touches, and `renames` is what the last claim on each says.+ * Claims are kept rather than a value and its predecessor because writes finish in any order: one+ * taken back from under another leaves the one above it standing, and a column with no claims left+ * has no record at all, whichever of the two failed first.+ */export interface PendingColumnWrites {renames: Map<string, string | undefined>;claims: Map<string, ColumnClaim[]>;diff --git a/apps/client/src/widgets/collections/board/card_toolbar.tsx b/apps/client/src/widgets/collections/board/card_toolbar.tsxindex 2ea4a8c63c..3d1fd0a6fb 100644--- a/apps/client/src/widgets/collections/board/card_toolbar.tsx+++ b/apps/client/src/widgets/collections/board/card_toolbar.tsx@@ -14,55 +14,6 @@ import OverlayControlGroup, { OverlayControlButton } from "../../react/OverlayCo*/export const RAIL_EXIT_MS = 400;-/**- * Which rail stands on a board: one at a time, the latest to claim it. A rail arriving while- * another stands takes over in place, neither sliding in over it nor waiting for it to slide off.- * The one it replaces is hidden, and shown again once the newcomer has gone, unless it was on its- * way off itself, in which case it is dropped for good (see {@link Rail}).- */-export class RailStand {- /** Every rail that stands, in the order they claimed the stand; the last one is shown. */- private claimants: object[] = [];- private listeners = new Set<() => void>();-- /** Whether any rail stands, one leaving included. */- get isTaken() {- return this.claimants.length > 0;- }-- /** Whether a later rail stands over this one. */- isSuperseded(token: object) {- const index = this.claimants.indexOf(token);- return index >= 0 && index < this.claimants.length - 1;- }-- claim(token: object) {- if (this.claimants.at(-1) === token) return;- this.claimants = [ ...this.claimants.filter((other) => other !== token), token ];- this.notify();- }-- release(token: object) {- if (!this.claimants.includes(token)) return;- this.claimants = this.claimants.filter((other) => other !== token);- this.notify();- }-- subscribe(listener: () => void) {- this.listeners.add(listener);- return () => { this.listeners.delete(listener); };- }-- private notify() {- for (const listener of [ ...this.listeners ]) {- listener();- }- }-}--/** The board's stand, provided by the board so that two boards side by side keep their own. */-export const BoardRailContext = createContext(new RailStand());-interface CardToolbarProps {/** The board's element, which the toolbar floats over rather than the card it belongs to. */host: HTMLElement;@@ -227,6 +178,55 @@ export function ColumnToolbar({);}+/**+ * Which rail stands on a board: one at a time, the latest to claim it. A rail arriving while+ * another stands takes over in place, neither sliding in over it nor waiting for it to slide off.+ * The one it replaces is hidden, and shown again once the newcomer has gone, unless it was on its+ * way off itself, in which case it is dropped for good (see {@link Rail}).+ */+export class RailStand {+ /** Every rail that stands, in the order they claimed the stand; the last one is shown. */+ private claimants: object[] = [];+ private listeners = new Set<() => void>();++ /** Whether any rail stands, one leaving included. */+ get isTaken() {+ return this.claimants.length > 0;+ }++ /** Whether a later rail stands over this one. */+ isSuperseded(token: object) {+ const index = this.claimants.indexOf(token);+ return index >= 0 && index < this.claimants.length - 1;+ }++ claim(token: object) {+ if (this.claimants.at(-1) === token) return;+ this.claimants = [ ...this.claimants.filter((other) => other !== token), token ];+ this.notify();+ }++ release(token: object) {+ if (!this.claimants.includes(token)) return;+ this.claimants = this.claimants.filter((other) => other !== token);+ this.notify();+ }++ subscribe(listener: () => void) {+ this.listeners.add(listener);+ return () => { this.listeners.delete(listener); };+ }++ private notify() {+ for (const listener of [ ...this.listeners ]) {+ listener();+ }+ }+}++/** The board's stand, provided by the board so that two boards side by side keep their own. */+export const BoardRailContext = createContext(new RailStand());+interface RailProps {host: HTMLElement;isLeaving: boolean;