port tab manager to ts

This commit is contained in:
Jin
2025-03-03 01:04:42 +01:00
parent 8e0b9d17a4
commit 45a50f3aa1
9 changed files with 233 additions and 156 deletions

View File

@@ -66,12 +66,13 @@ export default class Entrypoints extends Component {
}
async toggleNoteHoistingCommand({ noteId = appContext.tabManager.getActiveContextNoteId() }) {
if (!noteId) {
const activeNoteContext = appContext.tabManager.getActiveContext();
if (!activeNoteContext || !noteId) {
return;
}
const noteToHoist = await froca.getNote(noteId);
const activeNoteContext = appContext.tabManager.getActiveContext();
if (noteToHoist?.noteId === activeNoteContext.hoistedNoteId) {
await activeNoteContext.unhoist();
@@ -83,6 +84,11 @@ export default class Entrypoints extends Component {
async hoistNoteCommand({ noteId }: { noteId: string }) {
const noteContext = appContext.tabManager.getActiveContext();
if (!noteContext) {
logError("hoistNoteCommand: noteContext is null");
return;
}
if (noteContext.hoistedNoteId !== noteId) {
await noteContext.setHoistedNoteId(noteId);
}
@@ -174,7 +180,11 @@ export default class Entrypoints extends Component {
}
async runActiveNoteCommand() {
const { ntxId, note } = appContext.tabManager.getActiveContext();
const noteContext = appContext.tabManager.getActiveContext();
if (!noteContext) {
return;
}
const { ntxId, note } = noteContext;
// ctrl+enter is also used elsewhere, so make sure we're running only when appropriate
if (!note || note.type !== "code") {