Ensure image lightbox is aware of its underlying message changes

This commit is contained in:
Scott Nonnenberg 2019-02-21 14:15:43 -08:00
parent ae2db9f09a
commit 667b2e63f1
2 changed files with 15 additions and 6 deletions

View file

@ -1275,8 +1275,12 @@
className: 'lightbox-wrapper',
Component: Signal.Components.Lightbox,
props,
onClose: () => Signal.Backbone.Views.Lightbox.hide(),
onClose: () => {
Signal.Backbone.Views.Lightbox.hide();
this.stopListening(message);
},
});
this.listenTo(message, 'expired', () => this.lightboxView.remove());
Signal.Backbone.Views.Lightbox.show(this.lightboxView.el);
return;
}
@ -1304,8 +1308,14 @@
className: 'lightbox-wrapper',
Component: Signal.Components.LightboxGallery,
props,
onClose: () => Signal.Backbone.Views.Lightbox.hide(),
onClose: () => {
Signal.Backbone.Views.Lightbox.hide();
this.stopListening(message);
},
});
this.listenTo(message, 'expired', () =>
this.lightboxGalleryView.remove()
);
Signal.Backbone.Views.Lightbox.show(this.lightboxGalleryView.el);
},

View file

@ -53,16 +53,15 @@
augmentProps(props) {
return Object.assign({}, props, {
close: () => {
if (this.onClose) {
this.onClose();
return;
}
this.remove();
},
i18n,
});
},
remove() {
if (this.onClose) {
this.onClose();
}
ReactDOM.unmountComponentAtNode(this.el);
Backbone.View.prototype.remove.call(this);
},