Skip to content

Build your personal knowledge base with Trilium Notes

make initialization of launchers more robust

zadame2b227df3465
diff --git a/src/public/app/widgets/containers/launcher_container.js b/src/public/app/widgets/containers/launcher_container.js
index fe5e69ddec..1c18590487 100644
--- a/src/public/app/widgets/containers/launcher_container.js
+++ b/src/public/app/widgets/containers/launcher_container.js
@@ -17,8 +17,6 @@ export default class LauncherContainer extends FlexContainer {
async load() {
await froca.initializedPromise;
- this.children = [];
-
const visibleLaunchersRoot = await froca.getNote('_lbVisibleLaunchers', true);
if (!visibleLaunchersRoot) {
@@ -27,13 +25,15 @@ export default class LauncherContainer extends FlexContainer {
return;
}
+ const newChildren = [];
+
for (const launcherNote of await visibleLaunchersRoot.getChildNotes()) {
try {
const launcherWidget = new LauncherWidget();
const success = await launcherWidget.initLauncher(launcherNote);
if (success) {
- this.child(launcherWidget);
+ newChildren.push(launcherWidget);
}
}
catch (e) {
@@ -41,6 +41,9 @@ export default class LauncherContainer extends FlexContainer {
}
}
+ this.children = [];
+ this.child(...newChildren);
+
this.$widget.empty();
this.renderChildren();
diff --git a/src/public/app/widgets/sync_status.js b/src/public/app/widgets/sync_status.js
index d4e5187ccf..cc716b953d 100644
--- a/src/public/app/widgets/sync_status.js
+++ b/src/public/app/widgets/sync_status.js
@@ -78,8 +78,6 @@ export default class SyncStatusWidget extends BasicWidget {
constructor() {
super();
- ws.subscribeToMessages(message => this.processMessage(message));
-
this.syncState = 'unknown';
this.allChangesPushed = false;
}
@@ -93,8 +91,9 @@ export default class SyncStatusWidget extends BasicWidget {
});
this.$widget.find('.sync-status-icon:not(.sync-status-in-progress)')
- .on('click', () => syncService.syncNow())
+ .on('click', () => syncService.syncNow());
+ ws.subscribeToMessages(message => this.processMessage(message));
}
showIcon(className) {