Shared folder history
parent
ba877ba459
commit
04d8578f4e
|
@ -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;
|
||||
|
|
|
@ -537,9 +537,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;
|
||||
|
|
|
@ -1705,6 +1705,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)));
|
||||
|
@ -3527,7 +3532,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();
|
||||
|
@ -3667,13 +3697,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…
Reference in New Issue