Merge branch 'soon' into staging

pull/1/head
yflory 6 years ago
commit 1f5eb66fe0

@ -288,6 +288,15 @@ define([
$d.append(UI.dialog.selectable(formatted, {
id: 'cp-app-prop-size',
}));
if (data.sharedFolder) { // XXX debug
$('<label>', {'for': 'cp-app-prop-channel'}).text('Channel ID').appendTo($d);
if (AppConfig.pinBugRecovery) { $d.append(h('p', AppConfig.pinBugRecovery)); }
$d.append(UI.dialog.selectable(data.channel, {
id: 'cp-app-prop-link',
}));
}
cb(void 0, $d);
});
} else {

@ -130,6 +130,12 @@ define([
postMessage("DRIVE_USEROBJECT", data, cb);
};
common.restoreDrive = function (data, cb) {
if (data.sfId) { // Shared folder ID
postMessage('RESTORE_SHARED_FOLDER', data, cb, {
timeout: 5 * 60 * 1000
});
return;
}
postMessage("SET", {
key:['drive'],
value: data

@ -85,6 +85,20 @@ define([
cb({});
};
Store.restoreSharedFolder = function (clientId, data, cb) {
if (!data.sfId || !data.drive) { return void cb({error:'EINVAL'}); }
if (store.sharedFolders[data.sfId]) {
Object.keys(data.drive).forEach(function (k) {
store.sharedFolders[data.sfId].proxy[k] = data.drive[k];
});
Object.keys(store.sharedFolders[data.sfId].proxy).forEach(function (k) {
if (data.drive[k]) { return; }
delete store.sharedFolders[data.sfId].proxy[k];
});
}
onSync(cb);
};
Store.hasSigningKeys = function () {
if (!store.proxy) { return; }
return typeof(store.proxy.edPrivate) === 'string' &&

@ -57,6 +57,7 @@ define([
GET_SHARED_FOLDER: Store.getSharedFolder,
ADD_SHARED_FOLDER: Store.addSharedFolder,
LOAD_SHARED_FOLDER: Store.loadSharedFolderAnon,
RESTORE_SHARED_FOLDER: Store.restoreSharedFolder,
// Messaging
ANSWER_FRIEND_REQUEST: Store.answerFriendRequest,
SEND_FRIEND_REQUEST: Store.sendFriendRequest,

@ -63,7 +63,8 @@ define([
var sframeChan = common.getSframeChannel();
sframeChan.query('Q_GET_HISTORY_RANGE', {
lastKnownHash: lastKnownHash
lastKnownHash: lastKnownHash,
sharedFolder: config.sharedFolder
}, function (err, data) {
if (err) { return void console.error(err); }
if (!Array.isArray(data.messages)) { return void console.error('Not an array!'); }
@ -313,6 +314,10 @@ define([
$(window).trigger('resize');
};
if (config.onOpen) {
config.onOpen();
}
// Load all the history messages into a new chainpad object
loadMoreHistory(config, common, function (err, newRt, isFull) {
History.readOnly = common.getMetadataMgr().getPrivateData().readOnly;

@ -562,9 +562,12 @@ define([
sframeChan.on('Q_GET_HISTORY_RANGE', function (data, cb) {
var nSecret = secret;
if (cfg.isDrive) {
// Shared folder or user hash or fs hash
var hash = Utils.LocalStore.getUserHash() || Utils.LocalStore.getFSHash();
if (data.sharedFolder) { hash = data.sharedFolder.hash; }
if (hash) {
nSecret = Utils.Hash.getSecrets('drive', hash);
var password = (data.sharedFolder && data.sharedFolder.password) || undefined;
nSecret = Utils.Hash.getSecrets('drive', hash, password);
}
}
var channel = nSecret.channel;

@ -1775,6 +1775,11 @@ define([
default:
msg = undefined;
}
if (history.isHistoryMode && history.sfId) {
// Shared folder history: always display the warning
msg = Messages.fm_info_sharedFolderHistory;
return $(common.fixLinks($box.html(msg)));
}
if (!APP.loggedIn) {
msg = APP.newSharedFolder ? Messages.fm_info_sharedFolder : Messages.fm_info_anonymous;
return $(common.fixLinks($box.html(msg)));
@ -3227,6 +3232,7 @@ define([
//data.noPassword = true;
data.noEditPassword = true;
data.noExpiration = true;
data.sharedFolder = true; // XXX debug
}
UIElements.getProperties(common, data, cb);
@ -3613,7 +3619,32 @@ define([
return false;
});
APP.histConfig.onOpen = function () {
// If we're in a shared folder history, store its id in memory
// so that we remember that this isn't the drive history if
// we browse through the drive
var sfId = manager.isInSharedFolder(currentPath);
if (!sfId) {
delete history.sfId;
delete APP.histConfig.sharedFolder;
return;
}
history.sfId = sfId;
var data = manager.getSharedFolderData(sfId);
var parsed = Hash.parsePadUrl(data.href || data.roHref);
APP.histConfig.sharedFolder = {
hash: parsed.hash,
password: data.password
};
};
history.onEnterHistory = function (obj) {
if (history.sfId) {
if (!obj || typeof(obj) !== "object" || Object.keys(obj).length === 0) { return; }
copyObjectValue(folders[history.sfId], obj);
refresh();
return;
}
history.sfId = false;
copyObjectValue(files, obj.drive);
appStatus.isReady = true;
refresh();
@ -3753,13 +3784,22 @@ define([
APP.histConfig = {
onLocal: function () {
UI.addLoadingScreen({ loadingText: Messages.fm_restoreDrive });
proxy.drive = history.currentObj.drive;
sframeChan.query("Q_DRIVE_RESTORE", history.currentObj.drive, function () {
var data = {};
if (history.sfId) {
copyObjectValue(folders[history.sfId], history.currentObj);
data.sfId = history.sfId;
data.drive = history.currentObj;
} else {
proxy.drive = history.currentObj.drive;
data.drive = history.currentObj.drive;
}
sframeChan.query("Q_DRIVE_RESTORE", data, function () {
UI.removeLoadingScreen();
}, {
timeout: 5 * 60 * 1000
});
},
onOpen: function () {},
onRemote: function () {},
setHistory: setHistory,
applyVal: function (val) {

Loading…
Cancel
Save