mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
ensure isNewSceneVersion() does not increment currentVersion
This commit is contained in:
parent
3b1dcc7199
commit
6e535bac05
@ -67,6 +67,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
|
|||||||
this.refreshWithNote = this.refreshWithNote.bind(this);
|
this.refreshWithNote = this.refreshWithNote.bind(this);
|
||||||
this.onChangeHandler = this.onChangeHandler.bind(this);
|
this.onChangeHandler = this.onChangeHandler.bind(this);
|
||||||
this.isNewSceneVersion = this.isNewSceneVersion.bind(this);
|
this.isNewSceneVersion = this.isNewSceneVersion.bind(this);
|
||||||
|
this.updateSceneVersion = this.updateSceneVersion.bind(this);
|
||||||
this.getSceneVersion = this.getSceneVersion.bind(this);
|
this.getSceneVersion = this.getSceneVersion.bind(this);
|
||||||
|
|
||||||
// debugging helper
|
// debugging helper
|
||||||
@ -199,8 +200,9 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
|
|||||||
* Bug in excalidraw?! yes => see isNewSceneVersion()
|
* Bug in excalidraw?! yes => see isNewSceneVersion()
|
||||||
*/
|
*/
|
||||||
onChangeHandler() {
|
onChangeHandler() {
|
||||||
this.log("onChangeHandler() =================", new Date());
|
this.log("onChangeHandler() =================", new Date(), this.isNewSceneVersion());
|
||||||
if (this.isNewSceneVersion()) {
|
if (this.isNewSceneVersion()) {
|
||||||
|
this.updateSceneVersion();
|
||||||
this.saveData();
|
this.saveData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,8 +291,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
|
|||||||
* we compare the scene version as suggested in:
|
* we compare the scene version as suggested in:
|
||||||
* https://github.com/excalidraw/excalidraw/issues/3014#issuecomment-778115329
|
* https://github.com/excalidraw/excalidraw/issues/3014#issuecomment-778115329
|
||||||
*
|
*
|
||||||
* FIXME: calling it, increments scene version. calling it in a log and then for "real"
|
* info: sceneVersions are not incrementing. it seems to be a pseudo-random number
|
||||||
* will give wrong result
|
|
||||||
*/
|
*/
|
||||||
isNewSceneVersion() {
|
isNewSceneVersion() {
|
||||||
const sceneVersion = this.getSceneVersion();
|
const sceneVersion = this.getSceneVersion();
|
||||||
@ -299,8 +300,6 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
|
|||||||
this.currentSceneVersion === -1 // initial scene version update
|
this.currentSceneVersion === -1 // initial scene version update
|
||||||
|| this.currentSceneVersion !== sceneVersion
|
|| this.currentSceneVersion !== sceneVersion
|
||||||
) {
|
) {
|
||||||
this.log("isNewSceneVersion() YES - update!");
|
|
||||||
this.currentSceneVersion = sceneVersion;
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -312,5 +311,9 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
|
|||||||
const sceneVersion = window.Excalidraw.getSceneVersion(elements);
|
const sceneVersion = window.Excalidraw.getSceneVersion(elements);
|
||||||
return sceneVersion;
|
return sceneVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateSceneVersion() {
|
||||||
|
this.currentSceneVersion = this.getSceneVersion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user