feat: automatically attempt socket.io reconnection on ajaxify

Also, updated messaging and toaster to accurately reflect offline-mode state
This commit is contained in:
Julian Lam
2020-12-30 13:51:45 -05:00
parent 189be9e0be
commit e5edbc6faf
3 changed files with 30 additions and 5 deletions

View File

@@ -14,7 +14,10 @@ ajaxify = window.ajaxify || {};
ajaxify.currentPage = null;
ajaxify.go = function (url, callback, quiet) {
// Automatically reconnect to socket and re-ajaxify on success
if (!socket.connected) {
app.reconnect();
if (ajaxify.reconnectAction) {
$(window).off('action:reconnected', ajaxify.reconnectAction);
}
@@ -410,6 +413,7 @@ ajaxify = window.ajaxify || {};
require(['translator', 'benchpress'], function (translator, Benchpress) {
translator.translate('[[error:no-connection]]');
translator.translate('[[error:socket-reconnect-failed]]');
translator.translate(`[[global:reconnecting-message, ${config.siteTitle}]]`);
Benchpress.registerLoader(ajaxify.loadTemplate);
Benchpress.setGlobal('config', config);
});