Remove the members-list work and keep the nickname form stuff

It's not stable yet and XMPP server support is very patchy.
However, the nickname form work can be merged into master.
This commit is contained in:
JC Brand 2016-07-26 06:59:34 +00:00
parent 0d105b8a6e
commit 172ce7e0ce
6 changed files with 27 additions and 153 deletions

View File

@ -2043,12 +2043,9 @@
padding: 2px 5px;
text-overflow: ellipsis;
white-space: nowrap;
color: #A8ABA1;
width: 100px; }
#conversejs .chatroom .box-flyout .chatroom-body .occupants .occupant-list li.online {
color: #1A9707; }
#conversejs .chatroom .box-flyout .chatroom-body .occupants .occupant-list li.online.moderator {
color: #D24E2B; }
#conversejs .chatroom .box-flyout .chatroom-body .occupants .occupant-list li.moderator {
color: #D24E2B; }
#conversejs .chatroom .box-flyout .chatroom-body .chatroom-form-container {
background-color: white;
border-bottom-left-radius: 4px;

View File

@ -1,8 +1,10 @@
# Changelog
## 1.0.5 (Unreleased)
- In case of a nickname conflict when joining a room, allow the user to choose a new nickname. [jcbrand]
- Check whether the user has a reserved nickname before entering a room, and if so, use it. [jcbrand]
- In case of nickname conflict when joining a room, allow the user to choose a new one.
[jcbrand]
- Check whether the user has a reserved nickname before entering a room, and if so,
use it. [jcbrand]
## 1.0.4 (2016-07-26)

View File

@ -108,13 +108,9 @@
padding: 2px 5px;
text-overflow: ellipsis;
white-space: nowrap;
color: $light-text-color;
width: 100px;
&.online {
color: $online-color;
&.moderator {
color: $moderator-color;
}
&.moderator {
color: $moderator-color;
}
}
}

View File

@ -217,7 +217,7 @@
}).nodeTree;
converse.connection._dataRecv(test_utils.createRequest(presence));
expect(view.onChatRoomPresence).toHaveBeenCalled();
expect($occupants.find('li.online').length).toBe(i+1);
expect($occupants.find('li').length).toBe(i+1);
}
}.bind(converse));
@ -522,7 +522,7 @@
*/
var __ = utils.__.bind(converse);
test_utils.openAndEnterChatRoom('lounge', 'localhost', 'oldnick');
var view = this.chatboxviews.get('lounge@localhost');
var view = converse.chatboxviews.get('lounge@localhost');
var $chat_content = view.$el.find('.chat-content');
spyOn(view, 'onChatRoomPresence').andCallThrough();
@ -543,12 +543,11 @@
.c('status').attrs({code:'110'}).up()
.c('status').attrs({code:'210'}).nodeTree;
this.connection._dataRecv(test_utils.createRequest(presence));
converse.connection._dataRecv(test_utils.createRequest(presence));
expect(view.onChatRoomPresence).toHaveBeenCalled();
var $occupants = view.$('.occupant-list');
expect($occupants.children().length).toBe(1);
expect($occupants.children().first(0).text()).toBe("oldnick");
expect($occupants.children().first().hasClass('online')).toBe(true);
expect($chat_content.find('div.chat-info').length).toBe(1);
expect($chat_content.find('div.chat-info').html()).toBe(__(view.newNicknameMessages["210"], "oldnick"));
@ -569,17 +568,13 @@
.c('status').attrs({code:'303'}).up()
.c('status').attrs({code:'110'}).nodeTree;
this.connection._dataRecv(test_utils.createRequest(presence));
converse.connection._dataRecv(test_utils.createRequest(presence));
expect(view.onChatRoomPresence).toHaveBeenCalled();
expect($chat_content.find('div.chat-info').length).toBe(2);
expect($chat_content.find('div.chat-info').last().html()).toBe(__(view.newNicknameMessages["303"], "newnick"));
// The occupant is still listed (because they have affiliation
// of "member"), but they don't have the "online" class
// anymore.
$occupants = view.$('.occupant-list');
expect($occupants.children().length).toBe(1);
expect($occupants.children().first().hasClass('online')).toBe(false);
expect($occupants.children().length).toBe(0);
presence = $pres().attrs({
from:'lounge@localhost/newnick',
@ -594,14 +589,14 @@
}).up()
.c('status').attrs({code:'110'}).nodeTree;
this.connection._dataRecv(test_utils.createRequest(presence));
converse.connection._dataRecv(test_utils.createRequest(presence));
expect(view.onChatRoomPresence).toHaveBeenCalled();
expect($chat_content.find('div.chat-info').length).toBe(2);
expect($chat_content.find('div.chat-info').last().html()).toBe(__(view.newNicknameMessages["303"], "newnick"));
$occupants = view.$('.occupant-list');
expect($occupants.children().length).toBe(1);
expect($occupants.children().first(0).text()).toBe("newnick");
}.bind(converse));
});
it("informs users if they have been kicked out of the chat room", function () {
/* <presence

View File

@ -202,8 +202,6 @@
this.occupantsview.chatroomview = this;
this.render().$el.hide();
this.occupantsview.model.fetch({add:true});
_.each(['member', 'owner', 'admin'], this.fetchMembersList.bind(this));
var nick = this.model.get('nick');
if (!nick) {
this.checkForReservedNick();
@ -262,61 +260,6 @@
converse.ChatBoxView.prototype.close.apply(this, arguments);
},
fetchMembersList: function (affiliation) {
/* Fetch the member-list for a particular affiliation.
*
* Unfortunately it doesn't seem to work when trying to
* fetch a list for all affiliations, so we need to fetch
* them one by one.
*/
var iq = $iq({
'to': this.model.get('jid'),
'type': "get",
'from': converse.connection.jid
}).c("query", {'xmlns': Strophe.NS.MUC_ADMIN})
.c("item", {'affiliation': affiliation});
return converse.connection.sendIQ(
iq.tree(),
this.occupantsview.updateOccupantsOnMembersList.bind(this.occupantsview),
_.bind(this.onMembersListError, this, affiliation)
);
},
updateMembersList: function (members) {
/* Update the room's member-lists by sending a delta of
* changed memberships (for all affiliations).
*/
var iq = $iq({'to':this.model.get('jid'), 'type':'set', 'from':converse.connection.jid})
.c("query", {'xmlns': Strophe.NS.MUC_ADMIN});
_.each(members, function (member) {
iq.c('item', {
'affiliation': member.affiliation !== 'none' ? member.affiliation : 'member',
'jid': Strophe.getBareJidFromJid(member.jid)
});
});
return converse.connection.sendIQ(
iq.tree(),
this.onMembersListChanged.bind(this),
this.onMembersListChangedError.bind(this)
);
},
onMembersListChanged: function (stanza) {
converse.log("The membership-list for "+this.model.get('jid')+" has been succesfully updated");
},
onMembersListChangedError: function (stanza) {
this.showStatusNotification(__("An error occurred while trying to update the members list."));
},
onMembersListError: function (affiliation, iq) {
if (iq.getElementsByTagName('forbidden').length) {
converse.log("You are forbidden from retrieving the "+affiliation+"-list for "+this.model.get('jid'));
} else {
converse.log("Could not retrieve "+affiliation+"-list for "+this.model.get('jid'), "error");
}
},
toggleOccupants: function (ev, preserve_state) {
if (ev) {
ev.preventDefault();
@ -348,10 +291,6 @@
};
if (reason !== null) { attrs.reason = reason; }
if (this.model.get('password')) { attrs.password = this.model.get('password'); }
// We also add the invitee to the room's member-list.
this.updateMembersList([{'jid': recipient, 'affiliation': 'member'}]);
var invitation = $msg({
from: converse.connection.jid,
to: recipient,
@ -681,20 +620,7 @@
},
onConfigSaved: function (stanza) {
/*
* When changing a room to members-only, do we want to then
* add all current users to the membership list?
*
var members = [];
this.occupantsview.model.each(function (occupant) {
var affiliation = occupant.get('affiliation');
members.push({
'affiliation': affiliation !== 'none' ? affiliation : 'member',
'jid': Strophe.getBareJidFromJid(occupant.get('jid'))
});
});
this.updateMembersList(members);
*/
// TODO: provide feedback
},
onErrorConfigSaved: function (stanza) {
@ -1096,7 +1022,6 @@
initialize: function (attributes) {
this.set(_.extend({
'id': converse.connection.getUniqueId(),
'online': false
}, attributes));
}
});
@ -1109,13 +1034,12 @@
},
render: function () {
var new_el = converse.templates.occupant(
_.extend({
'nick': this.model.get('jid') || '',
'role': null,
'desc_moderator': __('This user is a moderator'),
'desc_occupant': __('This user can send messages in this room'),
'desc_visitor': __('This user can NOT send messages in this room')
}, this.model.toJSON())
_.extend(
this.model.toJSON(), {
'desc_moderator': __('This user is a moderator'),
'desc_occupant': __('This user can send messages in this room'),
'desc_visitor': __('This user can NOT send messages in this room')
})
);
var $parents = this.$el.parents();
if ($parents.length) {
@ -1226,28 +1150,20 @@
},
updateOccupantsOnPresence: function (pres) {
var attributes;
var data = this.parsePresence(pres);
var jid = Strophe.getBareJidFromJid(data.jid);
if (data.type === 'error') {
return true;
}
var occupant = this.findOccupant(data);
switch (data.type) {
case 'unavailable':
if (occupant) {
if (_.contains(['owner', 'admin', 'member'], occupant.get('affiliation'))) {
occupant.save({'online': false});
} else {
occupant.destroy();
}
}
if (occupant) { occupant.destroy(); }
break;
default:
attributes = _.extend(data, {
var jid = Strophe.getBareJidFromJid(data.jid);
var attributes = _.extend(data, {
'jid': jid ? jid : undefined,
'resource': data.jid ? Strophe.getResourceFromJid(data.jid) : undefined,
'online': true
'resource': data.jid ? Strophe.getResourceFromJid(data.jid) : undefined
});
if (occupant) {
occupant.save(attributes);
@ -1257,38 +1173,6 @@
}
},
updateOccupantsOnMembersList: function (iq) {
/* Create occupants based upon a received IQ stanza
* containing a member-list.
*
* <iq from='coven@chat.shakespeare.lit'
* id='member3'
* to='crone1@shakespeare.lit/desktop'
* type='result'>
* <query xmlns='http://jabber.org/protocol/muc#admin'>
* <item affiliation='member'
* jid='hag66@shakespeare.lit'
* nick='thirdwitch'
* role='participant'/>
* </query>
* </iq>
*/
_.each($(iq).find('query item'), function (item) {
var jid = item.getAttribute('jid');
var occupant = this.model.where({'jid': jid}).pop();
var data = {
'jid': item.getAttribute('jid'),
'affiliation': item.getAttribute('affiliation')
};
if (occupant) {
occupant.save(data);
} else {
this.model.create(data);
}
}.bind(this));
return;
},
initInviteWidget: function () {
var $el = this.$('input.invited-contact');
$el.typeahead({

View File

@ -1,4 +1,4 @@
<li class="{{role}} {[ if (online) { ]} online {[ } ]}" id="{{id}}"
<li class="{{role}}" id="{{id}}"
{[ if (role === "moderator") { ]}
title="{{desc_moderator}}"
{[ } ]}