Prevent instantiating a new BulkEdit react component with every click

pull/618/head
sachaaaaa 6 years ago
parent 2b6bd7e04a
commit bd9a900a1b

@ -8,33 +8,26 @@
Whisper.BulkEditView = Whisper.View.extend({ Whisper.BulkEditView = Whisper.View.extend({
initialize(options) { initialize(options) {
this.selectedMessages = new Set(); this.props = {
this.render(); onCancel: options.onCancel,
this.onCancel = options.onCancel; onDelete: options.onDelete,
this.onDelete = options.onDelete; messageCount: 0,
}, };
render() {
if (this.memberView) {
this.memberView.remove();
this.memberView = null;
}
this.memberView = new Whisper.ReactWrapperView({ this.memberView = new Whisper.ReactWrapperView({
className: 'bulk-edit-view', className: 'bulk-edit-view',
Component: window.Signal.Components.BulkEdit, Component: window.Signal.Components.BulkEdit,
props: { props: this.props,
messageCount: this.selectedMessages.size,
onCancel: this.onCancel,
onDelete: this.onDelete,
},
}); });
this.$el.append(this.memberView.el); this.$el.append(this.memberView.el);
return this; },
render() {
this.memberView.update(this.props);
}, },
update(selectedMessages) { update(selectionSize) {
this.selectedMessages = selectedMessages; this.props.messageCount = selectionSize;
this.render(); this.render();
}, },
}); });

@ -1797,7 +1797,7 @@
$('.compose').show(); $('.compose').show();
} }
this.bulkEditView.update(this.model.selectedMessages); this.bulkEditView.update(selectionSize);
}, },
resetMessageSelection() { resetMessageSelection() {

Loading…
Cancel
Save