mirror of
https://github.com/williamsjack/pairwise-glicko-ranking.git
synced 2026-07-22 06:44:09 +00:00
Clear stale leaf and show toast for deleted file
Fixes bug where a different note is shown in the session bar and the leaf that contained the deleted file.
This commit is contained in:
parent
dd080a3488
commit
d1a30c7fd1
1 changed files with 6 additions and 3 deletions
|
|
@ -232,10 +232,13 @@ export default class ArenaSession {
|
|||
if (deletedWasVisible) {
|
||||
this.lastPair = undefined;
|
||||
|
||||
// Wait to ensure deleted file is cleaned up before reusing leaf
|
||||
await new Promise((resolve) => window.setTimeout(resolve, 0));
|
||||
await new Promise((resolve) => window.setTimeout(resolve, 0));
|
||||
// Pre-emptively clear the stale leaf so Obsidian's cleanup
|
||||
// doesn't race with our setViewState and overwrite the new file.
|
||||
const staleLeaf = this.leftFile?.path === deletedPath ? this.leftLeaf : this.rightLeaf;
|
||||
await staleLeaf.setViewState({ type: 'empty', state: {} });
|
||||
|
||||
const deletedName = deletedPath.replace(/.*\//, '').replace(/\.md$/i, '');
|
||||
this.showToast(`Match skipped - "${deletedName}" was deleted.`);
|
||||
this.pickNextPair();
|
||||
await this.openCurrent();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue