Skip to content

Commit 3327bb0

Browse files
Jakob Schlanstedtwerererer
authored andcommitted
refactor(note_create): simplify type implementation and documentation
1 parent 1dede04 commit 3327bb0

File tree

14 files changed

+141
-166
lines changed

14 files changed

+141
-166
lines changed

apps/client/src/components/entrypoints.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import froca from "../services/froca.js";
1111
import linkService from "../services/link.js";
1212
import { t } from "../services/i18n.js";
1313
import { CreateChildrenResponse, SqlExecuteResponse } from "@triliumnext/commons";
14-
import noteCreateService, { CreateNoteIntoInboxURLOpts, CreateNoteTarget } from "../services/note_create.js";
14+
import noteCreateService, { CreateNoteIntoInboxOpts, CreateNoteTarget } from "../services/note_create.js";
1515

1616
export default class Entrypoints extends Component {
1717
constructor() {
@@ -26,7 +26,7 @@ export default class Entrypoints extends Component {
2626

2727
async createNoteIntoInboxCommand() {
2828
await noteCreateService.createNote(
29-
{ target: CreateNoteTarget.IntoInbox } as CreateNoteIntoInboxURLOpts
29+
{ target: CreateNoteTarget.IntoInbox } as CreateNoteIntoInboxOpts
3030
);
3131
}
3232

apps/client/src/components/main_tree_executors.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import appContext, { type EventData } from "./app_context.js";
2-
import noteCreateService, { CreateNoteTarget, CreateNoteIntoURLOpts, CreateNoteAfterURLOpts } from "../services/note_create.js";
2+
import noteCreateService, { CreateNoteTarget, CreateNoteIntoUrlOpts, CreateNoteAfterUrlOpts } from "../services/note_create.js";
33
import treeService from "../services/tree.js";
44
import hoistedNoteService from "../services/hoisted_note.js";
55
import Component from "./component.js";
@@ -55,7 +55,7 @@ export default class MainTreeExecutors extends Component {
5555
isProtected: activeNoteContext.note.isProtected,
5656
saveSelection: false,
5757
promptForType: false,
58-
} as CreateNoteIntoURLOpts
58+
} as CreateNoteIntoUrlOpts
5959
);
6060
}
6161

@@ -84,7 +84,7 @@ export default class MainTreeExecutors extends Component {
8484
targetBranchId: node.data.branchId,
8585
isProtected: isProtected,
8686
saveSelection: false
87-
} as CreateNoteAfterURLOpts
87+
} as CreateNoteAfterUrlOpts
8888
);
8989
}
9090
}

apps/client/src/components/root_command_executor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import froca from "../services/froca.js";
99
import utils from "../services/utils.js";
1010
import LlmChatPanel from "../widgets/llm_chat_panel.js";
1111
import toastService from "../services/toast.js";
12-
import noteCreateService, { CreateNoteIntoURLOpts, CreateNoteTarget } from "../services/note_create.js";
12+
import noteCreateService, { CreateNoteIntoUrlOpts, CreateNoteTarget } from "../services/note_create.js";
1313

1414
export default class RootCommandExecutor extends Component {
1515
editReadOnlyNoteCommand() {
@@ -242,7 +242,7 @@ export default class RootCommandExecutor extends Component {
242242
messages: [],
243243
title: "New AI Chat"
244244
}),
245-
} as CreateNoteIntoURLOpts
245+
} as CreateNoteIntoUrlOpts
246246
);
247247

248248
if (!result.note) {

apps/client/src/menus/tree_context_menu.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import treeService from "../services/tree.js";
22
import froca from "../services/froca.js";
33
import clipboard from "../services/clipboard.js";
4-
import noteCreateService, { CreateNoteAfterURLOpts, CreateNoteIntoURLOpts, CreateNoteTarget } from "../services/note_create.js";
4+
import noteCreateService, { CreateNoteAfterUrlOpts, CreateNoteIntoUrlOpts, CreateNoteTarget } from "../services/note_create.js";
55
import contextMenu, { type MenuCommandItem, type MenuItem } from "./context_menu.js";
66
import appContext, { type ContextMenuCommandData, type FilteredCommandNames } from "../components/app_context.js";
77
import noteTypesService from "../services/note_types.js";
@@ -283,7 +283,7 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
283283
isProtected: isProtected,
284284
templateNoteId: templateNoteId,
285285
promptForType: false,
286-
} as CreateNoteAfterURLOpts
286+
} as CreateNoteAfterUrlOpts
287287
);
288288
} else if (command === "insertChildNote") {
289289
const parentNotePath = treeService.getNotePath(this.node);
@@ -296,7 +296,7 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
296296
isProtected: this.node.data.isProtected,
297297
templateNoteId: templateNoteId,
298298
promptForType: false,
299-
} as CreateNoteIntoURLOpts
299+
} as CreateNoteIntoUrlOpts
300300
);
301301
} else if (command === "openNoteInSplit") {
302302
const subContexts = appContext.tabManager.getActiveContext()?.getSubContexts();

apps/client/src/services/note_autocomplete.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import server from "./server.js";
22
import appContext from "../components/app_context.js";
3-
import noteCreateService, { CreateNoteIntoURLOpts, CreateNoteTarget, CreateNoteIntoInboxURLOpts } from "./note_create.js";
3+
import noteCreateService, { CreateNoteIntoUrlOpts, CreateNoteTarget, CreateNoteIntoInboxOpts } from "./note_create.js";
44
import froca from "./froca.js";
55
import { t } from "./i18n.js";
66
import commandRegistry from "./command_registry.js";
@@ -487,7 +487,7 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
487487
title: suggestion.noteTitle,
488488
activate: true,
489489
promptForType: true,
490-
} as CreateNoteIntoInboxURLOpts
490+
} as CreateNoteIntoInboxOpts
491491
);
492492

493493
if (!note) return;
@@ -507,7 +507,7 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
507507
title: suggestion.noteTitle,
508508
activate: false,
509509
promptForType: true,
510-
} as CreateNoteIntoInboxURLOpts,
510+
} as CreateNoteIntoInboxOpts,
511511
);
512512

513513
if (!note) return;
@@ -528,7 +528,7 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
528528
title: suggestion.noteTitle,
529529
activate: true,
530530
promptForType: true,
531-
} as CreateNoteIntoURLOpts,
531+
} as CreateNoteIntoUrlOpts,
532532
);
533533

534534
if (!note) return;
@@ -549,7 +549,7 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
549549
title: suggestion.noteTitle,
550550
activate: false,
551551
promptForType: true,
552-
} as CreateNoteIntoURLOpts
552+
} as CreateNoteIntoUrlOpts
553553
);
554554

555555
if (!note) return;

0 commit comments

Comments
 (0)