Remove deleted pad from the drive

This commit is contained in:
yflory
2020-01-13 15:58:46 +01:00
parent 09da8ac6a2
commit 1e6e9fd288
4 changed files with 35 additions and 0 deletions

View File

@@ -2175,6 +2175,11 @@ define([
updateMetadata: function () {
broadcast([], "UPDATE_METADATA");
},
updateDrive: function () {
sendDriveEvent('DRIVE_CHANGE', {
path: ['drive', 'filesData']
});
},
pinPads: function (data, cb) { Store.pinPads(null, data, cb); },
}, waitFor, function (ev, data, clients, _cb) {
var cb = Util.once(_cb || function () {});

View File

@@ -482,6 +482,31 @@ define([
cb(true);
};
handlers['OWNED_PAD_REMOVED'] = function (ctx, box, data, cb) {
var msg = data.msg;
var content = msg.content;
if (msg.author !== content.user.curvePublic) { return void cb(true); }
if (!content.channel) {
console.log('Remove invalid notification');
return void cb(true);
}
var channel = content.channel;
var res = ctx.store.manager.findChannel(channel);
res.forEach(function (obj) {
var paths = ctx.store.manager.findFile(obj.id);
ctx.store.manager.delete({
paths: paths
}, function () {
ctx.updateDrive();
});
});
cb(true);
};
return {

View File

@@ -422,6 +422,7 @@ proxy.mailboxes = {
store: store,
pinPads: cfg.pinPads,
updateMetadata: cfg.updateMetadata,
updateDrive: cfg.updateDrive,
emit: emit,
clients: [],
boxes: {},