fix: 🐛 can't move a tab to new window

This commit is contained in:
Jin 2025-03-05 13:40:58 +01:00
parent c9c18146f4
commit 0858f531e4

View File

@ -393,17 +393,17 @@ export default class TabManager extends Component {
this.setCurrentNavigationStateToHash(); this.setCurrentNavigationStateToHash();
} }
async removeNoteContext(ntxId: string | null) { async removeNoteContext(ntxId: string | null): Promise<boolean> {
// removing note context is an async process which can take some time, if users presses CTRL-W quickly, two // removing note context is an async process which can take some time, if users presses CTRL-W quickly, two
// close events could interleave which would then lead to attempting to activate already removed context. // close events could interleave which would then lead to attempting to activate already removed context.
return await this.mutex.runExclusively(async () => { return await this.mutex.runExclusively(async (): Promise<boolean> => {
let noteContextToRemove; let noteContextToRemove;
try { try {
noteContextToRemove = this.getNoteContextById(ntxId); noteContextToRemove = this.getNoteContextById(ntxId);
} catch { } catch {
// note context not found // note context not found
return; return false;
} }
if (noteContextToRemove.isMainContext()) { if (noteContextToRemove.isMainContext()) {
@ -413,7 +413,7 @@ export default class TabManager extends Component {
if (noteContextToRemove.isEmpty()) { if (noteContextToRemove.isEmpty()) {
// this is already the empty note context, no point in closing it and replacing with another // this is already the empty note context, no point in closing it and replacing with another
// empty tab // empty tab
return; return false;
} }
await this.openEmptyTab(); await this.openEmptyTab();
@ -451,6 +451,7 @@ export default class TabManager extends Component {
} }
this.removeNoteContexts(noteContextsToRemove); this.removeNoteContexts(noteContextsToRemove);
return true;
}); });
} }