Use existing ReactWrapper
This commit is contained in:
parent
32a3ef518b
commit
272c49c5bf
1 changed files with 4 additions and 27 deletions
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
window.Whisper = window.Whisper || {};
|
window.Whisper = window.Whisper || {};
|
||||||
|
|
||||||
|
const { MediaGallery } = window.Signal.Components;
|
||||||
|
|
||||||
Whisper.ExpiredToast = Whisper.ToastView.extend({
|
Whisper.ExpiredToast = Whisper.ToastView.extend({
|
||||||
render_attributes() {
|
render_attributes() {
|
||||||
return { toastMessage: i18n('expiredWarning') };
|
return { toastMessage: i18n('expiredWarning') };
|
||||||
|
@ -636,30 +638,6 @@
|
||||||
// events up to its parent elements in the DOM.
|
// events up to its parent elements in the DOM.
|
||||||
this.closeMenu();
|
this.closeMenu();
|
||||||
|
|
||||||
const ReactWrapper = Backbone.View.extend({
|
|
||||||
initialize(options) {
|
|
||||||
const { Component, props, onClose } = options;
|
|
||||||
this.render();
|
|
||||||
this.onClose = onClose;
|
|
||||||
|
|
||||||
const updatedProps = Object.assign({}, props, {
|
|
||||||
close: () => {
|
|
||||||
if (onClose) {
|
|
||||||
onClose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.remove();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const element = window.React.createElement(Component, updatedProps);
|
|
||||||
window.ReactDOM.render(element, this.el);
|
|
||||||
},
|
|
||||||
remove() {
|
|
||||||
window.ReactDOM.unmountComponentAtNode(this.el);
|
|
||||||
Backbone.View.prototype.remove.call(this);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Next:
|
// Next:
|
||||||
// pull latest media
|
// pull latest media
|
||||||
|
@ -671,13 +649,12 @@
|
||||||
// Thumbnail
|
// Thumbnail
|
||||||
// Lightbox - or do we use the lightbox already in the app?
|
// Lightbox - or do we use the lightbox already in the app?
|
||||||
|
|
||||||
const Component = window.Signal.Components.MediaGallery;
|
|
||||||
const props = {
|
const props = {
|
||||||
number: 10,
|
number: 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
const view = new ReactWrapper({
|
const view = new window.Whisper.ReactWrapper({
|
||||||
Component,
|
Component: MediaGallery,
|
||||||
props,
|
props,
|
||||||
onClose: this.resetPanel.bind(this),
|
onClose: this.resetPanel.bind(this),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue