mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-05-08 05:09:13 -05:00
websocket reimplementation of status requests
This commit is contained in:
@@ -139,4 +139,31 @@ function initAjax() {
|
||||
});
|
||||
}
|
||||
|
||||
initAjax();
|
||||
initAjax();
|
||||
|
||||
// use wss for secure messaging
|
||||
const ws = new WebSocket("ws://" + location.host);
|
||||
ws.onopen = function (event) {
|
||||
};
|
||||
|
||||
ws.onmessage = function (event) {
|
||||
console.log(event.data);
|
||||
|
||||
const message = JSON.parse(event.data);
|
||||
|
||||
if (message.type === 'sync') {
|
||||
const data = message.data;
|
||||
|
||||
if (data.notes_tree) {
|
||||
console.log("Reloading tree because of background changes");
|
||||
|
||||
noteTree.reload();
|
||||
}
|
||||
|
||||
if (data.notes && data.notes.includes(noteEditor.getCurrentNoteId())) {
|
||||
showMessage('Reloading note because background change');
|
||||
|
||||
noteEditor.reload();
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -26,17 +26,17 @@ const status = (function() {
|
||||
}
|
||||
});
|
||||
|
||||
if (resp.changedTree) {
|
||||
console.log("Reloading tree because of background changes");
|
||||
|
||||
noteTree.reload();
|
||||
}
|
||||
|
||||
if (resp.changedCurrentNote) {
|
||||
showMessage('Reloading note because background change');
|
||||
|
||||
noteEditor.reload();
|
||||
}
|
||||
// if (resp.changedTree) {
|
||||
// console.log("Reloading tree because of background changes");
|
||||
//
|
||||
// noteTree.reload();
|
||||
// }
|
||||
//
|
||||
// if (resp.changedCurrentNote) {
|
||||
// showMessage('Reloading note because background change');
|
||||
//
|
||||
// noteEditor.reload();
|
||||
// }
|
||||
|
||||
changesToPushCountEl.html(resp.changesToPushCount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user