From cb35284d378c11ab31342a2246d10c697b9c1e02 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 28 Feb 2020 00:31:12 +0100 Subject: [PATCH] wip --- src/public/javascripts/services/tab_manager.js | 5 ++++- src/public/javascripts/widgets/search_box.js | 6 +++--- src/public/javascripts/widgets/tab_aware_widget.js | 8 +++++--- src/public/javascripts/widgets/tab_row.js | 8 ++++++++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/public/javascripts/services/tab_manager.js b/src/public/javascripts/services/tab_manager.js index da21c92a0..e7748f933 100644 --- a/src/public/javascripts/services/tab_manager.js +++ b/src/public/javascripts/services/tab_manager.js @@ -192,7 +192,10 @@ export default class TabManager extends Component { if (activate) { this.activateTab(tabContext.tabId, false); - this.triggerEvent('tabNoteSwitchedAndActivated'); + this.triggerEvent('tabNoteSwitchedAndActivated', { + tabId: tabContext.tabId, + notePath + }); } } diff --git a/src/public/javascripts/widgets/search_box.js b/src/public/javascripts/widgets/search_box.js index 186ba6180..930c253fd 100644 --- a/src/public/javascripts/widgets/search_box.js +++ b/src/public/javascripts/widgets/search_box.js @@ -70,7 +70,7 @@ export default class SearchBoxWidget extends BasicWidget { this.$saveSearchButton.on('click', () => this.saveSearch()); - this.$closeSearchButton.on('click', () => this.triggerCommand('hideSearch')); + this.$closeSearchButton.on('click', () => this.hideSearch()); return this.$widget; } @@ -142,7 +142,7 @@ export default class SearchBoxWidget extends BasicWidget { this.$searchInput.trigger('focus'); } - hideSearchEvent() { + hideSearch() { this.resetSearchEvent(); this.$searchBox.slideUp(); @@ -155,7 +155,7 @@ export default class SearchBoxWidget extends BasicWidget { this.showSearchEvent(); } else { - this.hideSearchEvent(); + this.hideSearch(); } } diff --git a/src/public/javascripts/widgets/tab_aware_widget.js b/src/public/javascripts/widgets/tab_aware_widget.js index 07afd6c2e..ab5e16ef9 100644 --- a/src/public/javascripts/widgets/tab_aware_widget.js +++ b/src/public/javascripts/widgets/tab_aware_widget.js @@ -79,10 +79,12 @@ export default class TabAwareWidget extends BasicWidget { } // when note is both switched and activated, this should not produce double refresh - async tabNoteSwitchedAndActivatedEvent() { - this.tabContext = appContext.tabManager.getActiveTabContext(); + async tabNoteSwitchedAndActivatedEvent({tabId, notePath}) { + if (this.isTab(tabId) && this.notePath === notePath) { + this.tabContext = appContext.tabManager.getActiveTabContext(); - await this.refresh(); + await this.refresh(); + } } async treeCacheReloadedEvent() { diff --git a/src/public/javascripts/widgets/tab_row.js b/src/public/javascripts/widgets/tab_row.js index e0bcff64c..af5acd23c 100644 --- a/src/public/javascripts/widgets/tab_row.js +++ b/src/public/javascripts/widgets/tab_row.js @@ -575,7 +575,15 @@ export default class TabRowWidget extends BasicWidget { return closestIndex; }; + tabNoteSwitchedAndActivatedEvent({tabId}) { + this.updateTabById(tabId); + } + tabNoteSwitchedEvent({tabId}) { + this.updateTabById(tabId); + } + + updateTabById(tabId) { const $tab = this.getTabById(tabId); const {note} = appContext.tabManager.getTabContextById(tabId);