Nicer looking end-session and group control messages
This commit is contained in:
parent
f160d1b7ad
commit
a7079206f4
7 changed files with 45 additions and 20 deletions
|
@ -45,10 +45,23 @@
|
|||
},
|
||||
getDescription: function() {
|
||||
if (this.isGroupUpdate()) {
|
||||
return 'Updated the group';
|
||||
var group_update = this.get('group_update');
|
||||
if (group_update.left) {
|
||||
return group_update.left + ' left the group.';
|
||||
}
|
||||
|
||||
var messages = ['Updated the group.'];
|
||||
if (group_update.name) {
|
||||
messages.push("Title is now '" + group_update.name + "'.");
|
||||
}
|
||||
if (group_update.joined) {
|
||||
messages.push(group_update.joined.join(', ') + ' joined the group.');
|
||||
}
|
||||
|
||||
return messages.join(' ');
|
||||
}
|
||||
if (this.isEndSession()) {
|
||||
return 'Secure session ended';
|
||||
return 'Secure session ended.';
|
||||
}
|
||||
if (this.isIncoming() && this.hasKeyConflicts()) {
|
||||
return 'Received message with unknown identity key.';
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
Whisper.EndSessionView = Backbone.View.extend({
|
||||
Whisper.EndSessionView = Whisper.View.extend({
|
||||
tagName: "div",
|
||||
className: "end-session",
|
||||
render: function() {
|
||||
this.$el.text("Secure session ended");
|
||||
return this;
|
||||
template: $('#message').html(),
|
||||
render_attributes: function() {
|
||||
return { text: 'Secure session ended' };
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
var contact = this.model.getContact();
|
||||
this.$el.html(
|
||||
Mustache.render(this.template, {
|
||||
message: this.model.get('body'),
|
||||
message: this.model.getDescription(),
|
||||
timestamp: moment(this.model.get('received_at')).fromNow(),
|
||||
sender: (contact && contact.getTitle()) || '',
|
||||
avatar_url: (contact && contact.getAvatarUrl())
|
||||
|
@ -79,15 +79,7 @@
|
|||
return ["entry", this.model.get('type')].join(' ');
|
||||
},
|
||||
initialize: function() {
|
||||
if (this.model.isEndSession()) {
|
||||
this.view = new Whisper.EndSessionView();
|
||||
} else if (this.model.isGroupUpdate()) {
|
||||
this.view = new Whisper.GroupUpdateView({
|
||||
model: this.model.get('group_update')
|
||||
});
|
||||
} else {
|
||||
this.view = new ContentMessageView({model: this.model});
|
||||
}
|
||||
this.view = new ContentMessageView({model: this.model});
|
||||
this.$el.append(this.view.el);
|
||||
|
||||
this.listenTo(this.model, 'destroy', this.remove); // auto update
|
||||
|
@ -99,6 +91,11 @@
|
|||
this.$el.trigger('select', {message: this.model});
|
||||
},
|
||||
render: function() {
|
||||
if (this.model.isEndSession() || this.model.isGroupUpdate()) {
|
||||
this.$el.addClass('control');
|
||||
} else {
|
||||
this.$el.removeClass('control');
|
||||
}
|
||||
this.view.render();
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue