Commit fdd0583a authored by JC Brand's avatar JC Brand

Rename RosterItem to RosterContact

parent 76a18bae
...@@ -326,10 +326,10 @@ ...@@ -326,10 +326,10 @@
img_type = $vcard.find('TYPE').text(), img_type = $vcard.find('TYPE').text(),
url = $vcard.find('URL').text(); url = $vcard.find('URL').text();
if (jid) { if (jid) {
var rosteritem = converse.roster.get(jid); var contact = converse.roster.get(jid);
if (rosteritem) { if (contact) {
fullname = _.isEmpty(fullname)? rosteritem.get('fullname') || jid: fullname; fullname = _.isEmpty(fullname)? contact.get('fullname') || jid: fullname;
rosteritem.save({ contact.save({
'fullname': fullname, 'fullname': fullname,
'image_type': img_type, 'image_type': img_type,
'image': img, 'image': img,
...@@ -345,9 +345,9 @@ ...@@ -345,9 +345,9 @@
jid, jid,
function (iq) { function (iq) {
// Error callback // Error callback
var rosteritem = converse.roster.get(jid); var contact = converse.roster.get(jid);
if (rosteritem) { if (contact) {
rosteritem.save({ contact.save({
'vcard_updated': moment().format() 'vcard_updated': moment().format()
}); });
} }
...@@ -490,9 +490,9 @@ ...@@ -490,9 +490,9 @@
this.initRoster = function () { this.initRoster = function () {
// Set up the roster // Set up the roster
this.roster = new this.RosterItems(); this.roster = new this.RosterContacts();
this.roster.browserStorage = new Backbone.BrowserStorage[converse.storage]( this.roster.browserStorage = new Backbone.BrowserStorage[converse.storage](
b64_sha1('converse.rosteritems-'+converse.bare_jid)); b64_sha1('converse.contacts-'+converse.bare_jid));
this.registerRosterHandler(); this.registerRosterHandler();
this.registerRosterXHandler(); this.registerRosterXHandler();
this.registerPresenceHandler(); this.registerPresenceHandler();
...@@ -1355,8 +1355,8 @@ ...@@ -1355,8 +1355,8 @@
updateVCard: function () { updateVCard: function () {
var jid = this.model.get('jid'), var jid = this.model.get('jid'),
rosteritem = converse.roster.get(jid); contact = converse.roster.get(jid);
if ((rosteritem) && (!rosteritem.get('vcard_updated'))) { if ((contact) && (!contact.get('vcard_updated'))) {
converse.getVCard( converse.getVCard(
jid, jid,
$.proxy(function (jid, fullname, image, image_type, url) { $.proxy(function (jid, fullname, image, image_type, url) {
...@@ -2797,7 +2797,7 @@ ...@@ -2797,7 +2797,7 @@
}, },
}); });
this.RosterItem = Backbone.Model.extend({ this.RosterContact = Backbone.Model.extend({
initialize: function (attributes, options) { initialize: function (attributes, options) {
var jid = attributes.jid; var jid = attributes.jid;
if (!attributes.fullname) { if (!attributes.fullname) {
...@@ -2816,7 +2816,7 @@ ...@@ -2816,7 +2816,7 @@
} }
}); });
this.RosterItemView = Backbone.View.extend({ this.RosterContactView = Backbone.View.extend({
tagName: 'dd', tagName: 'dd',
events: { events: {
...@@ -2952,10 +2952,10 @@ ...@@ -2952,10 +2952,10 @@
} }
}); });
this.RosterItems = Backbone.Collection.extend({ this.RosterContacts = Backbone.Collection.extend({
model: converse.RosterItem, model: converse.RosterContact,
comparator : function (rosteritem) { comparator : function (contact) {
var chat_status = rosteritem.get('chat_status'), var chat_status = contact.get('chat_status'),
rank = 4; rank = 4;
switch(chat_status) { switch(chat_status) {
case 'offline': case 'offline':
...@@ -3317,7 +3317,7 @@ ...@@ -3317,7 +3317,7 @@
}, },
onAdd: function (item) { onAdd: function (item) {
this.addRosterItem(item); this.addRosterContact(item);
if (item.get('is_last')) { if (item.get('is_last')) {
this.toggleHeaders().sortRoster().insertRosterFragment().updateCount(); this.toggleHeaders().sortRoster().insertRosterFragment().updateCount();
} }
...@@ -3402,25 +3402,25 @@ ...@@ -3402,25 +3402,25 @@
if (converse.roster_groups) { if (converse.roster_groups) {
if (item.get('groups').length === 0) { if (item.get('groups').length === 0) {
this.getRoster().find('.roster-group[data-group="'+HEADER_UNGROUPED+'"]') this.getRoster().find('.roster-group[data-group="'+HEADER_UNGROUPED+'"]')
.after((new converse.RosterItemView({model: item})).render().el); .after((new converse.RosterContactView({model: item})).render().el);
} else { } else {
_.each(item.get('groups'), $.proxy(function (group) { _.each(item.get('groups'), $.proxy(function (group) {
// We need a separate view per group // We need a separate view per group
this.getGroup(group).after((new converse.RosterItemView({model: item})).render().el); this.getGroup(group).after((new converse.RosterContactView({model: item})).render().el);
},this)); },this));
} }
} else { } else {
this.getRoster().find('.roster-group[data-group="'+HEADER_CURRENT_CONTACTS+'"]') this.getRoster().find('.roster-group[data-group="'+HEADER_CURRENT_CONTACTS+'"]')
.after((new converse.RosterItemView({model: item})).render().el); .after((new converse.RosterContactView({model: item})).render().el);
} }
}, },
addRosterItem: function (item) { addRosterContact: function (item) {
var view; var view;
if (item.get('subscription') === 'both' || item.get('subscription') === 'to') { if (item.get('subscription') === 'both' || item.get('subscription') === 'to') {
this.addCurrentContact(item); this.addCurrentContact(item);
} else { } else {
view = (new converse.RosterItemView({model: item})).render(); view = (new converse.RosterContactView({model: item})).render();
if ((item.get('ask') === 'subscribe') || (item.get('subscription') === 'from')) { if ((item.get('ask') === 'subscribe') || (item.get('subscription') === 'from')) {
this.getRoster().find('#pending-xmpp-contacts').after(view.el); this.getRoster().find('#pending-xmpp-contacts').after(view.el);
} else if (item.get('requesting') === true) { } else if (item.get('requesting') === true) {
......
...@@ -649,12 +649,12 @@ ...@@ -649,12 +649,12 @@
it("are saved to, and can be retrieved from, browserStorage", $.proxy(function () { it("are saved to, and can be retrieved from, browserStorage", $.proxy(function () {
var new_attrs, old_attrs, attrs, old_roster; var new_attrs, old_attrs, attrs, old_roster;
var num_contacts = this.roster.length; var num_contacts = this.roster.length;
new_roster = new this.RosterItems(); new_roster = new this.RosterContacts();
// Roster items are yet to be fetched from browserStorage // Roster items are yet to be fetched from browserStorage
expect(new_roster.length).toEqual(0); expect(new_roster.length).toEqual(0);
new_roster.browserStorage = new Backbone.BrowserStorage.session( new_roster.browserStorage = new Backbone.BrowserStorage.session(
b64_sha1('converse.rosteritems-dummy@localhost')); b64_sha1('converse.contacts-dummy@localhost'));
new_roster.fetch(); new_roster.fetch();
expect(new_roster.length).toEqual(num_contacts); expect(new_roster.length).toEqual(num_contacts);
......
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