Offline fixes

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

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

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

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

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

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

Loading…
Cancel
Save