Skip to content

Commit 591bb72

Browse files
Jakob Schlanstedtwerererer
authored andcommitted
fix(Omit in types): remove Omit from types to make hierarchy logical consistent and resulting errors from corrected logic.
1 parent ee532ee commit 591bb72

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

apps/client/src/services/note_create.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ import dateNoteService from "../services/date_notes.js";
2929
*
3030
* * Hierarchy of general to specific categories(hypernyms -> hyponyms):
3131
*
32-
* BaseCreateNoteSharedOpts
32+
* * BaseCreateNoteSharedOpts
3333
* |
3434
* \-- BaseCreateNoteOpts
3535
* |
3636
* +-- CreateNoteAtUrlOpts
3737
* | +-- CreateNoteIntoURLOpts
38-
* | +-- CreateNoteBeforeURLOpts
39-
* | \-- CreateNoteAfterURLOpts
38+
* | \-- CreateNoteSiblingURLOpts
39+
* | +-- CreateNoteBeforeURLOpts
40+
* | \-- CreateNoteAfterURLOpts
4041
* |
4142
* \-- CreateNoteIntoInboxURLOpts
4243
*/
@@ -56,7 +57,6 @@ type BaseCreateNoteSharedOpts = {
5657
templateNoteId?: string;
5758
activate?: boolean;
5859
focus?: "title" | "content";
59-
targetBranchId?: string;
6060
textEditor?: CKTextEditor;
6161
}
6262

@@ -79,17 +79,16 @@ type CreateNoteAtUrlOpts = BaseCreateNoteOpts & {
7979
// `Url` means either parentNotePath or parentNoteId.
8080
// The vocabulary is inspired by its loose semantics of getNoteIdFromUrl.
8181
parentNoteUrl: string;
82+
/*
83+
* targetBranchId disambiguates the position for cloned notes. This is a
84+
* concern whenever we are given a note URL.
85+
*/
86+
targetBranchId: string;
8287
}
8388

8489
export type CreateNoteIntoURLOpts = CreateNoteAtUrlOpts;
8590

86-
/*
87-
* targetBranchId disambiguates the position for cloned notes. This is only a
88-
* concern for siblings. The reason for that is specified in the backend.
89-
*/
90-
type CreateNoteSiblingURLOpts = Omit<CreateNoteAtUrlOpts, "targetBranchId"> & {
91-
targetBranchId: string;
92-
};
91+
type CreateNoteSiblingURLOpts = CreateNoteAtUrlOpts;
9392
export type CreateNoteBeforeURLOpts = CreateNoteSiblingURLOpts;
9493
export type CreateNoteAfterURLOpts = CreateNoteSiblingURLOpts;
9594

apps/client/src/widgets/collections/table/context_menu.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import froca from "../../../services/froca.js";
88
import branches from "../../../services/branches.js";
99
import Component from "../../../components/component.js";
1010
import { RefObject } from "preact";
11-
import { CreateNoteTarget } from "../../../services/note_create.js";
11+
import { CreateNoteAfterURLOpts, CreateNoteBeforeURLOpts, CreateNoteTarget } from "../../../services/note_create.js";
1212

1313
export function useContextMenu(parentNote: FNote, parentComponent: Component | null | undefined, tabulator: RefObject<Tabulator>): Partial<EventCallBackMethods> {
1414
const events: Partial<EventCallBackMethods> = {};
@@ -185,7 +185,7 @@ export function showRowContextMenu(parentComponent: Component, e: MouseEvent, ro
185185
customOpts: {
186186
target: CreateNoteTarget.BeforeNoteURL,
187187
targetBranchId: rowData.branchId,
188-
}
188+
} as CreateNoteBeforeURLOpts
189189
})
190190
},
191191
{
@@ -199,7 +199,7 @@ export function showRowContextMenu(parentComponent: Component, e: MouseEvent, ro
199199
customOpts: {
200200
target: CreateNoteTarget.AfterNoteURL,
201201
targetBranchId: branchId,
202-
}
202+
} as CreateNoteAfterURLOpts
203203
});
204204
}
205205
},
@@ -212,7 +212,7 @@ export function showRowContextMenu(parentComponent: Component, e: MouseEvent, ro
212212
customOpts: {
213213
target: CreateNoteTarget.AfterNoteURL,
214214
targetBranchId: rowData.branchId,
215-
}
215+
} as CreateNoteAfterURLOpts
216216
})
217217
},
218218
{ kind: "separator" },

0 commit comments

Comments
 (0)