From 2ee8cae8d49bdd4c645a357c243dfbb5de27a392 Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 10 Nov 2015 20:39:36 -0800 Subject: [PATCH] Move some initial setup to the 'opened' event Avoid inbox views digging too deep into conversation views. // FREEBIE --- js/views/conversation_view.js | 10 +++++++++- js/views/inbox_view.js | 3 --- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 4c81d5da..085c85f1 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -27,7 +27,7 @@ this.listenTo(this.model, 'change:name', this.updateTitle); this.listenTo(this.model, 'newmessage', this.addMessage); this.listenTo(this.model, 'change:unreadCount', this.onUnread); - this.listenTo(this.model, 'opened', this.focusMessageField); + this.listenTo(this.model, 'opened', this.onOpened); this.render(); twemoji.parse(this.el, { base: '/images/twemoji/', size: 16 }); @@ -85,6 +85,14 @@ 'click .choose-file': 'focusMessageField', 'loadMore .message-list': 'fetchMessages' }, + + onOpened: function() { + this.view.resetScrollPosition(); + this.$el.trigger('force-resize'); + this.focusMessageField(); + this.model.markRead(); + }, + focusMessageField: function() { this.$messageField.focus(); }, diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js index 59bf9dd5..5d37195b 100644 --- a/js/views/inbox_view.js +++ b/js/views/inbox_view.js @@ -56,9 +56,6 @@ $el = view.$el; } $el.prependTo(this.el); - $el.find('.message-list').trigger('reset-scroll'); - $el.trigger('force-resize'); - conversation.markRead(); conversation.trigger('opened'); } });