Skip to content

Build your personal knowledge base with Trilium Notes

sync WS message is now kind of ping - if there's no ping from server we display error message

azivner3e6acb17ccf2
diff --git a/public/javascripts/init.js b/public/javascripts/init.js
index ceea8c2af1..eeb896d52c 100644
--- a/public/javascripts/init.js
+++ b/public/javascripts/init.js
@@ -152,6 +152,7 @@ ws.onmessage = function (event) {
const message = JSON.parse(event.data);
if (message.type === 'sync') {
+ lastPingTs = new Date().getTime();
const data = message.data;
if (data.notes_tree) {
@@ -169,4 +170,12 @@ ws.onmessage = function (event) {
const changesToPushCountEl = $("#changesToPushCount");
changesToPushCountEl.html(message.changesToPushCount);
}
-};
\ No newline at end of file
+};
+
+let lastPingTs = new Date().getTime();
+
+setInterval(() => {
+ if (new Date().getTime() - lastPingTs > 5000) {
+ showError("No communication with server");
+ }
+}, 3000);
\ No newline at end of file