Shared folder history
This commit is contained in:
parent
ba877ba459
commit
04d8578f4e
@ -130,6 +130,12 @@ define([
|
|||||||
postMessage("DRIVE_USEROBJECT", data, cb);
|
postMessage("DRIVE_USEROBJECT", data, cb);
|
||||||
};
|
};
|
||||||
common.restoreDrive = function (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", {
|
postMessage("SET", {
|
||||||
key:['drive'],
|
key:['drive'],
|
||||||
value: data
|
value: data
|
||||||
|
|||||||
@ -85,6 +85,20 @@ define([
|
|||||||
cb({});
|
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 () {
|
Store.hasSigningKeys = function () {
|
||||||
if (!store.proxy) { return; }
|
if (!store.proxy) { return; }
|
||||||
return typeof(store.proxy.edPrivate) === 'string' &&
|
return typeof(store.proxy.edPrivate) === 'string' &&
|
||||||
|
|||||||
@ -57,6 +57,7 @@ define([
|
|||||||
GET_SHARED_FOLDER: Store.getSharedFolder,
|
GET_SHARED_FOLDER: Store.getSharedFolder,
|
||||||
ADD_SHARED_FOLDER: Store.addSharedFolder,
|
ADD_SHARED_FOLDER: Store.addSharedFolder,
|
||||||
LOAD_SHARED_FOLDER: Store.loadSharedFolderAnon,
|
LOAD_SHARED_FOLDER: Store.loadSharedFolderAnon,
|
||||||
|
RESTORE_SHARED_FOLDER: Store.restoreSharedFolder,
|
||||||
// Messaging
|
// Messaging
|
||||||
ANSWER_FRIEND_REQUEST: Store.answerFriendRequest,
|
ANSWER_FRIEND_REQUEST: Store.answerFriendRequest,
|
||||||
SEND_FRIEND_REQUEST: Store.sendFriendRequest,
|
SEND_FRIEND_REQUEST: Store.sendFriendRequest,
|
||||||
|
|||||||
@ -63,7 +63,8 @@ define([
|
|||||||
var sframeChan = common.getSframeChannel();
|
var sframeChan = common.getSframeChannel();
|
||||||
|
|
||||||
sframeChan.query('Q_GET_HISTORY_RANGE', {
|
sframeChan.query('Q_GET_HISTORY_RANGE', {
|
||||||
lastKnownHash: lastKnownHash
|
lastKnownHash: lastKnownHash,
|
||||||
|
sharedFolder: config.sharedFolder
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
if (err) { return void console.error(err); }
|
if (err) { return void console.error(err); }
|
||||||
if (!Array.isArray(data.messages)) { return void console.error('Not an array!'); }
|
if (!Array.isArray(data.messages)) { return void console.error('Not an array!'); }
|
||||||
@ -313,6 +314,10 @@ define([
|
|||||||
$(window).trigger('resize');
|
$(window).trigger('resize');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (config.onOpen) {
|
||||||
|
config.onOpen();
|
||||||
|
}
|
||||||
|
|
||||||
// Load all the history messages into a new chainpad object
|
// Load all the history messages into a new chainpad object
|
||||||
loadMoreHistory(config, common, function (err, newRt, isFull) {
|
loadMoreHistory(config, common, function (err, newRt, isFull) {
|
||||||
History.readOnly = common.getMetadataMgr().getPrivateData().readOnly;
|
History.readOnly = common.getMetadataMgr().getPrivateData().readOnly;
|
||||||
|
|||||||
@ -537,9 +537,12 @@ define([
|
|||||||
sframeChan.on('Q_GET_HISTORY_RANGE', function (data, cb) {
|
sframeChan.on('Q_GET_HISTORY_RANGE', function (data, cb) {
|
||||||
var nSecret = secret;
|
var nSecret = secret;
|
||||||
if (cfg.isDrive) {
|
if (cfg.isDrive) {
|
||||||
|
// Shared folder or user hash or fs hash
|
||||||
var hash = Utils.LocalStore.getUserHash() || Utils.LocalStore.getFSHash();
|
var hash = Utils.LocalStore.getUserHash() || Utils.LocalStore.getFSHash();
|
||||||
|
if (data.sharedFolder) { hash = data.sharedFolder.hash; }
|
||||||
if (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;
|
var channel = nSecret.channel;
|
||||||
|
|||||||
@ -1705,6 +1705,11 @@ define([
|
|||||||
default:
|
default:
|
||||||
msg = undefined;
|
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) {
|
if (!APP.loggedIn) {
|
||||||
msg = APP.newSharedFolder ? Messages.fm_info_sharedFolder : Messages.fm_info_anonymous;
|
msg = APP.newSharedFolder ? Messages.fm_info_sharedFolder : Messages.fm_info_anonymous;
|
||||||
return $(common.fixLinks($box.html(msg)));
|
return $(common.fixLinks($box.html(msg)));
|
||||||
@ -3527,7 +3532,32 @@ define([
|
|||||||
return false;
|
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) {
|
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);
|
copyObjectValue(files, obj.drive);
|
||||||
appStatus.isReady = true;
|
appStatus.isReady = true;
|
||||||
refresh();
|
refresh();
|
||||||
@ -3667,13 +3697,22 @@ define([
|
|||||||
APP.histConfig = {
|
APP.histConfig = {
|
||||||
onLocal: function () {
|
onLocal: function () {
|
||||||
UI.addLoadingScreen({ loadingText: Messages.fm_restoreDrive });
|
UI.addLoadingScreen({ loadingText: Messages.fm_restoreDrive });
|
||||||
|
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;
|
proxy.drive = history.currentObj.drive;
|
||||||
sframeChan.query("Q_DRIVE_RESTORE", history.currentObj.drive, function () {
|
data.drive = history.currentObj.drive;
|
||||||
|
}
|
||||||
|
sframeChan.query("Q_DRIVE_RESTORE", data, function () {
|
||||||
UI.removeLoadingScreen();
|
UI.removeLoadingScreen();
|
||||||
}, {
|
}, {
|
||||||
timeout: 5 * 60 * 1000
|
timeout: 5 * 60 * 1000
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
onOpen: function () {},
|
||||||
onRemote: function () {},
|
onRemote: function () {},
|
||||||
setHistory: setHistory,
|
setHistory: setHistory,
|
||||||
applyVal: function (val) {
|
applyVal: function (val) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user