From e12be14dc9a873d77c7658828f55bc20b7da7065 Mon Sep 17 00:00:00 2001 From: Jin <22962980+JYC333@users.noreply.github.com> Date: Tue, 18 Mar 2025 17:39:59 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20remove=20redundant?= =?UTF-8?q?=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/app/components/tab_manager.ts | 14 ++++---------- src/public/app/widgets/tab_row.ts | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/public/app/components/tab_manager.ts b/src/public/app/components/tab_manager.ts index 8906d496a..4cac7a5e3 100644 --- a/src/public/app/components/tab_manager.ts +++ b/src/public/app/components/tab_manager.ts @@ -550,9 +550,7 @@ export default class TabManager extends Component { } async closeActiveTabCommand() { - if (this.activeNtxId) { - await this.removeNoteContext(this.activeNtxId); - } + await this.removeNoteContext(this.activeNtxId); } beforeUnloadEvent(): boolean { @@ -566,15 +564,13 @@ export default class TabManager extends Component { async closeAllTabsCommand() { for (const ntxIdToRemove of this.mainNoteContexts.map((nc) => nc.ntxId)) { - if (ntxIdToRemove) { - await this.removeNoteContext(ntxIdToRemove); - } + await this.removeNoteContext(ntxIdToRemove); } } async closeOtherTabsCommand({ ntxId }: { ntxId: string }) { for (const ntxIdToRemove of this.mainNoteContexts.map((nc) => nc.ntxId)) { - if (ntxIdToRemove && ntxIdToRemove !== ntxId) { + if (ntxIdToRemove !== ntxId) { await this.removeNoteContext(ntxIdToRemove); } } @@ -587,9 +583,7 @@ export default class TabManager extends Component { if (index !== -1) { const idsToRemove = ntxIds.slice(index + 1); for (const ntxIdToRemove of idsToRemove) { - if (ntxIdToRemove) { - await this.removeNoteContext(ntxIdToRemove); - } + await this.removeNoteContext(ntxIdToRemove); } } } diff --git a/src/public/app/widgets/tab_row.ts b/src/public/app/widgets/tab_row.ts index 0f60a9c2e..68557df3a 100644 --- a/src/public/app/widgets/tab_row.ts +++ b/src/public/app/widgets/tab_row.ts @@ -419,13 +419,13 @@ export default class TabRowWidget extends BasicWidget { closeActiveTabCommand({ $el }: CommandListenerData<"closeActiveTab">) { const ntxId = $el.closest(".note-tab").attr("data-ntx-id"); - appContext.tabManager.removeNoteContext(ntxId ?? null); + appContext.tabManager.removeNoteContext(ntxId); } setTabCloseEvent($tab: JQuery) { $tab.on("mousedown", (e) => { if (e.which === 2) { - appContext.tabManager.removeNoteContext($tab.attr("data-ntx-id") ?? null); + appContext.tabManager.removeNoteContext($tab.attr("data-ntx-id")); return true; // event has been handled }