From 0c8d09ebbf6bdeddda40fef41edbe6131e964831 Mon Sep 17 00:00:00 2001 From: myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Mon, 29 Nov 2021 21:55:51 +0100 Subject: [PATCH 1/2] current stand --- src/public/app/services/note_context.js | 9 +++++++++ src/public/app/widgets/note_detail.js | 22 ++++++++++++++++++++++ src/public/app/widgets/note_tree.js | 10 +--------- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/public/app/services/note_context.js b/src/public/app/services/note_context.js index d2b4b4fb50..d7bea3a281 100644 --- a/src/public/app/services/note_context.js +++ b/src/public/app/services/note_context.js @@ -32,6 +32,15 @@ class NoteContext extends Component { }); } + setLoading() { + console.log("setLoading") + this.notePath = null; + this.noteId = null; + this.parentNoteId = null; + + this.triggerEvent('noteLoading'); + } + async setNote(inputNotePath, triggerSwitchEvent = true) { const resolvedNotePath = await this.getResolvedNotePath(inputNotePath); diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js index e951fbbdce..182805f10a 100644 --- a/src/public/app/widgets/note_detail.js +++ b/src/public/app/widgets/note_detail.js @@ -196,6 +196,28 @@ export default class NoteDetailWidget extends NoteContextAwareWidget { } } + async noteLoadingEvent() { + console.log("blaa"); + const widget = new EmptyTypeWidget(); + widget.spacedUpdate = this.spacedUpdate; + widget.setParent(this); + + const $renderedWidget = widget.render(); + keyboardActionsService.updateDisplayedShortcuts($renderedWidget); + + this.$widget.append($renderedWidget); + + await widget.handleEvent('setNoteContext', {noteContext: this.noteContext}); + + // this is happening in update() so note has been already set and we need to reflect this + await widget.handleEvent('noteSwitched', { + noteContext: this.noteContext, + notePath: this.noteContext.notePath + }); + + this.child(widget); + } + async beforeTabRemoveEvent({ntxIds}) { if (this.isNoteContext(ntxIds)) { await this.spacedUpdate.updateNowIfNecessary(); diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index a9538645db..c9991288f6 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -328,19 +328,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { } }, activate: async (event, data) => { - // click event won't propagate so let's close context menu manually - contextMenu.hide(); - - this.clearSelectedNodes(); - const notePath = treeService.getNotePath(data.node); const activeNoteContext = appContext.tabManager.getActiveContext(); + activeNoteContext.setLoading(); await activeNoteContext.setNote(notePath); - - if (utils.isMobile()) { - this.triggerCommand('setActiveScreen', {screen: 'detail'}); - } }, expand: (event, data) => this.setExpanded(data.node.data.branchId, true), collapse: (event, data) => this.setExpanded(data.node.data.branchId, false), From ac9b61ab3db56a7b8d2768e14fc09cced7b39116 Mon Sep 17 00:00:00 2001 From: myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Wed, 1 Dec 2021 21:48:17 +0100 Subject: [PATCH 2/2] current stand --- src/public/app/services/note_context.js | 1 - src/public/app/widgets/note_detail.js | 19 +++++++------------ .../app/widgets/type_widgets/loading.js | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 src/public/app/widgets/type_widgets/loading.js diff --git a/src/public/app/services/note_context.js b/src/public/app/services/note_context.js index d7bea3a281..d8ee393a43 100644 --- a/src/public/app/services/note_context.js +++ b/src/public/app/services/note_context.js @@ -33,7 +33,6 @@ class NoteContext extends Component { } setLoading() { - console.log("setLoading") this.notePath = null; this.noteId = null; this.parentNoteId = null; diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js index 182805f10a..5b412b67a2 100644 --- a/src/public/app/widgets/note_detail.js +++ b/src/public/app/widgets/note_detail.js @@ -21,6 +21,7 @@ import ReadOnlyCodeTypeWidget from "./type_widgets/read_only_code.js"; import NoneTypeWidget from "./type_widgets/none.js"; import attributeService from "../services/attributes.js"; import NoteMapTypeWidget from "./type_widgets/note_map.js"; +import LoadingTypeWidget from "./type_widgets/loading.js"; const TPL = `