Skip to content

Commit 3b261c0

Browse files
Made sure force reload only happens if there is absolutely no data unsaved
1 parent ad6ceb5 commit 3b261c0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/patchers/canvas-patcher.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,15 @@ export default class CanvasPatcher extends Patcher {
298298
})])
299299

300300
// Canvas is now patched - update all open canvas views
301-
this.plugin.app.workspace.iterateAllLeaves((leaf: WorkspaceLeaf) => {
301+
this.plugin.app.workspace.iterateAllLeaves(async (leaf: WorkspaceLeaf) => {
302302
if (leaf.view.getViewType() !== 'canvas') return
303303

304304
const canvasView = leaf.view as any as Omit<CanvasView, 'onClose'> & { onClose: () => void }
305-
const hasChangesToSave = canvasView.lastSavedData !== canvasView.data
305+
const currentData = canvasView.getViewData()
306+
const savedData = canvasView.file ? await this.plugin.app.vault.read(canvasView.file) : null
307+
const hasChangesToSave = currentData !== savedData
308+
309+
console.debug(`Reloading canvas view (Saving: ${hasChangesToSave})`)
306310

307311
// Skip saving the canvas data if there are no changes to save (Remote sync compatibility)
308312
const originalOnClose = canvasView.onClose

0 commit comments

Comments
 (0)