Childpatch

This commit is contained in:
Jiiks 2018-11-26 07:22:15 +02:00
parent 9ba8047066
commit ad28e7c638
2 changed files with 7 additions and 3 deletions

View File

@ -78,6 +78,12 @@ export default class BuiltinModule {
Patch(`BD:${this.moduleName}`, module)[when](fnName, cb.bind(this));
}
childPatch(module, fnName, child, cb, when = 'after') {
this.patch(module, fnName, (component, args, retVal) => {
this.patch(retVal[child[0]], child[1], cb, when);
});
}
/**
* Logger wraps
*/

View File

@ -227,9 +227,7 @@ export default new class EmoteModule extends BuiltinModule {
*/
async patchMessageContent() {
const MessageContent = await ReactComponents.getComponent('MessageContent', { selector: Reflection.resolve('container', 'containerCozy', 'containerCompact', 'edited').selector }, m => m.defaultProps && m.defaultProps.hasOwnProperty('disableButtons'));
this.patch(MessageContent.component.prototype, 'render', (component, args, retVal) => {
this.patch(retVal.props, 'children', this.afterRenderMessageContent);
});
this.childPatch(MessageContent.component.prototype, 'render', ['props', 'children'], this.afterRenderMessageContent);
MessageContent.forceUpdateAll();
}