Skip to content

Build your personal knowledge base with Trilium Notes

fix non disappearing persistent toast

zadamc4d5060a0b9f
diff --git a/src/app.js b/src/app.js
index 322ebdd982..3ef1a7c0f5 100644
--- a/src/app.js
+++ b/src/app.js
@@ -92,6 +92,7 @@ app.use((err, req, res, next) => {
err.message.includes("Invalid package")
|| (err.message.includes("Router not found for request") && err.message.includes("node_modules"))
|| (err.message.includes("Router not found for request") && err.message.includes(".js.map"))
+ || (err.message.includes("Router not found for request") && err.message.includes(".css.map"))
)) {
// electron 6 outputs a lot of such errors which do not seem important
}
diff --git a/src/public/javascripts/services/toast.js b/src/public/javascripts/services/toast.js
index 389a3dfe26..a09b38b02f 100644
--- a/src/public/javascripts/services/toast.js
+++ b/src/public/javascripts/services/toast.js
@@ -33,7 +33,7 @@ function toast(options) {
}
function showPersistent(options) {
- let $toast = $("#toast-" + options.id);
+ let $toast = $("#toast-persistent-" + options.id);
if ($toast.length > 0) {
$toast.find('.toast-body').html(options.message);
diff --git a/src/public/javascripts/services/ws.js b/src/public/javascripts/services/ws.js
index c18027926a..bc06d37e4c 100644
--- a/src/public/javascripts/services/ws.js
+++ b/src/public/javascripts/services/ws.js
@@ -173,7 +173,8 @@ subscribeToMessages(message => {
});
}
else if (message.type === 'sync-pull-finished') {
- toastService.closePersistent('sync');
+ // this gives user a chance to see the toast in case of fast sync finish
+ setTimeout(() => toastService.closePersistent('sync'), 1000);
}
});
diff --git a/src/services/log.js b/src/services/log.js
index 0de8b16190..1514c209a3 100644
--- a/src/services/log.js
+++ b/src/services/log.js
@@ -42,6 +42,10 @@ function request(req) {
}
}
+ if (req.url.includes(".js.map") || req.url.includes(".css.map")) {
+ return;
+ }
+
logger.info(req.method + " " + req.url);
}
diff --git a/src/services/sync.js b/src/services/sync.js
index 5bd9aa2a54..ee709b7092 100644
--- a/src/services/sync.js
+++ b/src/services/sync.js
@@ -117,6 +117,8 @@ async function doLogin() {
}
async function pullSync(syncContext) {
+ let appliedPulls = 0;
+
while (true) {
const lastSyncedPull = await getLastSyncedPull();
const changesUri = '/api/sync/changed?lastSyncId=' + lastSyncedPull;
@@ -150,9 +152,13 @@ async function pullSync(syncContext) {
}
await setLastSyncedPull(rows[rows.length - 1].sync.id);
+
+ appliedPulls += rows.length;
}
- ws.syncPullFinished();
+ if (appliedPulls > 0) {
+ ws.syncPullFinished();
+ }
log.info("Finished pull");
}