fix(Omit in types): remove Omit from types to make hierarchy logical consistent and resulting errors from corrected logic.

This commit is contained in:
Jakob Schlanstedt 2025-10-22 16:16:58 +02:00
parent c6ed0b43fc
commit 00aa470bf2
2 changed files with 14 additions and 15 deletions

View File

@ -29,14 +29,15 @@ import dateNoteService from "../services/date_notes.js";
* *
* * Hierarchy of general to specific categories(hypernyms -> hyponyms): * * Hierarchy of general to specific categories(hypernyms -> hyponyms):
* *
* BaseCreateNoteSharedOpts * * BaseCreateNoteSharedOpts
* | * |
* \-- BaseCreateNoteOpts * \-- BaseCreateNoteOpts
* | * |
* +-- CreateNoteAtUrlOpts * +-- CreateNoteAtUrlOpts
* | +-- CreateNoteIntoURLOpts * | +-- CreateNoteIntoURLOpts
* | +-- CreateNoteBeforeURLOpts * | \-- CreateNoteSiblingURLOpts
* | \-- CreateNoteAfterURLOpts * | +-- CreateNoteBeforeURLOpts
* | \-- CreateNoteAfterURLOpts
* | * |
* \-- CreateNoteIntoInboxURLOpts * \-- CreateNoteIntoInboxURLOpts
*/ */
@ -56,7 +57,6 @@ type BaseCreateNoteSharedOpts = {
templateNoteId?: string; templateNoteId?: string;
activate?: boolean; activate?: boolean;
focus?: "title" | "content"; focus?: "title" | "content";
targetBranchId?: string;
textEditor?: CKTextEditor; textEditor?: CKTextEditor;
} }
@ -79,17 +79,16 @@ type CreateNoteAtUrlOpts = BaseCreateNoteOpts & {
// `Url` means either parentNotePath or parentNoteId. // `Url` means either parentNotePath or parentNoteId.
// The vocabulary is inspired by its loose semantics of getNoteIdFromUrl. // The vocabulary is inspired by its loose semantics of getNoteIdFromUrl.
parentNoteUrl: string; parentNoteUrl: string;
/*
* targetBranchId disambiguates the position for cloned notes. This is a
* concern whenever we are given a note URL.
*/
targetBranchId: string;
} }
export type CreateNoteIntoURLOpts = CreateNoteAtUrlOpts; export type CreateNoteIntoURLOpts = CreateNoteAtUrlOpts;
/* type CreateNoteSiblingURLOpts = CreateNoteAtUrlOpts;
* targetBranchId disambiguates the position for cloned notes. This is only a
* concern for siblings. The reason for that is specified in the backend.
*/
type CreateNoteSiblingURLOpts = Omit<CreateNoteAtUrlOpts, "targetBranchId"> & {
targetBranchId: string;
};
export type CreateNoteBeforeURLOpts = CreateNoteSiblingURLOpts; export type CreateNoteBeforeURLOpts = CreateNoteSiblingURLOpts;
export type CreateNoteAfterURLOpts = CreateNoteSiblingURLOpts; export type CreateNoteAfterURLOpts = CreateNoteSiblingURLOpts;

View File

@ -9,7 +9,7 @@ import branches from "../../../services/branches.js";
import Component from "../../../components/component.js"; import Component from "../../../components/component.js";
import NoteColorPicker from "../../../menus/custom-items/NoteColorPicker.jsx"; import NoteColorPicker from "../../../menus/custom-items/NoteColorPicker.jsx";
import { RefObject } from "preact"; import { RefObject } from "preact";
import { CreateNoteTarget } from "../../../services/note_create.js"; import { CreateNoteAfterURLOpts, CreateNoteBeforeURLOpts, CreateNoteTarget } from "../../../services/note_create.js";
export function useContextMenu(parentNote: FNote, parentComponent: Component | null | undefined, tabulator: RefObject<Tabulator>): Partial<EventCallBackMethods> { export function useContextMenu(parentNote: FNote, parentComponent: Component | null | undefined, tabulator: RefObject<Tabulator>): Partial<EventCallBackMethods> {
const events: Partial<EventCallBackMethods> = {}; const events: Partial<EventCallBackMethods> = {};
@ -186,7 +186,7 @@ export function showRowContextMenu(parentComponent: Component, e: MouseEvent, ro
customOpts: { customOpts: {
target: CreateNoteTarget.BeforeNoteURL, target: CreateNoteTarget.BeforeNoteURL,
targetBranchId: rowData.branchId, targetBranchId: rowData.branchId,
} } as CreateNoteBeforeURLOpts
}) })
}, },
{ {
@ -200,7 +200,7 @@ export function showRowContextMenu(parentComponent: Component, e: MouseEvent, ro
customOpts: { customOpts: {
target: CreateNoteTarget.AfterNoteURL, target: CreateNoteTarget.AfterNoteURL,
targetBranchId: branchId, targetBranchId: branchId,
} } as CreateNoteAfterURLOpts
}); });
} }
}, },
@ -213,7 +213,7 @@ export function showRowContextMenu(parentComponent: Component, e: MouseEvent, ro
customOpts: { customOpts: {
target: CreateNoteTarget.AfterNoteURL, target: CreateNoteTarget.AfterNoteURL,
targetBranchId: rowData.branchId, targetBranchId: rowData.branchId,
} } as CreateNoteAfterURLOpts
}) })
}, },
{ kind: "separator" }, { kind: "separator" },