This commit is contained in:
zadam 2020-02-29 22:04:46 +01:00
parent 49398f5374
commit 8888d04878
6 changed files with 23 additions and 13 deletions

File diff suppressed because one or more lines are too long

View File

@ -49,8 +49,6 @@ class TabContext extends Component {
this.autoBookDisabled = false; this.autoBookDisabled = false;
//this.cleanup(); // esp. on windows autocomplete is not getting closed automatically
setTimeout(async () => { setTimeout(async () => {
// we include the note into recent list only if the user stayed on the note at least 5 seconds // we include the note into recent list only if the user stayed on the note at least 5 seconds
if (notePath && notePath === this.notePath) { if (notePath && notePath === this.notePath) {

View File

@ -222,7 +222,7 @@ export default class TabManager extends Component {
this.activeTabId = tabId; this.activeTabId = tabId;
if (triggerEvent) { if (triggerEvent) {
this.triggerEvent('activeTabChanged'); this.triggerEvent('activeTabChanged', {tabId});
} }
this.tabsUpdate.scheduleUpdate(); this.tabsUpdate.scheduleUpdate();

View File

@ -117,7 +117,12 @@ export default class NoteDetailWidget extends TabAwareWidget {
this.$widget.append($renderedWidget); this.$widget.append($renderedWidget);
typeWidget.handleEvent('setTabContext', {tabContext: this.tabContext}); await typeWidget.handleEvent('setTabContext', {tabContext: this.tabContext});
typeWidget.handleEvent('tabNoteSwitched', {
tabId: this.tabContext.tabId,
notePath: this.notePath
});
} }
this.setupClasses(); this.setupClasses();

View File

@ -72,17 +72,21 @@ export default class TabAwareWidget extends BasicWidget {
async refreshWithNote(note, notePath) {} async refreshWithNote(note, notePath) {}
async activeTabChangedEvent() { async activeTabChangedEvent({tabId}) {
this.tabContext = appContext.tabManager.getActiveTabContext(); this.tabContext = appContext.tabManager.getTabContextById(tabId);
await this.activeTabChanged(); if (this.tabContext.tabId === appContext.tabManager.getActiveTabContext().tabId) {
await this.activeTabChanged();
}
} }
// when note is both switched and activated, this should not produce double refresh // when note is both switched and activated, this should not produce double refresh
async tabNoteSwitchedAndActivatedEvent({tabId, notePath}) { async tabNoteSwitchedAndActivatedEvent({tabId, notePath}) {
this.tabContext = appContext.tabManager.getActiveTabContext(); this.tabContext = appContext.tabManager.getTabContextById(tabId);
if (this.tabContext.tabId === appContext.tabManager.getActiveTabContext().tabId
&& this.notePath === notePath) {
if (this.notePath === notePath) {
this.tabContext = appContext.tabManager.getActiveTabContext(); this.tabContext = appContext.tabManager.getActiveTabContext();
await this.refresh(); await this.refresh();

View File

@ -1,5 +1,6 @@
import TabAwareWidget from "./tab_aware_widget.js"; import TabAwareWidget from "./tab_aware_widget.js";
import keyboardActionsService from "../services/keyboard_actions.js"; import keyboardActionsService from "../services/keyboard_actions.js";
import appContext from "../services/app_context.js";
export default class TabCachingWidget extends TabAwareWidget { export default class TabCachingWidget extends TabAwareWidget {
constructor(widgetFactory) { constructor(widgetFactory) {
@ -42,7 +43,9 @@ export default class TabCachingWidget extends TabAwareWidget {
keyboardActionsService.updateDisplayedShortcuts($renderedWidget); keyboardActionsService.updateDisplayedShortcuts($renderedWidget);
await this.widgets[tabId].handleEvent('setTabContext', {tabContext: this.tabContext}); await this.widgets[tabId].handleEvent('setTabContext', {
tabContext: appContext.tabManager.getTabContextById(tabId)
});
this.child(this.widgets[tabId]); // add as child only once it is ready (rendered with tabContext) this.child(this.widgets[tabId]); // add as child only once it is ready (rendered with tabContext)
} }