mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Less jquery, more templating in conversation view
`if (foo) then jquery-dom-insert...` is a poor pattern to follow. Instead, let mustache do the work.
This commit is contained in:
@@ -18,12 +18,17 @@
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
Whisper.ConversationView = Backbone.View.extend({
|
||||
className: 'conversation',
|
||||
className: function() {
|
||||
return [ 'conversation', this.model.get('type') ].join(' ');
|
||||
},
|
||||
initialize: function() {
|
||||
this.listenTo(this.model, 'destroy', this.stopListening); // auto update
|
||||
this.template = $('#conversation').html();
|
||||
Mustache.parse(this.template);
|
||||
this.$el.html(Mustache.render(this.template));
|
||||
|
||||
this.$el.html(Mustache.render(this.template,
|
||||
{ group: this.model.get('type') === 'group' }
|
||||
));
|
||||
|
||||
this.fileInput = new Whisper.FileInputView({
|
||||
el: this.$el.find('.attachments')
|
||||
@@ -35,11 +40,6 @@
|
||||
this.$el.find('.discussion-container').append(this.view.el);
|
||||
|
||||
this.model.fetchMessages({reset: true});
|
||||
|
||||
if (this.model.get('type') === 'group') {
|
||||
this.$el.addClass('group');
|
||||
this.$el.find('.send-message-area').append($('<button>').addClass('new-group-update').text('Update group'));
|
||||
}
|
||||
},
|
||||
|
||||
events: {
|
||||
|
||||
Reference in New Issue
Block a user