Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
small fixes
zadam2e3534dfb7dd
diff --git a/src/entities/note.js b/src/entities/note.jsindex 3336f377a3..c110479d30 100644--- a/src/entities/note.js+++ b/src/entities/note.js@@ -36,7 +36,7 @@ const RELATION_DEFINITION = 'relation-definition';class Note extends Entity {static get entityName() { return "notes"; }static get primaryKeyName() { return "noteId"; }- static get hashedProperties() { return ["noteId", "title", "type", "isProtected", "isDeleted", "deleteId"]; }+ static get hashedProperties() { return ["noteId", "title", "type", "mime", "isProtected", "isDeleted", "deleteId"]; }/*** @param row - object containing database row from "notes" tablediff --git a/src/public/javascripts/widgets/note_detail.js b/src/public/javascripts/widgets/note_detail.jsindex 0c4085dd1c..7145a6daaf 100644--- a/src/public/javascripts/widgets/note_detail.js+++ b/src/public/javascripts/widgets/note_detail.js@@ -101,6 +101,7 @@ export default class NoteDetailWidget extends TabAwareWidget {this.toggle(true);this.type = await this.getWidgetType();+ this.mime = this.note.mime;if (!(this.type in this.typeWidgets)) {const clazz = typeWidgetClasses[this.type];@@ -218,10 +219,12 @@ export default class NoteDetailWidget extends TabAwareWidget {}async entitiesReloadedEvent({loadResults}) {- // we should test what happens when the loaded note is deleted+ // FIXME: we should test what happens when the loaded note is deleted- if (loadResults.isNoteContentReloaded(this.noteId, this.componentId)) {- this.refreshWithNote(this.note, this.notePath);+ if (loadResults.isNoteContentReloaded(this.noteId, this.componentId)+ || (loadResults.isNoteReloaded(this.noteId, this.componentId) && (this.type !== await this.getWidgetType() || this.mime !== this.note.mime))) {++ this.handleEvent('noteTypeMimeChanged', {noteId: this.noteId});}}diff --git a/src/public/javascripts/widgets/note_type.js b/src/public/javascripts/widgets/note_type.jsindex f3383d8c09..d33e26d17d 100644--- a/src/public/javascripts/widgets/note_type.js+++ b/src/public/javascripts/widgets/note_type.js@@ -118,6 +118,10 @@ export default class NoteTypeWidget extends TabAwareWidget {}async save(type, mime) {+ if (type === this.note.type && mime === this.note.mime) {+ return;+ }+if (type !== this.note.type && !await this.confirmChangeIfContent()) {return;}@@ -125,8 +129,6 @@ export default class NoteTypeWidget extends TabAwareWidget {await server.put('notes/' + this.noteId+ '/type/' + encodeURIComponent(type)+ '/mime/' + encodeURIComponent(mime));-- this.update();}async confirmChangeIfContent() {@@ -139,4 +141,10 @@ export default class NoteTypeWidget extends TabAwareWidget {const confirmDialog = await import("../dialogs/confirm.js");return await confirmDialog.confirm("It is not recommended to change note type when note content is not empty. Do you want to continue anyway?");}++ async entitiesReloadedEvent({loadResults}) {+ if (loadResults.isNoteReloaded(this.noteId, this.componentId)) {+ this.refresh();+ }+ }}\ No newline at end of filediff --git a/src/public/javascripts/widgets/tab_aware_widget.js b/src/public/javascripts/widgets/tab_aware_widget.jsindex 333c21c09a..df94d0115f 100644--- a/src/public/javascripts/widgets/tab_aware_widget.js+++ b/src/public/javascripts/widgets/tab_aware_widget.js@@ -36,6 +36,12 @@ export default class TabAwareWidget extends BasicWidget {}}+ noteTypeMimeChangedEvent({noteId}) {+ if (this.noteId === noteId) {+ this.refresh();+ }+ }+noteSwitched() {this.refresh();}