Ability to remove owned channels from the drive

This commit is contained in:
yflory
2018-01-29 15:17:53 +01:00
parent 1c39e8b1bb
commit bdafc101c9
8 changed files with 31 additions and 10 deletions

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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);