Ensure image lightbox is aware of its underlying message changes

pull/272/head
Scott Nonnenberg 6 years ago
parent ae2db9f09a
commit 667b2e63f1

@ -1275,8 +1275,12 @@
className: 'lightbox-wrapper', className: 'lightbox-wrapper',
Component: Signal.Components.Lightbox, Component: Signal.Components.Lightbox,
props, 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); Signal.Backbone.Views.Lightbox.show(this.lightboxView.el);
return; return;
} }
@ -1304,8 +1308,14 @@
className: 'lightbox-wrapper', className: 'lightbox-wrapper',
Component: Signal.Components.LightboxGallery, Component: Signal.Components.LightboxGallery,
props, 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); Signal.Backbone.Views.Lightbox.show(this.lightboxGalleryView.el);
}, },

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

Loading…
Cancel
Save