mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	refactor: 💡 remove redundant code
This commit is contained in:
		@@ -550,9 +550,7 @@ export default class TabManager extends Component {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async closeActiveTabCommand() {
 | 
					    async closeActiveTabCommand() {
 | 
				
			||||||
        if (this.activeNtxId) {
 | 
					        await this.removeNoteContext(this.activeNtxId);
 | 
				
			||||||
            await this.removeNoteContext(this.activeNtxId);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    beforeUnloadEvent(): boolean {
 | 
					    beforeUnloadEvent(): boolean {
 | 
				
			||||||
@@ -566,15 +564,13 @@ export default class TabManager extends Component {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    async closeAllTabsCommand() {
 | 
					    async closeAllTabsCommand() {
 | 
				
			||||||
        for (const ntxIdToRemove of this.mainNoteContexts.map((nc) => nc.ntxId)) {
 | 
					        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 }) {
 | 
					    async closeOtherTabsCommand({ ntxId }: { ntxId: string }) {
 | 
				
			||||||
        for (const ntxIdToRemove of this.mainNoteContexts.map((nc) => nc.ntxId)) {
 | 
					        for (const ntxIdToRemove of this.mainNoteContexts.map((nc) => nc.ntxId)) {
 | 
				
			||||||
            if (ntxIdToRemove && ntxIdToRemove !== ntxId) {
 | 
					            if (ntxIdToRemove !== ntxId) {
 | 
				
			||||||
                await this.removeNoteContext(ntxIdToRemove);
 | 
					                await this.removeNoteContext(ntxIdToRemove);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -587,9 +583,7 @@ export default class TabManager extends Component {
 | 
				
			|||||||
        if (index !== -1) {
 | 
					        if (index !== -1) {
 | 
				
			||||||
            const idsToRemove = ntxIds.slice(index + 1);
 | 
					            const idsToRemove = ntxIds.slice(index + 1);
 | 
				
			||||||
            for (const ntxIdToRemove of idsToRemove) {
 | 
					            for (const ntxIdToRemove of idsToRemove) {
 | 
				
			||||||
                if (ntxIdToRemove) {
 | 
					                await this.removeNoteContext(ntxIdToRemove);
 | 
				
			||||||
                    await this.removeNoteContext(ntxIdToRemove);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -419,13 +419,13 @@ export default class TabRowWidget extends BasicWidget {
 | 
				
			|||||||
    closeActiveTabCommand({ $el }: CommandListenerData<"closeActiveTab">) {
 | 
					    closeActiveTabCommand({ $el }: CommandListenerData<"closeActiveTab">) {
 | 
				
			||||||
        const ntxId = $el.closest(".note-tab").attr("data-ntx-id");
 | 
					        const ntxId = $el.closest(".note-tab").attr("data-ntx-id");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        appContext.tabManager.removeNoteContext(ntxId ?? null);
 | 
					        appContext.tabManager.removeNoteContext(ntxId);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    setTabCloseEvent($tab: JQuery<HTMLElement>) {
 | 
					    setTabCloseEvent($tab: JQuery<HTMLElement>) {
 | 
				
			||||||
        $tab.on("mousedown", (e) => {
 | 
					        $tab.on("mousedown", (e) => {
 | 
				
			||||||
            if (e.which === 2) {
 | 
					            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
 | 
					                return true; // event has been handled
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user