From 5ce2ce8db6de2ed8136fd3e1fcea6e34f50cbea1 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Thu, 30 Oct 2014 17:32:03 +0200 Subject: [PATCH] Removes toggle lock icon, just lock or unlock it, depending the status returned by the server. --- app.js | 2 -- muc.js | 15 ++++++++++++++- toolbar.js | 7 ++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index c448b3797..535dac43f 100644 --- a/app.js +++ b/app.js @@ -1413,8 +1413,6 @@ function lockRoom(lock) { connection.emuc.lockRoom(sharedKey); else connection.emuc.lockRoom(''); - - Toolbar.updateLockButton(); } /** diff --git a/muc.js b/muc.js index a71dc2832..e4a32e4dc 100644 --- a/muc.js +++ b/muc.js @@ -263,19 +263,31 @@ Strophe.addConnectionPlugin('emuc', { // FIXME: is muc#roomconfig_passwordprotectedroom required? this.connection.sendIQ(formsubmit, function (res) { - console.log('set room password'); + // password is required + if (sharedKey) + { + console.log('set room password'); + Toolbar.lockLockButton(); + } + else + { + console.log('removed room password'); + Toolbar.unlockLockButton(); + } }, function (err) { console.warn('setting password failed', err); messageHandler.showError('Lock failed', 'Failed to lock conference.', err); + setSharedKey(''); } ); } else { console.warn('room passwords not supported'); messageHandler.showError('Warning', 'Room passwords are currently not supported.'); + setSharedKey(''); } }, @@ -284,6 +296,7 @@ Strophe.addConnectionPlugin('emuc', { messageHandler.showError('Lock failed', 'Failed to lock conference.', err); + setSharedKey(''); } ); }, diff --git a/toolbar.js b/toolbar.js index 077dd26db..7fcdfee0d 100644 --- a/toolbar.js +++ b/toolbar.js @@ -204,10 +204,11 @@ var Toolbar = (function (my) { } }; /** - * Updates the lock button state. + * Unlocks the lock button state. */ - my.updateLockButton = function() { - buttonClick("#lockIcon", "icon-security icon-security-locked"); + my.unlockLockButton = function() { + if($("#lockIcon").hasClass("icon-security-locked")) + buttonClick("#lockIcon", "icon-security icon-security-locked"); }; /** * Updates the lock button state to locked.