Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 2ab22e7

Browse files
committed
fix(client): type errors due to command change
1 parent 147c340 commit 2ab22e7

File tree

7 files changed

+29
-18
lines changed

7 files changed

+29
-18
lines changed

src/public/app/components/app_context.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export interface ContextMenuCommandData extends CommandData {
5656
}
5757

5858
export interface NoteCommandData extends CommandData {
59-
notePath: string;
59+
notePath?: string;
6060
hoistedNoteId?: string;
6161
viewScope?: ViewScope;
6262
}
@@ -79,6 +79,7 @@ export type CommandMappings = {
7979
ancestorNoteId?: string | null;
8080
};
8181
closeTocCommand: CommandData;
82+
closeHlt: CommandData;
8283
showLaunchBarSubtree: CommandData;
8384
showRevisions: CommandData;
8485
showOptions: CommandData & {
@@ -113,6 +114,8 @@ export type CommandMappings = {
113114
openNoteInNewTab: CommandData;
114115
openNoteInNewSplit: CommandData;
115116
openNoteInNewWindow: CommandData;
117+
openAboutDialog: CommandData;
118+
hideFloatingButtons: {};
116119
hideLeftPane: CommandData;
117120
showLeftPane: CommandData;
118121
hoistNote: CommandData & { noteId: string };
@@ -129,7 +132,7 @@ export type CommandMappings = {
129132
protectSubtree: ContextMenuCommandData;
130133
unprotectSubtree: ContextMenuCommandData;
131134
openBulkActionsDialog: ContextMenuCommandData | {
132-
selectedOrActiveNoteIds: string[]
135+
selectedOrActiveNoteIds?: string[]
133136
};
134137
editBranchPrefix: ContextMenuCommandData;
135138
convertNoteToAttachment: ContextMenuCommandData;
@@ -186,6 +189,7 @@ export type CommandMappings = {
186189
importMarkdownInline: CommandData;
187190
showPasswordNotSet: CommandData;
188191
showProtectedSessionPasswordDialog: CommandData;
192+
showUploadAttachmentsDialog: CommandData & { noteId: string };
189193
closeProtectedSessionPasswordDialog: CommandData;
190194
copyImageReferenceToClipboard: CommandData;
191195
copyImageToClipboard: CommandData;
@@ -209,6 +213,7 @@ export type CommandMappings = {
209213
screen: Screen;
210214
};
211215
closeTab: CommandData;
216+
closeToc: CommandData;
212217
closeOtherTabs: CommandData;
213218
closeRightTabs: CommandData;
214219
closeAllTabs: CommandData;
@@ -227,15 +232,20 @@ export type CommandMappings = {
227232
scrollContainerToCommand: CommandData & {
228233
position: number;
229234
};
230-
moveThisNoteSplit: CommandData & {
231-
isMovingLeft: boolean;
232-
};
235+
scrollToEnd: CommandData;
236+
closeThisNoteSplit: CommandData;
237+
moveThisNoteSplit: CommandData & { isMovingLeft: boolean; };
233238

234239
// Geomap
235240
deleteFromMap: { noteId: string },
236241
openGeoLocation: { noteId: string, event: JQuery.MouseDownEvent }
237242

238243
toggleZenMode: CommandData;
244+
245+
updateAttributeList: CommandData & { attributes: Attribute[] };
246+
saveAttributes: CommandData;
247+
reloadAttributes: CommandData;
248+
refreshNoteList: CommandData & { noteId: string; };
239249
};
240250

241251
type EventMappings = {
@@ -336,7 +346,6 @@ type EventMappings = {
336346
showToc: {
337347
noteId: string;
338348
};
339-
scrollToEnd: { ntxId: string };
340349
noteTypeMimeChanged: { noteId: string };
341350
zenModeChanged: { isEnabled: boolean };
342351
};

src/public/app/components/component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ export class TypedComponent<ChildT extends TypedComponent<ChildT>> {
8080
return promises.length > 0 ? Promise.all(promises) : null;
8181
}
8282

83-
triggerCommand<K extends CommandNames>(name: K, _data?: CommandMappings[K]): Promise<unknown> | undefined | null {
84-
const data = _data || {};
83+
triggerCommand<K extends CommandNames>(name: K, data?: CommandMappings[K]): Promise<unknown> | undefined | null {
8584
const fun = (this as any)[`${name}Command`];
8685

8786
if (fun) {

src/public/app/menus/launcher_context_menu.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export default class LauncherContextMenu implements SelectMenuItemEventListener<
2121

2222
async show(e: PointerEvent | JQuery.TouchStartEvent | JQuery.ContextMenuEvent) {
2323
contextMenu.show({
24-
x: e.pageX,
25-
y: e.pageY,
24+
x: e.pageX ?? 0,
25+
y: e.pageY ?? 0,
2626
items: await this.getMenuItems(),
2727
selectMenuItemHandler: (item, e) => this.selectMenuItemHandler(item)
2828
});

src/public/app/menus/tree_context_menu.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
3131

3232
async show(e: PointerEvent | JQuery.TouchStartEvent | JQuery.ContextMenuEvent) {
3333
contextMenu.show({
34-
x: e.pageX,
35-
y: e.pageY,
34+
x: e.pageX ?? 0,
35+
y: e.pageY ?? 0,
3636
items: await this.getMenuItems(),
3737
selectMenuItemHandler: (item, e) => this.selectMenuItemHandler(item)
3838
});

src/public/app/services/hoisted_note.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import appContext from "../components/app_context.js";
2-
import treeService, { type Node } from "./tree.js";
2+
import treeService from "./tree.js";
33
import dialogService from "./dialog.js";
44
import froca from "./froca.js";
55
import type NoteContext from "../components/note_context.js";
@@ -19,11 +19,11 @@ async function unhoist() {
1919
}
2020
}
2121

22-
function isTopLevelNode(node: Node) {
22+
function isTopLevelNode(node: Fancytree.FancytreeNode) {
2323
return isHoistedNode(node.getParent());
2424
}
2525

26-
function isHoistedNode(node: Node) {
26+
function isHoistedNode(node: Fancytree.FancytreeNode) {
2727
// even though check for 'root' should not be necessary, we keep it just in case
2828
return node.data.noteId === "root" || node.data.noteId === getHoistedNoteId();
2929
}

src/routes/api/special_notes.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import dateNoteService from "../../services/date_notes.js";
44
import sql from "../../services/sql.js";
55
import cls from "../../services/cls.js";
6-
import specialNotesService from "../../services/special_notes.js";
6+
import specialNotesService, { type LauncherType } from "../../services/special_notes.js";
77
import becca from "../../becca/becca.js";
88
import type { Request } from "express";
99

@@ -85,7 +85,8 @@ function getHoistedNote() {
8585
function createLauncher(req: Request) {
8686
return specialNotesService.createLauncher({
8787
parentNoteId: req.params.parentNoteId,
88-
launcherType: req.params.launcherType
88+
// TODO: Validate the parameter
89+
launcherType: req.params.launcherType as LauncherType
8990
});
9091
}
9192

src/services/special_notes.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,11 @@ function createScriptLauncher(parentNoteId: string, forceNoteId?: string) {
156156
return note;
157157
}
158158

159+
export type LauncherType = "launcher" | "note" | "script" | "customWidget" | "spacer";
160+
159161
interface LauncherConfig {
160162
parentNoteId: string;
161-
launcherType: "launcher" | "note" | "script" | "customWidget" | "spacer";
163+
launcherType: LauncherType;
162164
noteId?: string;
163165
}
164166

0 commit comments

Comments
 (0)