mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-01 04:32:26 +08:00
refactor: 💡 remove redundant code
This commit is contained in:
parent
0858f531e4
commit
e12be14dc9
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user