diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index c10bdf120..2776a1695 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1000,6 +1000,9 @@ define([ }).nThen(cb); }; Store.setPadTitle = function (clientId, data, cb) { + if (store.offline) { + return void cb({ error: 'OFFLINE' }); + } var title = data.title; var href = data.href; var channel = data.channel; @@ -1811,6 +1814,10 @@ define([ if (!cmdData || !cmdData.cmd) { return; } //var data = cmdData.data; var s = getStore(cmdData.teamId); + if (s.offline) { + broadcast([], 'NETWORK_DISCONNECT'); + return void cb({ error: 'OFFLINE' }); + } var cb2 = function (data2) { // Send the CHANGE event to all the stores because the command may have // affected data from a shared folder used by multiple teams. @@ -2237,9 +2244,11 @@ define([ }); rt.proxy.on('disconnect', function () { + store.offline = true; broadcast([], 'NETWORK_DISCONNECT'); }); rt.proxy.on('reconnect', function (info) { + store.offline = false; broadcast([], 'NETWORK_RECONNECT', {myId: info.myId}); }); diff --git a/www/common/outer/team.js b/www/common/outer/team.js index 8769e5e7a..eedc96514 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -74,6 +74,12 @@ define([ path: p }); }); + proxy.on('disconnect', function () { + team.offline = true; + }); + proxy.on('reconnect', function (info) { + team.offline = false; + }); }; var closeTeam = function (ctx, teamId) { diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index bffe150c3..1b893e9a2 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -457,7 +457,7 @@ define([ path: initialPathInDrive // Where to store the pad if we don't have it in our drive }; Cryptpad.setPadTitle(data, function (err) { - cb(err); + cb({error: err}); }); }); sframeChan.on('EV_SET_TAB_TITLE', function (newTabTitle) { diff --git a/www/common/sframe-common-title.js b/www/common/sframe-common-title.js index 5f748347c..bafbc6c16 100644 --- a/www/common/sframe-common-title.js +++ b/www/common/sframe-common-title.js @@ -64,10 +64,13 @@ define([ sframeChan.query('Q_SET_PAD_TITLE_IN_DRIVE', { title: title, defaultTitle: defaultTitle - }, function (err) { + }, function (err, obj) { + err = err || (obj && obj.error); if (err === 'E_OVER_LIMIT') { return void UI.alert(Messages.pinLimitNotPinned, null, true); - } else if (err) { return; } + } else if (err) { + return UI.alert(Messages.driveOfflineError); + } evTitleChange.fire(title); if (titleUpdated) { titleUpdated(undefined, title);