From 820ff42781802261e12f772764d1da6a9b61b58d Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Thu, 29 Sep 2016 20:41:28 +0000 Subject: [PATCH] Add tests. Kill the vfs connection when a users access level is changed too. --- plugins/c9.vfs.server/vfs.server.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/c9.vfs.server/vfs.server.js b/plugins/c9.vfs.server/vfs.server.js index aa259a99..8bbbc4f3 100644 --- a/plugins/c9.vfs.server/vfs.server.js +++ b/plugins/c9.vfs.server/vfs.server.js @@ -340,21 +340,23 @@ function plugin(options, imports, register) { var message = JSON.parse(messageString); switch (message.action) { case "remove_member": - handleRemoveProjectMember(vfs, message); + case "update_member_access": + handleProjectMemberAccessChange(vfs, message); break; default: break; } } - function handleRemoveProjectMember(vfs, message) { + function handleProjectMemberAccessChange(vfs, message) { if (vfs.uid !== message.body.uid) return; console.log("Removing ", vfs.id, " for user ", vfs.uid, " project ", vfs.pid, " from the vfs connection cache"); - // Remove after 2s so client has time to recieve final "You've been removed" PubSub message. - setTimeout(function() { + + // Remove next tick so client has time to recieve final "You've been removed" PubSub message. + process.nextTick(function() { cache.remove(vfs.id); - }, 2000); + }); } register(null, {