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):
*
* BaseCreateNoteSharedOpts
* * BaseCreateNoteSharedOpts
* |
* \-- BaseCreateNoteOpts
* |
* +-- CreateNoteAtUrlOpts
* | +-- CreateNoteIntoURLOpts
* | +-- CreateNoteBeforeURLOpts
* | \-- CreateNoteAfterURLOpts
* | \-- CreateNoteSiblingURLOpts
* | +-- CreateNoteBeforeURLOpts
* | \-- CreateNoteAfterURLOpts
* |
* \-- CreateNoteIntoInboxURLOpts
*/
@ -56,7 +57,6 @@ type BaseCreateNoteSharedOpts = {
templateNoteId?: string;
activate?: boolean;
focus?: "title" | "content";
targetBranchId?: string;
textEditor?: CKTextEditor;
}
@ -79,17 +79,16 @@ type CreateNoteAtUrlOpts = BaseCreateNoteOpts & {
// `Url` means either parentNotePath or parentNoteId.
// The vocabulary is inspired by its loose semantics of getNoteIdFromUrl.
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;
/*
* 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;
};
type CreateNoteSiblingURLOpts = CreateNoteAtUrlOpts;
export type CreateNoteBeforeURLOpts = CreateNoteSiblingURLOpts;
export type CreateNoteAfterURLOpts = CreateNoteSiblingURLOpts;

View File

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