1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-08-07 22:33:50 +00:00

TiddlyWebAdaptor: Avoid crashing if server sent events not available

Fixes #5663
This commit is contained in:
jeremy@jermolene.com 2021-05-04 17:31:37 +01:00
parent cf56a17f28
commit d8ac00a108

View File

@ -40,6 +40,7 @@ function debounce(callback) {
} }
function setupEvents(host) { function setupEvents(host) {
if(window.EventSource) {
var events = new EventSource(host + "events/plugins/tiddlywiki/tiddlyweb"); var events = new EventSource(host + "events/plugins/tiddlywiki/tiddlyweb");
var debouncedSync = debounce($tw.syncer.syncFromServer.bind($tw.syncer)); var debouncedSync = debounce($tw.syncer.syncFromServer.bind($tw.syncer));
events.addEventListener("change",debouncedSync); events.addEventListener("change",debouncedSync);
@ -50,4 +51,6 @@ function setupEvents(host) {
},$tw.syncer.errorRetryInterval); },$tw.syncer.errorRetryInterval);
}; };
} }
}
})(); })();