Improve UX by opening file 1 after deleting file 2

This commit is contained in:
friebetill 2023-02-15 21:44:43 +08:00
parent fbd14edf23
commit 81c8172a11

View file

@ -1,5 +1,4 @@
import { Modal, TFile } from 'obsidian'
import { DifferencesView } from '../differences_view'
export class DeleteFileModal extends Modal {
constructor(args: {
@ -52,8 +51,12 @@ export class DeleteFileModal extends Modal {
this.app.vault.delete(this.file2)
this.close()
// Close currently active file
this.app.workspace.getActiveViewOfType(DifferencesView)?.leaf.detach()
const leaf = this.app.workspace.getMostRecentLeaf()
if (leaf != null) {
leaf.openFile(this.file1)
}
this.onDone(null)
}
}