Refactored XMPPStatus a bit to remove initStatus and to always show status_message
This commit is contained in:
parent
0f1739ca3d
commit
e41fddee0f
36
converse.js
36
converse.js
|
@ -1092,7 +1092,7 @@
|
||||||
view.model = item;
|
view.model = item;
|
||||||
view.initialize();
|
view.initialize();
|
||||||
if (item.get('id') !== 'controlbox') {
|
if (item.get('id') !== 'controlbox') {
|
||||||
// FIXME: Why is it necessary to append chatboxes again?
|
// FIXME: Why is it necessary to again append chatboxes?
|
||||||
view.$el.appendTo(this.$el);
|
view.$el.appendTo(this.$el);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1667,19 +1667,6 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
initStatus: function () {
|
|
||||||
/* Called when the page is loaded and we aren't sure what the users
|
|
||||||
* status is. Will also cause the UI to be updated with the correct
|
|
||||||
* status.
|
|
||||||
*/
|
|
||||||
var stat = this.get('status');
|
|
||||||
if (stat === undefined) {
|
|
||||||
this.setStatus('online');
|
|
||||||
} else {
|
|
||||||
this.sendPresence(stat);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
sendPresence: function (type) {
|
sendPresence: function (type) {
|
||||||
var status_message = this.get('status_message'),
|
var status_message = this.get('status_message'),
|
||||||
presence;
|
presence;
|
||||||
|
@ -1777,15 +1764,14 @@
|
||||||
return pretty_status;
|
return pretty_status;
|
||||||
},
|
},
|
||||||
|
|
||||||
updateStatusUI: function (ev) {
|
updateStatusUI: function (model) {
|
||||||
var stat = ev.get('status'),
|
var stat = model.get('status'),
|
||||||
status_message;
|
status_message = model.get('status_message') || "I am " + this.getPrettyStatus(stat);
|
||||||
status_message = ev.get('status_message') || "I am " + this.getPrettyStatus(stat);
|
|
||||||
this.$el.find('#fancy-xmpp-status-select').html(
|
this.$el.find('#fancy-xmpp-status-select').html(
|
||||||
this.status_template({
|
this.status_template({
|
||||||
'chat_status': stat,
|
'chat_status': stat,
|
||||||
'status_message': status_message
|
'status_message': status_message
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
choose_template: _.template(
|
choose_template: _.template(
|
||||||
|
@ -1803,9 +1789,7 @@
|
||||||
'</li>'),
|
'</li>'),
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.model.initStatus();
|
this.model.on("change", this.updateStatusUI, this);
|
||||||
// Listen for status change on the model and initialize
|
|
||||||
this.options.model.on("change", $.proxy(this.updateStatusUI, this));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
|
@ -1961,7 +1945,6 @@
|
||||||
this.xmppstatus = new this.XMPPStatus({id:1});
|
this.xmppstatus = new this.XMPPStatus({id:1});
|
||||||
this.xmppstatus.localStorage = new Backbone.LocalStorage(
|
this.xmppstatus.localStorage = new Backbone.LocalStorage(
|
||||||
'converse.xmppstatus'+this.connection.bare_jid);
|
'converse.xmppstatus'+this.connection.bare_jid);
|
||||||
this.xmppstatus.fetch();
|
|
||||||
|
|
||||||
this.chatboxes.onConnected();
|
this.chatboxes.onConnected();
|
||||||
|
|
||||||
|
@ -1986,11 +1969,12 @@
|
||||||
return true;
|
return true;
|
||||||
}, this), null, 'message', 'chat');
|
}, this), null, 'message', 'chat');
|
||||||
|
|
||||||
// XMPP Status
|
|
||||||
this.xmppstatusview = new this.XMPPStatusView({
|
this.xmppstatusview = new this.XMPPStatusView({
|
||||||
'model': this.xmppstatus
|
'model': this.xmppstatus
|
||||||
});
|
});
|
||||||
this.xmppstatusview.render();
|
this.xmppstatusview.render();
|
||||||
|
this.xmppstatus.fetch();
|
||||||
|
this.xmppstatus.sendPresence(this.xmppstatus.get('status'));
|
||||||
}, this));
|
}, this));
|
||||||
$connecting.hide();
|
$connecting.hide();
|
||||||
$toggle.show();
|
$toggle.show();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user