Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
refactor: 💡 remove redundant code
Jine12be14dc9a8
diff --git a/src/public/app/components/tab_manager.ts b/src/public/app/components/tab_manager.tsindex 8906d496a6..4cac7a5e37 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.tsindex 0f60a9c2e3..68557df3af 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<HTMLElement>) {$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}