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