Kick from pad when an owned channel is deleted + whiteboard and poll

This commit is contained in:
yflory
2018-02-14 19:41:07 +01:00
parent 728a6a868d
commit e83e589cf0
17 changed files with 122 additions and 23 deletions

View File

@@ -1655,8 +1655,6 @@ define([
var metadataMgr = common.getMetadataMgr();
var type = metadataMgr.getMetadataLazy().type;
// XXX check text for pad creation screen + translate it in French
var $body = $('body');
var $creationContainer = $('<div>', { id: 'cp-creation-container' }).appendTo($body);
var $creation = $('<div>', { id: 'cp-creation' }).appendTo($creationContainer);

View File

@@ -897,7 +897,7 @@ define([
case 'addFolder':
store.userObject.addFolder(data.path, data.name, cb); break;
case 'delete':
store.userObject.delete(data.paths, cb, data.nocheck); break;
store.userObject.delete(data.paths, cb, data.nocheck, data.isOwnPadRemoved); break;
case 'emptyTrash':
store.userObject.emptyTrash(cb); break;
case 'rename':

View File

@@ -85,8 +85,11 @@ define([
delete files[FILES_DATA][id];
};
exp.checkDeletedFiles = function () {
// Nothing in OLD_FILES_DATA for workgroups
// Find files in FILES_DATA that are not anymore in the drive, and remove them from
// FILES_DATA. If there are owned pads, remove them from server too, unless the flag tells
// us they're already removed
exp.checkDeletedFiles = function (isOwnPadRemoved) {
// Nothing in FILES_DATA for workgroups
if (workgroup || (!loggedIn && !config.testMode)) { return; }
var filesList = exp.getFiles([ROOT, 'hrefArray', TRASH]);
@@ -96,7 +99,8 @@ define([
var fd = exp.getFileData(id);
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) {
if (!isOwnPadRemoved &&
fd.owners && fd.owners.indexOf(edPublic) !== -1 && channelId) {
removeOwnedChannel(channelId, function (obj) {
if (obj && obj.error) { console.error(obj.error); }
});
@@ -123,7 +127,7 @@ define([
files[TRASH][obj.name].splice(idx, 1);
});
};
exp.deleteMultiplePermanently = function (paths, nocheck) {
exp.deleteMultiplePermanently = function (paths, nocheck, isOwnPadRemoved) {
var hrefPaths = paths.filter(function(x) { return exp.isPathIn(x, ['hrefArray']); });
var rootPaths = paths.filter(function(x) { return exp.isPathIn(x, [ROOT]); });
var trashPaths = paths.filter(function(x) { return exp.isPathIn(x, [TRASH]); });
@@ -179,7 +183,7 @@ define([
// In some cases, we want to remove pads from a location without removing them from
// OLD_FILES_DATA (replaceHref)
if (!nocheck) { exp.checkDeletedFiles(); }
if (!nocheck) { exp.checkDeletedFiles(isOwnPadRemoved); }
};
// Move

View File

@@ -157,8 +157,8 @@ define([
}
rpc.send('REMOVE_OWNED_CHANNEL', channel, function (e, response) {
if (e) { return void cb(e); }
if (response && response.length) {
cb(void 0, response[0]); // I haven't tested this...
if (response && response.length && response[0] === "OK") {
cb();
} else {
cb('INVALID_RESPONSE');
}

View File

@@ -340,6 +340,11 @@ define([
if (err.loaded) {
msg += Messages.expiredErrorCopy;
}
} else if (err.type === 'EDELETED') {
msg = Messages.deletedError;
if (err.loaded) {
msg += Messages.expiredErrorCopy;
}
}
UI.errorLoadingScreen(msg, true, true);
};
@@ -436,7 +441,9 @@ define([
var priv = common.getMetadataMgr().getPrivateData();
if (priv.isNewFile) {
var c = (priv.settings.general && priv.settings.general.creation) || {};
if (c.skip && !priv.forceCreationScreen) { return void common.createPad(c, waitFor()); }
if (c.skip && !priv.forceCreationScreen) {
return void common.createPad(c, waitFor());
}
common.getPadCreationScreen(c, waitFor());
}
}).nThen(function (waitFor) {

View File

@@ -1100,6 +1100,7 @@ define([
toolbar.deleted = function (/*userId*/) {
toolbar.isErrorState = true;
toolbar.connected = false;
updateUserList(toolbar, config);
if (toolbar.spinner) {
toolbar.spinner.text(Messages.deletedFromServer);
}

View File

@@ -556,17 +556,18 @@ define([
// DELETE
// Permanently delete multiple files at once using a list of paths
// NOTE: We have to be careful when removing elements from arrays (trash root, unsorted or template)
exp.delete = function (paths, cb, nocheck) {
exp.delete = function (paths, cb, nocheck, isOwnPadRemoved) {
if (sframeChan) {
return void sframeChan.query("Q_DRIVE_USEROBJECT", {
cmd: "delete",
data: {
paths: paths,
nocheck: nocheck
nocheck: nocheck,
isOwnPadRemoved: isOwnPadRemoved
}
}, cb);
}
exp.deleteMultiplePermanently(paths, nocheck);
exp.deleteMultiplePermanently(paths, nocheck, isOwnPadRemoved);
if (typeof cb === "function") { cb(); }
};
exp.emptyTrash = function (cb) {