mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
small fixes
This commit is contained in:
parent
d288c1b052
commit
2e3534dfb7
@ -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" table
|
||||
|
@ -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});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -36,6 +36,12 @@ export default class TabAwareWidget extends BasicWidget {
|
||||
}
|
||||
}
|
||||
|
||||
noteTypeMimeChangedEvent({noteId}) {
|
||||
if (this.noteId === noteId) {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
noteSwitched() {
|
||||
this.refresh();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user