Preserve scroll position on toggle emoji panel, add attachment

pull/272/head
Scott Nonnenberg 6 years ago
parent 0de54e125c
commit 16a821645f

@ -151,16 +151,15 @@
this.fileInput = new Whisper.FileInputView({ this.fileInput = new Whisper.FileInputView({
el: this.$('.attachment-list'), el: this.$('.attachment-list'),
}); });
this.listenTo(
this.fileInput,
'attachments-changed',
this.toggleMicrophone
);
this.listenTo( this.listenTo(
this.fileInput, this.fileInput,
'choose-attachment', 'choose-attachment',
this.onChooseAttachment this.onChooseAttachment
); );
this.listenTo(this.fileInput, 'staged-attachments-changed', () => {
this.view.resetScrollPosition();
this.toggleMicrophone();
});
const getHeaderProps = () => { const getHeaderProps = () => {
const expireTimer = this.model.get('expireTimer'); const expireTimer = this.model.get('expireTimer');
@ -1485,7 +1484,6 @@
if (event.key !== 'Escape') { if (event.key !== 'Escape') {
return; return;
} }
this.closeEmojiPanel(); this.closeEmojiPanel();
}, },
openEmojiPanel() { openEmojiPanel() {
@ -1493,6 +1491,7 @@
this.emojiPanel = new EmojiPanel(this.$emojiPanelContainer[0], { this.emojiPanel = new EmojiPanel(this.$emojiPanelContainer[0], {
onClick: this.insertEmoji.bind(this), onClick: this.insertEmoji.bind(this),
}); });
this.view.resetScrollPosition();
this.updateMessageFieldSize({}); this.updateMessageFieldSize({});
}, },
closeEmojiPanel() { closeEmojiPanel() {
@ -1502,6 +1501,7 @@
this.$emojiPanelContainer.empty().outerHeight(0); this.$emojiPanelContainer.empty().outerHeight(0);
this.emojiPanel = null; this.emojiPanel = null;
this.view.resetScrollPosition();
this.updateMessageFieldSize({}); this.updateMessageFieldSize({});
}, },
insertEmoji(e) { insertEmoji(e) {

@ -72,6 +72,7 @@
render() { render() {
this.attachmentListView.update(this.getPropsForAttachmentList()); this.attachmentListView.update(this.getPropsForAttachmentList());
this.trigger('staged-attachments-changed');
}, },
getPropsForAttachmentList() { getPropsForAttachmentList() {
@ -120,7 +121,6 @@
onCloseAttachment(attachment) { onCloseAttachment(attachment) {
this.attachments = _.without(this.attachments, attachment); this.attachments = _.without(this.attachments, attachment);
this.trigger('attachments-changed');
this.render(); this.render();
}, },
@ -130,7 +130,6 @@
onClose() { onClose() {
this.attachments = []; this.attachments = [];
this.trigger('attachments-changed');
this.render(); this.render();
}, },
@ -271,7 +270,6 @@
this.attachments.push(attachment); this.attachments.push(attachment);
this.render(); this.render();
this.trigger('attachments-changed');
}, },
async maybeAddAttachment(file) { async maybeAddAttachment(file) {

Loading…
Cancel
Save