Remove deleted pad from the drive
This commit is contained in:
@@ -2175,6 +2175,11 @@ define([
|
|||||||
updateMetadata: function () {
|
updateMetadata: function () {
|
||||||
broadcast([], "UPDATE_METADATA");
|
broadcast([], "UPDATE_METADATA");
|
||||||
},
|
},
|
||||||
|
updateDrive: function () {
|
||||||
|
sendDriveEvent('DRIVE_CHANGE', {
|
||||||
|
path: ['drive', 'filesData']
|
||||||
|
});
|
||||||
|
},
|
||||||
pinPads: function (data, cb) { Store.pinPads(null, data, cb); },
|
pinPads: function (data, cb) { Store.pinPads(null, data, cb); },
|
||||||
}, waitFor, function (ev, data, clients, _cb) {
|
}, waitFor, function (ev, data, clients, _cb) {
|
||||||
var cb = Util.once(_cb || function () {});
|
var cb = Util.once(_cb || function () {});
|
||||||
|
|||||||
@@ -482,6 +482,31 @@ define([
|
|||||||
cb(true);
|
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 {
|
return {
|
||||||
|
|||||||
@@ -422,6 +422,7 @@ proxy.mailboxes = {
|
|||||||
store: store,
|
store: store,
|
||||||
pinPads: cfg.pinPads,
|
pinPads: cfg.pinPads,
|
||||||
updateMetadata: cfg.updateMetadata,
|
updateMetadata: cfg.updateMetadata,
|
||||||
|
updateDrive: cfg.updateDrive,
|
||||||
emit: emit,
|
emit: emit,
|
||||||
clients: [],
|
clients: [],
|
||||||
boxes: {},
|
boxes: {},
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ define([
|
|||||||
// If it's not a shared folder, check the pads
|
// If it's not a shared folder, check the pads
|
||||||
if (!data) { data = Env.user.userObject.getFileData(id, editable); }
|
if (!data) { data = Env.user.userObject.getFileData(id, editable); }
|
||||||
ret.push({
|
ret.push({
|
||||||
|
id: id,
|
||||||
data: data,
|
data: data,
|
||||||
userObject: Env.user.userObject
|
userObject: Env.user.userObject
|
||||||
});
|
});
|
||||||
@@ -126,6 +127,7 @@ define([
|
|||||||
Object.keys(Env.folders).forEach(function (fId) {
|
Object.keys(Env.folders).forEach(function (fId) {
|
||||||
Env.folders[fId].userObject.findChannels([channel]).forEach(function (id) {
|
Env.folders[fId].userObject.findChannels([channel]).forEach(function (id) {
|
||||||
ret.push({
|
ret.push({
|
||||||
|
id: id,
|
||||||
fId: fId,
|
fId: fId,
|
||||||
data: Env.folders[fId].userObject.getFileData(id, editable),
|
data: Env.folders[fId].userObject.getFileData(id, editable),
|
||||||
userObject: Env.folders[fId].userObject
|
userObject: Env.folders[fId].userObject
|
||||||
@@ -1095,9 +1097,11 @@ define([
|
|||||||
// Store
|
// Store
|
||||||
getChannelsList: callWithEnv(getChannelsList),
|
getChannelsList: callWithEnv(getChannelsList),
|
||||||
addPad: callWithEnv(addPad),
|
addPad: callWithEnv(addPad),
|
||||||
|
delete: callWithEnv(_delete),
|
||||||
// Tools
|
// Tools
|
||||||
findChannel: callWithEnv(findChannel),
|
findChannel: callWithEnv(findChannel),
|
||||||
findHref: callWithEnv(findHref),
|
findHref: callWithEnv(findHref),
|
||||||
|
findFile: callWithEnv(findFile),
|
||||||
getEditHash: callWithEnv(getEditHash),
|
getEditHash: callWithEnv(getEditHash),
|
||||||
user: Env.user,
|
user: Env.user,
|
||||||
folders: Env.folders
|
folders: Env.folders
|
||||||
|
|||||||
Reference in New Issue
Block a user