similar notes is getting updated automatically after the title change

This commit is contained in:
zadam
2019-09-03 21:31:39 +02:00
parent 9404e27cba
commit 2e05cb1764
10 changed files with 53 additions and 30 deletions

View File

@@ -2,8 +2,6 @@ import StandardWidget from "./standard_widget.js";
import linkService from "../services/link.js";
import server from "../services/server.js";
import treeCache from "../services/tree_cache.js";
import treeUtils from "../services/tree_utils.js";
import treeService from "../services/tree.js";
class SimilarNotesWidget extends StandardWidget {
getWidgetTitle() { return "Similar notes"; }
@@ -11,6 +9,9 @@ class SimilarNotesWidget extends StandardWidget {
getMaxHeight() { return "200px"; }
async doRenderBody() {
// remember which title was when we found the similar notes
this.title = this.ctx.note.title;
const similarNotes = await server.get('similar_notes/' + this.ctx.note.noteId);
if (similarNotes.length === 0) {
@@ -39,6 +40,16 @@ class SimilarNotesWidget extends StandardWidget {
this.$body.empty().append($list);
}
eventReceived(name, data) {
if (name === 'noteSaved') {
if (this.title !== this.ctx.note.title) {
this.rendered = false;
this.renderBody();
}
}
}
}
export default SimilarNotesWidget;