Ability to remove owned channels from the drive

pull/1/head
yflory 7 years ago
parent 1c39e8b1bb
commit bdafc101c9

@ -377,7 +377,8 @@ define(function () {
out.fm_emptyTrashDialog = "Êtes-vous sûr de vouloir vider la corbeille ?"; out.fm_emptyTrashDialog = "Êtes-vous sûr de vouloir vider la corbeille ?";
out.fm_removeSeveralPermanentlyDialog = "Êtes-vous sûr de vouloir supprimer ces {0} éléments de votre CryptDrive de manière permanente ?"; out.fm_removeSeveralPermanentlyDialog = "Êtes-vous sûr de vouloir supprimer ces {0} éléments de votre CryptDrive de manière permanente ?";
out.fm_removePermanentlyDialog = "Êtes-vous sûr de vouloir supprimer cet élément de votre CryptDrive de manière permanente ?"; out.fm_removePermanentlyDialog = "Êtes-vous sûr de vouloir supprimer cet élément de votre CryptDrive de manière permanente ?";
out.fm_deleteOwnedPads = "Êtes-vous sûr de vouloir supprimer définitivement ce pad du serveur ?"; out.fm_deleteOwnedPad = "Êtes-vous sûr de vouloir supprimer définitivement ce pad du serveur ?";
out.fm_deleteOwnedPads = "Êtes-vous sûr de vouloir supprimer définitivement ces pads du serveur ?";
out.fm_restoreDialog = "Êtes-vous sûr de vouloir restaurer {0} à son emplacement précédent ?"; out.fm_restoreDialog = "Êtes-vous sûr de vouloir restaurer {0} à son emplacement précédent ?";
out.fm_removeSeveralDialog = "Êtes-vous sûr de vouloir déplacer ces {0} éléments vers la corbeille ?"; out.fm_removeSeveralDialog = "Êtes-vous sûr de vouloir déplacer ces {0} éléments vers la corbeille ?";
out.fm_removeDialog = "Êtes-vous sûr de vouloir déplacer {0} vers la corbeille ?"; out.fm_removeDialog = "Êtes-vous sûr de vouloir déplacer {0} vers la corbeille ?";

@ -195,6 +195,9 @@ define([
common.clearOwnedChannel = function (channel, cb) { common.clearOwnedChannel = function (channel, cb) {
postMessage("CLEAR_OWNED_CHANNEL", channel, cb); postMessage("CLEAR_OWNED_CHANNEL", channel, cb);
}; };
common.removeOwnedChannel = function (channel, cb) {
postMessage("REMOVE_OWNED_CHANNEL", channel, cb);
};
common.getDeletedPads = function (cb) { common.getDeletedPads = function (cb) {
postMessage("GET_DELETED_PADS", null, function (obj) { postMessage("GET_DELETED_PADS", null, function (obj) {

@ -190,6 +190,13 @@ define([
}); });
}; };
Store.removeOwnedChannel = function (data, cb) {
if (!store.rpc) { return void cb({error: 'RPC_NOT_READY'}); }
store.rpc.removeOwnedChannel(data, function (err) {
cb({error:err});
});
};
var arePinsSynced = function (cb) { var arePinsSynced = function (cb) {
if (!store.rpc) { return void cb({error: 'RPC_NOT_READY'}); } if (!store.rpc) { return void cb({error: 'RPC_NOT_READY'}); }
@ -335,7 +342,6 @@ define([
} }
store.anon_rpc.send('GET_DELETED_PADS', list, function (e, res) { store.anon_rpc.send('GET_DELETED_PADS', list, function (e, res) {
console.log(e, res);
if (e) { return void cb({error: e}); } if (e) { return void cb({error: e}); }
if (res && res.length && Array.isArray(res[0])) { if (res && res.length && Array.isArray(res[0])) {
cb(res[0]); cb(res[0]);
@ -907,7 +913,7 @@ define([
var userObject = store.userObject = UserObject.init(proxy.drive, { var userObject = store.userObject = UserObject.init(proxy.drive, {
pinPads: Store.pinPads, pinPads: Store.pinPads,
unpinPads: Store.unpinPads, unpinPads: Store.unpinPads,
removeOwnedChannel: function () {}, // XXX removeOwnedChannel: Store.removeOwnedChannel,
edPublic: store.proxy.edPublic, edPublic: store.proxy.edPublic,
loggedIn: store.loggedIn, loggedIn: store.loggedIn,
log: function (msg) { log: function (msg) {

@ -31,6 +31,9 @@ define([
case 'CLEAR_OWNED_CHANNEL': { case 'CLEAR_OWNED_CHANNEL': {
Store.clearOwnedChannel(data, cb); break; Store.clearOwnedChannel(data, cb); break;
} }
case 'REMOVE_OWNED_CHANNEL': {
Store.removeOwnedChannel(data, cb); break;
}
case 'UPLOAD_CHUNK': { case 'UPLOAD_CHUNK': {
Store.uploadChunk(data, cb); break; Store.uploadChunk(data, cb); break;
} }

@ -97,7 +97,9 @@ define([
var channelId = fd && fd.href && Hash.hrefToHexChannelId(fd.href); var channelId = fd && fd.href && Hash.hrefToHexChannelId(fd.href);
// If trying to remove an owned pad, remove it from server also // If trying to remove an owned pad, remove it from server also
if (fd.owners && fd.owners.indexOf(edPublic) !== -1 && channelId) { if (fd.owners && fd.owners.indexOf(edPublic) !== -1 && channelId) {
removeOwnedChannel(channelId); removeOwnedChannel(channelId, function (obj) {
if (obj && obj.error) { console.error(obj.error); }
});
} }
if (channelId) { toClean.push(channelId); } if (channelId) { toClean.push(channelId); }
spliceFileData(id); spliceFileData(id);

@ -501,6 +501,9 @@ define([
sframeChan.on('Q_CONTACTS_CLEAR_OWNED_CHANNEL', function (channel, cb) { sframeChan.on('Q_CONTACTS_CLEAR_OWNED_CHANNEL', function (channel, cb) {
Cryptpad.clearOwnedChannel(channel, cb); Cryptpad.clearOwnedChannel(channel, cb);
}); });
sframeChan.on('Q_REMOVE_OWNED_CHANNEL', function (channel, cb) {
Cryptpad.removeOwnedChannel(channel, cb);
});
if (cfg.addRpc) { if (cfg.addRpc) {
cfg.addRpc(sframeChan, Cryptpad, Utils); cfg.addRpc(sframeChan, Cryptpad, Utils);

@ -209,6 +209,9 @@ define({
'EV_DRIVE_CHANGE': true, 'EV_DRIVE_CHANGE': true,
'EV_DRIVE_REMOVE': true, 'EV_DRIVE_REMOVE': true,
// Remove an owned pad from the server
'Q_REMOVE_OWNED_CHANNEL': true,
// Notifications about connection and disconnection from the network // Notifications about connection and disconnection from the network
'EV_NETWORK_DISCONNECT': true, 'EV_NETWORK_DISCONNECT': true,
'EV_NETWORK_RECONNECT': true, 'EV_NETWORK_RECONNECT': true,

@ -2687,8 +2687,8 @@ define([
if (paths) { if (paths) {
paths.forEach(function (p) { pathsList.push(p.path); }); paths.forEach(function (p) { pathsList.push(p.path); });
} }
var msg = Messages._getKey("fm_removeSeveralPermanentlyDialog", [paths.length]); var msg = Messages._getKey("fm_removeSeveralPermanentlyDialog", [pathsList.length]);
if (paths.length === 1) { if (pathsList.length === 1) {
msg = Messages.fm_removePermanentlyDialog; msg = Messages.fm_removePermanentlyDialog;
} }
UI.confirm(msg, function(res) { UI.confirm(msg, function(res) {
@ -2702,7 +2702,8 @@ define([
if (paths) { if (paths) {
paths.forEach(function (p) { pathsList.push(p.path); }); paths.forEach(function (p) { pathsList.push(p.path); });
} }
var msgD = paths ? Messages.fm_deleteOwnedPads : Messages.fm_deleteContainsOwned; var msgD = pathsList.length === 1 ? Messages.fm_deleteOwnedPad :
Messages.fm_deleteOwnedPads;
UI.confirm(msgD, function(res) { UI.confirm(msgD, function(res) {
$(window).focus(); $(window).focus();
if (!res) { return; } if (!res) { return; }
@ -2714,11 +2715,10 @@ define([
var parsed = Hash.parsePadUrl(data.href); var parsed = Hash.parsePadUrl(data.href);
var channel = Util.base64ToHex(parsed.hashData.channel); var channel = Util.base64ToHex(parsed.hashData.channel);
n = n.nThen(function (waitFor) { n = n.nThen(function (waitFor) {
// XXX use the delete channel rpc sframeChan.query('Q_REMOVE_OWNED_CHANNEL', channel,
sframeChan.query('Q_CONTACTS_CLEAR_OWNED_CHANNEL', channel,
waitFor(function (e) { waitFor(function (e) {
if (e) { return void console.error(e); } if (e) { return void console.error(e); }
filesOp.delete([p.path], refresh); filesOp.delete([p], refresh);
})); }));
}); });
}); });

Loading…
Cancel
Save