Offline fixes

pull/1/head
yflory 4 years ago
parent 989020a436
commit e629f0aa47

@ -229,6 +229,7 @@ define([
};
};
UIElements.noContactsMessage = function (common) {
var metadataMgr = common.getMetadataMgr();
var data = metadataMgr.getUserData();

@ -769,6 +769,7 @@ define([
}, function () {});
};
Messages.access_offline = "You're currently offline. Access management is not available"; // XXX
var getAccessTab = function (Env, data, opts, _cb) {
var cb = Util.once(Util.mkAsync(_cb));
var common = Env.common;
@ -776,8 +777,14 @@ define([
var sframeChan = common.getSframeChannel();
var metadataMgr = common.getMetadataMgr();
var priv = metadataMgr.getPrivateData();
var $div = $(h('div.cp-share-columns'));
if (priv.offline) {
$div.append(h('p', Messages.access_offline));
return void cb(void 0, $div);
}
if (!data) { return void cb(void 0, $div); }
var div1 = h('div.cp-usergrid-user.cp-share-column.cp-access');

@ -47,6 +47,9 @@ define([
if (!common.isLoggedIn()) { return void cb(void 0, $d); }
var privateData = common.getMetadataMgr().getPrivateData();
if (privateData.offline) { return void cb(void 0, $d); }
// File and history size...
var owned = Modal.isOwned(Env, data);

@ -273,6 +273,21 @@ define([
var hasFriends = opts.hasFriends;
var onFriendShare = Util.mkEvent();
Messages.share_noContactsOffline = "OFFLINE"; // XXX
var metadataMgr = common.getMetadataMgr();
var priv = metadataMgr.getPrivateData();
if (priv.offline) {
return void cb(void 0, {
content: h('p', Messages.share_noContactsOffline),
buttons: [{
className: 'cancel',
name: Messages.filePicker_close,
onClick: function () {},
keys: [27]
}]
});
}
var friendsObject = hasFriends ? createShareWithFriends(opts, onFriendShare, opts.getLinkValue) : UIElements.noContactsMessage(common);
var friendsList = friendsObject.content;
@ -642,6 +657,8 @@ define([
opts.teams = teams;
var hasFriends = opts.hasFriends = Object.keys(opts.friends || {}).length ||
Object.keys(teams).length;
var metadataMgr = common.getMetadataMgr();
var priv = metadataMgr.getPrivateData();
// check if the pad is password protected
var pathname = opts.pathname;
@ -662,23 +679,24 @@ define([
$rights.find('input[type="radio"]').trigger('change');
};
var onShowContacts = function () {
if (!hasFriends) {
if (!hasFriends || priv.offline) {
$rights.hide();
}
};
var contactsActive = hasFriends && !priv.offline;
var tabs = [{
getTab: getContactsTab,
title: Messages.share_contactCategory,
icon: "fa fa-address-book",
active: hasFriends,
active: contactsActive,
onShow: onShowContacts,
onHide: resetTab
}, {
getTab: getLinkTab,
title: Messages.share_linkCategory,
icon: "fa fa-link",
active: !hasFriends,
active: !contactsActive,
}, {
getTab: getEmbedTab,
title: Messages.share_embedCategory,

@ -1924,6 +1924,7 @@ define([
Store.getPadMetadata = function (clientId, data, _cb) {
var cb = Util.once(Util.mkAsync(_cb));
if (store.offline || !store.anon_rpc) { return void cb({ error: 'OFFLINE' }); }
if (!data.channel) { return void cb({ error: 'ENOTFOUND'}); }
if (data.channel.length !== 32) { return void cb({ error: 'EINVAL'}); }
store.anon_rpc.send('GET_METADATA', data.channel, function (err, obj) {
@ -2605,6 +2606,7 @@ define([
// "cb" may have already been called by onCacheReady
if (typeof(cb) === 'function') { cb(returned); }
sendDriveEvent('NETWORK_RECONNECT');
broadcast([], "UPDATE_METADATA");
store.offline = false;
// XXX broadcast READY event with the missing data
// XXX we can improve feedback to queue the queries and send them when coming back online

@ -431,12 +431,13 @@ define([
}
if (!stored && !parsed.hashData.password) {
// We've received a link without /p/ and it doesn't work without a password: abort
if (e === "ANON_RPC_NOT_READY") {
// We're currently offline and the pad is not in our cache
sframeChan.event('EV_OFFLINE');
}
return void todo();
}
if (e === "ANON_RPC_NOT_READY") {
// We're currently offline and the pad is not in our cache
w.abort();
return void sframeChan.event('EV_OFFLINE');
}
// Wrong password or deleted file?
askPassword(true, passwordCfg);
}));

Loading…
Cancel
Save