mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
protection against note switching race conditions
This commit is contained in:
parent
dce54c7af3
commit
45c5287d53
@ -55,18 +55,21 @@ class NoteDetailCode {
|
|||||||
this.onNoteChange(() => this.ctx.noteChanged());
|
this.onNoteChange(() => this.ctx.noteChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
// CodeMirror breaks pretty badly on null so even though it shouldn't happen (guarded by consistency check)
|
// lazy loading above can take time and tab might have been already switched to another note
|
||||||
// we provide fallback
|
if (this.ctx.note && this.ctx.note.type === 'code') {
|
||||||
this.codeEditor.setValue(this.ctx.note.content || "");
|
// CodeMirror breaks pretty badly on null so even though it shouldn't happen (guarded by consistency check)
|
||||||
|
// we provide fallback
|
||||||
|
this.codeEditor.setValue(this.ctx.note.content || "");
|
||||||
|
|
||||||
const info = CodeMirror.findModeByMIME(this.ctx.note.mime);
|
const info = CodeMirror.findModeByMIME(this.ctx.note.mime);
|
||||||
|
|
||||||
if (info) {
|
if (info) {
|
||||||
this.codeEditor.setOption("mode", info.mime);
|
this.codeEditor.setOption("mode", info.mime);
|
||||||
CodeMirror.autoLoadMode(this.codeEditor, info.mode);
|
CodeMirror.autoLoadMode(this.codeEditor, info.mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
|
@ -238,14 +238,17 @@ class NoteDetailRelationMap {
|
|||||||
|
|
||||||
await libraryLoader.requireLibrary(libraryLoader.RELATION_MAP);
|
await libraryLoader.requireLibrary(libraryLoader.RELATION_MAP);
|
||||||
|
|
||||||
this.loadMapData();
|
|
||||||
|
|
||||||
jsPlumb.ready(() => {
|
jsPlumb.ready(() => {
|
||||||
this.initJsPlumbInstance();
|
// lazy loading above can take time and tab might have been already switched to another note
|
||||||
|
if (this.ctx.note && this.ctx.note.type === 'relation-map') {
|
||||||
|
this.loadMapData();
|
||||||
|
|
||||||
this.initPanZoom();
|
this.initJsPlumbInstance();
|
||||||
|
|
||||||
this.loadNotesAndRelations();
|
this.initPanZoom();
|
||||||
|
|
||||||
|
this.loadNotesAndRelations();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,11 +98,14 @@ class NoteDetailText {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.textEditor.isReadOnly = await this.isReadOnly();
|
// lazy loading above can take time and tab might have been already switched to another note
|
||||||
|
if (this.ctx.note && this.ctx.note.type === 'text') {
|
||||||
|
this.textEditor.isReadOnly = await this.isReadOnly();
|
||||||
|
|
||||||
this.$component.show();
|
this.$component.show();
|
||||||
|
|
||||||
this.textEditor.setData(this.ctx.note.content);
|
this.textEditor.setData(this.ctx.note.content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getContent() {
|
getContent() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user