mirror of
https://github.com/zadam/trilium.git
synced 2025-01-16 20:21:43 +08:00
fixes
This commit is contained in:
parent
606d5afcab
commit
ba500a3a80
7 changed files with 48 additions and 26 deletions
|
@ -253,7 +253,6 @@ class AppContext {
|
|||
const tabContext = new TabContext(this, this.tabRow);
|
||||
this.tabContexts.push(tabContext);
|
||||
this.components.push(tabContext);
|
||||
|
||||
return tabContext;
|
||||
}
|
||||
|
||||
|
@ -321,9 +320,11 @@ class AppContext {
|
|||
}
|
||||
|
||||
activateTab(tabId) {
|
||||
const oldActiveTabId = this.activeTabId;
|
||||
|
||||
this.activeTabId = tabId;
|
||||
|
||||
this.trigger('activeTabChanged', { tabId: this.activeTabId });
|
||||
this.trigger('activeTabChanged', { oldActiveTabId });
|
||||
}
|
||||
|
||||
newTabListener() {
|
||||
|
|
|
@ -69,6 +69,7 @@ class TabContext extends Component {
|
|||
}
|
||||
}, 5000);
|
||||
|
||||
// should be done somewhere else ...
|
||||
bundleService.executeRelationBundles(this.note, 'runOnNoteView', this);
|
||||
|
||||
if (this.note.isProtected && protectedSessionHolder.isProtectedSessionAvailable()) {
|
||||
|
|
|
@ -24,10 +24,6 @@ class BasicWidget extends Component {
|
|||
doRender() {}
|
||||
|
||||
toggle(show) {
|
||||
if (!this.$widget) {
|
||||
console.log(this.componentId);
|
||||
}
|
||||
|
||||
this.$widget.toggle(show);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,10 @@ export default class Component {
|
|||
}
|
||||
|
||||
if (propagateToChildren) {
|
||||
for (const child of this.children) {
|
||||
let promise = child.eventReceived(name, data, sync);
|
||||
const promise = this.triggerChildren(name, data, sync);
|
||||
|
||||
if (sync) {
|
||||
await promise;
|
||||
}
|
||||
if (sync) {
|
||||
await promise;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,4 +33,14 @@ export default class Component {
|
|||
trigger(name, data, sync = false) {
|
||||
this.appContext.trigger(name, data, sync);
|
||||
}
|
||||
|
||||
async triggerChildren(name, data, sync = false) {
|
||||
for (const child of this.children) {
|
||||
let promise = child.eventReceived(name, data, sync);
|
||||
|
||||
if (sync) {
|
||||
await promise;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
import TabAwareWidget from "./tab_aware_widget.js";
|
||||
import utils from "../services/utils.js";
|
||||
import protectedSessionHolder from "../services/protected_session_holder.js";
|
||||
import appContext from "../services/app_context.js";
|
||||
import SpacedUpdate from "../services/spaced_update.js";
|
||||
import server from "../services/server.js";
|
||||
import libraryLoader from "../services/library_loader.js";
|
||||
|
@ -81,13 +80,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
|
|||
}
|
||||
|
||||
async refresh() {
|
||||
this.type = this.getWidgetType(/*disableAutoBook*/);
|
||||
|
||||
if (!(this.type in this.typeWidgetPromises)) {
|
||||
this.typeWidgetPromises[this.type] = this.initWidgetType(this.type);
|
||||
}
|
||||
|
||||
await this.typeWidgetPromises[this.type];
|
||||
await this.initType();
|
||||
|
||||
for (const typeWidget of Object.values(this.typeWidgets)) {
|
||||
if (typeWidget.constructor.getType() !== this.type) {
|
||||
|
@ -101,6 +94,20 @@ export default class NoteDetailWidget extends TabAwareWidget {
|
|||
this.setupClasses();
|
||||
}
|
||||
|
||||
async initType() {
|
||||
do {
|
||||
this.type = this.getWidgetType();
|
||||
|
||||
console.log(`Note detail type = ${this.type} for ${this.tabContext.tabId}`);
|
||||
|
||||
if (!(this.type in this.typeWidgetPromises)) {
|
||||
this.typeWidgetPromises[this.type] = this.initWidgetType(this.type);
|
||||
}
|
||||
|
||||
await this.typeWidgetPromises[this.type];
|
||||
} while (this.type !== this.getWidgetType());
|
||||
}
|
||||
|
||||
setupClasses() {
|
||||
for (const clazz of Array.from(this.$widget[0].classList)) { // create copy to safely iterate over while removing classes
|
||||
if (clazz !== 'note-detail') {
|
||||
|
@ -130,7 +137,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
|
|||
async initWidgetType(type) {
|
||||
const clazz = await import(typeWidgetClasses[type]);
|
||||
|
||||
const typeWidget = this.typeWidgets[this.type] = new clazz.default(this.appContext);
|
||||
const typeWidget = this.typeWidgets[type] = new clazz.default(this.appContext);
|
||||
this.children.push(typeWidget);
|
||||
|
||||
this.$widget.append(typeWidget.render());
|
||||
|
@ -209,4 +216,10 @@ export default class NoteDetailWidget extends TabAwareWidget {
|
|||
protectedSessionStartedListener() {
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
async eventReceived(name, data, sync = false) {
|
||||
console.log("Received ", name, data);
|
||||
|
||||
super.eventReceived(name, data, sync);
|
||||
}
|
||||
}
|
|
@ -21,6 +21,8 @@ export default class TabCachingWidget extends TabAwareWidget {
|
|||
}
|
||||
|
||||
if (!this.tabContext) {
|
||||
console.log(`Received activeTabChanged to widget ${this.componentId} which does not have tabContext.`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,13 +36,14 @@ export default class EmptyTypeWidget extends TypeWidget {
|
|||
return this.$widget;
|
||||
}
|
||||
|
||||
refresh() {
|
||||
if (this.tabContext.note) {
|
||||
this.toggle(false);
|
||||
return;
|
||||
}
|
||||
toggle(show) {
|
||||
console.log("EMPTY TOGGLE", show);
|
||||
|
||||
this.toggle(true);
|
||||
super.toggle(show);
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this.toggle(!this.tabContext.note);
|
||||
}
|
||||
|
||||
show() {}
|
||||
|
|
Loading…
Reference in a new issue