Commit d8713920 authored by JC Brand's avatar JC Brand

updates #1094

Update the occupants list when occupants are added/removed from the
member lists.
parent f573c69d
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
"map", "replace", "toLower", "split", "trim", "forEach", "toUpperCase", "includes" "map", "replace", "toLower", "split", "trim", "forEach", "toUpperCase", "includes"
] ]
}], }],
"lodash/prefer-invoke-map": "off",
"lodash/prefer-startswith": "off", "lodash/prefer-startswith": "off",
"lodash/prefer-constant": "off", "lodash/prefer-constant": "off",
"lodash/prefer-noop": "off", "lodash/prefer-noop": "off",
......
...@@ -7584,6 +7584,9 @@ body.reset { ...@@ -7584,6 +7584,9 @@ body.reset {
#conversejs.converse-fullscreen .chatbox-btn { #conversejs.converse-fullscreen .chatbox-btn {
font-size: 16px; } font-size: 16px; }
#conversejs.converse-fullscreen .chat-head .chatbox-buttons {
flex: 0 0 25%;
max-width: 25%; }
@media screen and (max-width: 767px) { @media screen and (max-width: 767px) {
#conversejs:not(.converse-embedded) > .row { #conversejs:not(.converse-embedded) > .row {
......
...@@ -7635,6 +7635,9 @@ body { ...@@ -7635,6 +7635,9 @@ body {
#conversejs.converse-fullscreen .chatbox-btn { #conversejs.converse-fullscreen .chatbox-btn {
font-size: 16px; } font-size: 16px; }
#conversejs.converse-fullscreen .chat-head .chatbox-buttons {
flex: 0 0 25%;
max-width: 25%; }
@media screen and (max-width: 767px) { @media screen and (max-width: 767px) {
#conversejs:not(.converse-embedded) > .row { #conversejs:not(.converse-embedded) > .row {
......
...@@ -435,6 +435,11 @@ ...@@ -435,6 +435,11 @@
.chatbox-btn { .chatbox-btn {
font-size: $fullpage-chatbox-button-size; font-size: $fullpage-chatbox-button-size;
} }
.chat-head {
.chatbox-buttons {
@include make-col(3);
}
}
} }
@media screen and (max-width: 767px) { @media screen and (max-width: 767px) {
......
...@@ -495,7 +495,7 @@ ...@@ -495,7 +495,7 @@
'click .close-chatbox-button': 'close', 'click .close-chatbox-button': 'close',
'click .configure-chatroom-button': 'getAndRenderConfigurationForm', 'click .configure-chatroom-button': 'getAndRenderConfigurationForm',
'click .new-msgs-indicator': 'viewUnreadMessages', 'click .new-msgs-indicator': 'viewUnreadMessages',
'click .occupant': 'onOccupantClicked', 'click .occupant-nick': 'onOccupantClicked',
'click .send-button': 'onFormSubmitted', 'click .send-button': 'onFormSubmitted',
'click .toggle-call': 'toggleCall', 'click .toggle-call': 'toggleCall',
'click .toggle-occupants': 'toggleOccupants', 'click .toggle-occupants': 'toggleOccupants',
...@@ -759,8 +759,12 @@ ...@@ -759,8 +759,12 @@
return true; return true;
}, },
onCommandError () { onCommandError (err) {
this.showErrorMessage(__("Error: could not execute the command"), true); _converse.log(err, Strophe.LogLevel.FATAL);
this.showErrorMessage(
__("Sorry, an error happened while running the command. Check your browser's developer console for details."),
true
);
}, },
parseMessageForCommands (text) { parseMessageForCommands (text) {
...@@ -780,14 +784,20 @@ ...@@ -780,14 +784,20 @@
this.model.setAffiliation('admin', this.model.setAffiliation('admin',
[{ 'jid': args[0], [{ 'jid': args[0],
'reason': args[1] 'reason': args[1]
}]).then(null, this.onCommandError.bind(this)); }]).then(
() => this.model.occupants.fetchMembers(),
(err) => this.onCommandError(err)
);
break; break;
case 'ban': case 'ban':
if (!this.validateRoleChangeCommand(command, args)) { break; } if (!this.validateRoleChangeCommand(command, args)) { break; }
this.model.setAffiliation('outcast', this.model.setAffiliation('outcast',
[{ 'jid': args[0], [{ 'jid': args[0],
'reason': args[1] 'reason': args[1]
}]).then(null, this.onCommandError.bind(this)); }]).then(
() => this.model.occupants.fetchMembers(),
(err) => this.onCommandError(err)
);
break; break;
case 'deop': case 'deop':
if (!this.validateRoleChangeCommand(command, args)) { break; } if (!this.validateRoleChangeCommand(command, args)) { break; }
...@@ -832,7 +842,10 @@ ...@@ -832,7 +842,10 @@
this.model.setAffiliation('member', this.model.setAffiliation('member',
[{ 'jid': args[0], [{ 'jid': args[0],
'reason': args[1] 'reason': args[1]
}]).then(null, this.onCommandError.bind(this)); }]).then(
() => this.model.occupants.fetchMembers(),
(err) => this.onCommandError(err)
);
break; break;
case 'nick': case 'nick':
_converse.connection.send($pres({ _converse.connection.send($pres({
...@@ -846,7 +859,10 @@ ...@@ -846,7 +859,10 @@
this.model.setAffiliation('owner', this.model.setAffiliation('owner',
[{ 'jid': args[0], [{ 'jid': args[0],
'reason': args[1] 'reason': args[1]
}]).then(null, this.onCommandError.bind(this)); }]).then(
() => this.model.occupants.fetchMembers(),
(err) => this.onCommandError(err)
);
break; break;
case 'op': case 'op':
if (!this.validateRoleChangeCommand(command, args)) { break; } if (!this.validateRoleChangeCommand(command, args)) { break; }
...@@ -859,7 +875,10 @@ ...@@ -859,7 +875,10 @@
this.model.setAffiliation('none', this.model.setAffiliation('none',
[{ 'jid': args[0], [{ 'jid': args[0],
'reason': args[1] 'reason': args[1]
}]).then(null, this.onCommandError.bind(this)); }]).then(
() => this.model.occupants.fetchMembers(),
(err) => this.onCommandError(err)
);
break; break;
case 'topic': case 'topic':
case 'subject': case 'subject':
......
...@@ -1020,8 +1020,22 @@ ...@@ -1020,8 +1020,22 @@
}, },
fetchMembers () { fetchMembers () {
const old_jids = _.uniq(_.concat(
_.map(this.where({'affiliation': 'admin'}), (item) => item.get('jid')),
_.map(this.where({'affiliation': 'member'}), (item) => item.get('jid')),
_.map(this.where({'affiliation': 'owner'}), (item) => item.get('jid'))
));
this.chatroom.getJidsWithAffiliations(['member', 'owner', 'admin']) this.chatroom.getJidsWithAffiliations(['member', 'owner', 'admin'])
.then((jids) => { .then((jids) => {
_.each(_.difference(old_jids, jids), (removed_jid) => {
// Remove absent occupants who've been removed from
// the members lists.
const occupant = this.findOccupant({'jid': removed_jid});
if (occupant.get('show') === 'offline') {
occupant.destroy();
}
});
_.each(jids, (attrs) => { _.each(jids, (attrs) => {
const occupant = this.findOccupant({'jid': attrs.jid}); const occupant = this.findOccupant({'jid': attrs.jid});
if (occupant) { if (occupant) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment