Warn users when the drive is offline

pull/1/head
yflory 5 years ago
parent 77c6269e0c
commit 5c223f1ae1

@ -1000,6 +1000,9 @@ define([
}).nThen(cb); }).nThen(cb);
}; };
Store.setPadTitle = function (clientId, data, cb) { Store.setPadTitle = function (clientId, data, cb) {
if (store.offline) {
return void cb({ error: 'OFFLINE' });
}
var title = data.title; var title = data.title;
var href = data.href; var href = data.href;
var channel = data.channel; var channel = data.channel;
@ -1811,6 +1814,10 @@ define([
if (!cmdData || !cmdData.cmd) { return; } if (!cmdData || !cmdData.cmd) { return; }
//var data = cmdData.data; //var data = cmdData.data;
var s = getStore(cmdData.teamId); var s = getStore(cmdData.teamId);
if (s.offline) {
broadcast([], 'NETWORK_DISCONNECT');
return void cb({ error: 'OFFLINE' });
}
var cb2 = function (data2) { var cb2 = function (data2) {
// Send the CHANGE event to all the stores because the command may have // Send the CHANGE event to all the stores because the command may have
// affected data from a shared folder used by multiple teams. // affected data from a shared folder used by multiple teams.
@ -2237,9 +2244,11 @@ define([
}); });
rt.proxy.on('disconnect', function () { rt.proxy.on('disconnect', function () {
store.offline = true;
broadcast([], 'NETWORK_DISCONNECT'); broadcast([], 'NETWORK_DISCONNECT');
}); });
rt.proxy.on('reconnect', function (info) { rt.proxy.on('reconnect', function (info) {
store.offline = false;
broadcast([], 'NETWORK_RECONNECT', {myId: info.myId}); broadcast([], 'NETWORK_RECONNECT', {myId: info.myId});
}); });

@ -74,6 +74,12 @@ define([
path: p path: p
}); });
}); });
proxy.on('disconnect', function () {
team.offline = true;
});
proxy.on('reconnect', function (info) {
team.offline = false;
});
}; };
var closeTeam = function (ctx, teamId) { var closeTeam = function (ctx, teamId) {

@ -457,7 +457,7 @@ define([
path: initialPathInDrive // Where to store the pad if we don't have it in our drive path: initialPathInDrive // Where to store the pad if we don't have it in our drive
}; };
Cryptpad.setPadTitle(data, function (err) { Cryptpad.setPadTitle(data, function (err) {
cb(err); cb({error: err});
}); });
}); });
sframeChan.on('EV_SET_TAB_TITLE', function (newTabTitle) { sframeChan.on('EV_SET_TAB_TITLE', function (newTabTitle) {

@ -64,10 +64,13 @@ define([
sframeChan.query('Q_SET_PAD_TITLE_IN_DRIVE', { sframeChan.query('Q_SET_PAD_TITLE_IN_DRIVE', {
title: title, title: title,
defaultTitle: defaultTitle defaultTitle: defaultTitle
}, function (err) { }, function (err, obj) {
err = err || (obj && obj.error);
if (err === 'E_OVER_LIMIT') { if (err === 'E_OVER_LIMIT') {
return void UI.alert(Messages.pinLimitNotPinned, null, true); return void UI.alert(Messages.pinLimitNotPinned, null, true);
} else if (err) { return; } } else if (err) {
return UI.alert(Messages.driveOfflineError);
}
evTitleChange.fire(title); evTitleChange.fire(title);
if (titleUpdated) { if (titleUpdated) {
titleUpdated(undefined, title); titleUpdated(undefined, title);

Loading…
Cancel
Save