mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixes
This commit is contained in:
parent
cb35284d37
commit
a2d6a5c3e9
@ -17,6 +17,13 @@ class TabContext extends Component {
|
|||||||
this.tabId = tabId || utils.randomString(4);
|
this.tabId = tabId || utils.randomString(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setEmpty() {
|
||||||
|
this.triggerEvent('tabNoteSwitched', {
|
||||||
|
tabId: this.tabId,
|
||||||
|
notePath: this.notePath
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async setNote(inputNotePath, triggerSwitchEvent = true) {
|
async setNote(inputNotePath, triggerSwitchEvent = true) {
|
||||||
const notePath = await treeService.resolveNotePath(inputNotePath);
|
const notePath = await treeService.resolveNotePath(inputNotePath);
|
||||||
|
|
||||||
|
@ -173,13 +173,15 @@ export default class TabManager extends Component {
|
|||||||
const tabContext = this.openEmptyTab();
|
const tabContext = this.openEmptyTab();
|
||||||
|
|
||||||
await this.activateTab(tabContext.tabId);
|
await this.activateTab(tabContext.tabId);
|
||||||
|
|
||||||
|
await tabContext.setEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
openEmptyTab(tabId) {
|
openEmptyTab(tabId) {
|
||||||
const tabContext = new TabContext(tabId);
|
const tabContext = new TabContext(tabId);
|
||||||
this.child(tabContext);
|
this.child(tabContext);
|
||||||
|
|
||||||
this.triggerEvent('newTabOpened', {tabId: this.tabId});
|
this.triggerEvent('newTabOpened', {tabId: tabContext.tabId});
|
||||||
|
|
||||||
return tabContext;
|
return tabContext;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,9 @@ export default class TabAwareWidget extends BasicWidget {
|
|||||||
|
|
||||||
// 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}) {
|
||||||
if (this.isTab(tabId) && this.notePath === notePath) {
|
this.tabContext = appContext.tabManager.getActiveTabContext();
|
||||||
|
|
||||||
|
if (this.notePath === notePath) {
|
||||||
this.tabContext = appContext.tabManager.getActiveTabContext();
|
this.tabContext = appContext.tabManager.getActiveTabContext();
|
||||||
|
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
|
@ -20,12 +20,15 @@ export default class TabCachingWidget extends TabAwareWidget {
|
|||||||
async handleEventInChildren(name, data) {
|
async handleEventInChildren(name, data) {
|
||||||
// stop propagation of the event to the children, individual tab widget should not know about tab switching
|
// stop propagation of the event to the children, individual tab widget should not know about tab switching
|
||||||
// since they are per-tab
|
// since they are per-tab
|
||||||
if (name !== 'activeTabChanged') {
|
if (name === 'tabNoteSwitchedAndActivated') {
|
||||||
|
await super.handleEventInChildren('tabNoteSwitched', data);
|
||||||
|
}
|
||||||
|
else if (name !== 'activeTabChanged') {
|
||||||
await super.handleEventInChildren(name, data);
|
await super.handleEventInChildren(name, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshWithNote() {
|
async refreshWithNote() {
|
||||||
for (const widget of Object.values(this.widgets)) {
|
for (const widget of Object.values(this.widgets)) {
|
||||||
widget.toggle(false);
|
widget.toggle(false);
|
||||||
}
|
}
|
||||||
@ -47,7 +50,7 @@ export default class TabCachingWidget extends TabAwareWidget {
|
|||||||
keyboardActionsService.updateDisplayedShortcuts($renderedWidget);
|
keyboardActionsService.updateDisplayedShortcuts($renderedWidget);
|
||||||
|
|
||||||
this.child(widget); // add as child only once it is ready (also rendered)
|
this.child(widget); // add as child only once it is ready (also rendered)
|
||||||
widget.handleEvent('setTabContext', {tabContext: this.tabContext});
|
await widget.handleEvent('setTabContext', {tabContext: this.tabContext});
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.toggle(widget.isEnabled());
|
widget.toggle(widget.isEnabled());
|
||||||
|
@ -576,6 +576,8 @@ export default class TabRowWidget extends BasicWidget {
|
|||||||
};
|
};
|
||||||
|
|
||||||
tabNoteSwitchedAndActivatedEvent({tabId}) {
|
tabNoteSwitchedAndActivatedEvent({tabId}) {
|
||||||
|
this.activeTabChangedEvent();
|
||||||
|
|
||||||
this.updateTabById(tabId);
|
this.updateTabById(tabId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user