Enable change events in the drive

This commit is contained in:
yflory
2017-12-05 18:09:43 +01:00
parent 17636769e4
commit 9eb33e39e6
7 changed files with 59 additions and 29 deletions

View File

@@ -2869,9 +2869,10 @@ define([
onRefresh.to = window.setTimeout(refresh, 500);
}
};
/*proxy.on('change', [], function () {
sframeChan.on('EV_DRIVE_CHANGE', function (data) {
if (history.isHistoryMode) { return; }
var path = arguments[2];
var path = data.path;
if (path[0] !== 'drive') { return false; }
path = path.slice(1);
var cPath = currentPath.slice();
@@ -2884,26 +2885,21 @@ define([
}
APP.resetTree();
return false;
}).on('remove', [], function () {
});
sframeChan.on('EV_DRIVE_REMOVE', function (data) {
if (history.isHistoryMode) { return; }
var path = arguments[1];
var path = data.path;
if (path[0] !== 'drive') { return false; }
path = path.slice(1);
var cPath = currentPath.slice();
if ((filesOp.isPathIn(cPath, ['hrefArray', TRASH]) && cPath[0] === path[0]) ||
(path.length >= cPath.length && filesOp.isSubpath(path, cPath))) {
// Reload after a few to make sure all the change events have been received
onRefresh.to = window.setTimeout(refresh, 500);
onRefresh.refresh();
}
APP.resetTree();
return false;
}).on('change', ['drive', 'migrate'], function () {
var path = arguments[2];
var value = arguments[1];
if (path[1] === "migrate" && value === 1) {
if (APP.onDisconnect) { APP.onDisconnect(true); }
}
});*/
});
history.onEnterHistory = function (obj) {
var files = obj.drive;

View File

@@ -62,18 +62,21 @@ define([
Cryptpad.onNetworkReconnect.reg(function (data) {
sframeChan.event('EV_NETWORK_RECONNECT', data);
});
Cryptpad.onDriveLog.reg(function (msg) {
Cryptpad.drive.onLog.reg(function (msg) {
sframeChan.event('EV_DRIVE_LOG', msg);
});
// History?
};
//Netflux.connect(NetConfig.getWebsocketURL()).then(function (network) {
SFCommonO.start({
getSecrets: getSecrets,
//newNetwork: network,
noHash: true,
addRpc: addRpc
Cryptpad.drive.onChange.reg(function (data) {
sframeChan.event('EV_DRIVE_CHANGE', data);
});
//}, function (err) { console.error(err); });
Cryptpad.drive.onRemove.reg(function (data) {
sframeChan.event('EV_DRIVE_REMOVE', data);
});
};
SFCommonO.start({
getSecrets: getSecrets,
noHash: true,
driveEvents: true,
addRpc: addRpc
});
});
});

View File

@@ -362,7 +362,7 @@ define([
return cb();
}
var path;
fo.addFolder(["root", "Folder2"], "subsub", function (e, o) { path = o.newPath; });
fo.addFolder(["root", "Folder2"], "subsub", function (o) { path = o.newPath; });
if (!files.root.Folder2.subsub || path.length !== 3) {
console.log("DRIVE operations: add folder");
return cb();