diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index c0ebd20ff..81003b3c6 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -377,7 +377,8 @@ define(function () { 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_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_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 ?"; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index ad5141c03..fcfab50f0 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -195,6 +195,9 @@ define([ common.clearOwnedChannel = function (channel, cb) { postMessage("CLEAR_OWNED_CHANNEL", channel, cb); }; + common.removeOwnedChannel = function (channel, cb) { + postMessage("REMOVE_OWNED_CHANNEL", channel, cb); + }; common.getDeletedPads = function (cb) { postMessage("GET_DELETED_PADS", null, function (obj) { diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index c0ac5b915..3b61acaa5 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -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) { 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) { - console.log(e, res); if (e) { return void cb({error: e}); } if (res && res.length && Array.isArray(res[0])) { cb(res[0]); @@ -907,7 +913,7 @@ define([ var userObject = store.userObject = UserObject.init(proxy.drive, { pinPads: Store.pinPads, unpinPads: Store.unpinPads, - removeOwnedChannel: function () {}, // XXX + removeOwnedChannel: Store.removeOwnedChannel, edPublic: store.proxy.edPublic, loggedIn: store.loggedIn, log: function (msg) { diff --git a/www/common/outer/store-rpc.js b/www/common/outer/store-rpc.js index c1b69dab7..9fe45556e 100644 --- a/www/common/outer/store-rpc.js +++ b/www/common/outer/store-rpc.js @@ -31,6 +31,9 @@ define([ case 'CLEAR_OWNED_CHANNEL': { Store.clearOwnedChannel(data, cb); break; } + case 'REMOVE_OWNED_CHANNEL': { + Store.removeOwnedChannel(data, cb); break; + } case 'UPLOAD_CHUNK': { Store.uploadChunk(data, cb); break; } diff --git a/www/common/outer/userObject.js b/www/common/outer/userObject.js index e50a5f219..3293dcb36 100644 --- a/www/common/outer/userObject.js +++ b/www/common/outer/userObject.js @@ -97,7 +97,9 @@ define([ var channelId = fd && fd.href && Hash.hrefToHexChannelId(fd.href); // If trying to remove an owned pad, remove it from server also 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); } spliceFileData(id); diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 55346db6a..0bbd40eea 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -501,6 +501,9 @@ define([ sframeChan.on('Q_CONTACTS_CLEAR_OWNED_CHANNEL', function (channel, cb) { Cryptpad.clearOwnedChannel(channel, cb); }); + sframeChan.on('Q_REMOVE_OWNED_CHANNEL', function (channel, cb) { + Cryptpad.removeOwnedChannel(channel, cb); + }); if (cfg.addRpc) { cfg.addRpc(sframeChan, Cryptpad, Utils); diff --git a/www/common/sframe-protocol.js b/www/common/sframe-protocol.js index 5035e2af2..46aa93348 100644 --- a/www/common/sframe-protocol.js +++ b/www/common/sframe-protocol.js @@ -209,6 +209,9 @@ define({ 'EV_DRIVE_CHANGE': 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 'EV_NETWORK_DISCONNECT': true, 'EV_NETWORK_RECONNECT': true, diff --git a/www/drive/inner.js b/www/drive/inner.js index 65547c60d..5bb678a9c 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -2687,8 +2687,8 @@ define([ if (paths) { paths.forEach(function (p) { pathsList.push(p.path); }); } - var msg = Messages._getKey("fm_removeSeveralPermanentlyDialog", [paths.length]); - if (paths.length === 1) { + var msg = Messages._getKey("fm_removeSeveralPermanentlyDialog", [pathsList.length]); + if (pathsList.length === 1) { msg = Messages.fm_removePermanentlyDialog; } UI.confirm(msg, function(res) { @@ -2702,7 +2702,8 @@ define([ if (paths) { 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) { $(window).focus(); if (!res) { return; } @@ -2714,11 +2715,10 @@ define([ var parsed = Hash.parsePadUrl(data.href); var channel = Util.base64ToHex(parsed.hashData.channel); n = n.nThen(function (waitFor) { - // XXX use the delete channel rpc - sframeChan.query('Q_CONTACTS_CLEAR_OWNED_CHANNEL', channel, + sframeChan.query('Q_REMOVE_OWNED_CHANNEL', channel, waitFor(function (e) { if (e) { return void console.error(e); } - filesOp.delete([p.path], refresh); + filesOp.delete([p], refresh); })); }); });