mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
TiddlyWebAdaptor: Avoid crashing if server sent events not available
Fixes #5663
This commit is contained in:
parent
cf56a17f28
commit
d8ac00a108
@ -40,14 +40,17 @@ function debounce(callback) {
|
||||
}
|
||||
|
||||
function setupEvents(host) {
|
||||
var events = new EventSource(host + "events/plugins/tiddlywiki/tiddlyweb");
|
||||
var debouncedSync = debounce($tw.syncer.syncFromServer.bind($tw.syncer));
|
||||
events.addEventListener("change",debouncedSync);
|
||||
events.onerror = function() {
|
||||
events.close();
|
||||
setTimeout(function() {
|
||||
setupEvents(host);
|
||||
},$tw.syncer.errorRetryInterval);
|
||||
};
|
||||
if(window.EventSource) {
|
||||
var events = new EventSource(host + "events/plugins/tiddlywiki/tiddlyweb");
|
||||
var debouncedSync = debounce($tw.syncer.syncFromServer.bind($tw.syncer));
|
||||
events.addEventListener("change",debouncedSync);
|
||||
events.onerror = function() {
|
||||
events.close();
|
||||
setTimeout(function() {
|
||||
setupEvents(host);
|
||||
},$tw.syncer.errorRetryInterval);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user