Rerender messages after loading emotes

This commit is contained in:
Samuel Elliott 2019-03-10 17:45:20 +00:00
parent fcfee53928
commit 226719b36e
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
4 changed files with 13 additions and 8 deletions

View File

@ -22,10 +22,10 @@ export default class BuiltinModule {
this.patch = this.patch.bind(this);
}
init() {
async init() {
this.setting.on('setting-updated', this._settingUpdated);
if (this.setting.value) {
if (this.enabled) this.enabled();
if (this.enabled) await this.enabled();
if (this.applyPatches) this.applyPatches();
}
}
@ -38,10 +38,10 @@ export default class BuiltinModule {
return Patcher.getPatchesByCaller(`BD:${this.moduleName}`);
}
_settingUpdated(e) {
async _settingUpdated(e) {
const { value } = e;
if (value === true) {
if (this.enabled) this.enabled(e);
if (this.enabled) await this.enabled(e);
if (this.applyPatches) this.applyPatches();
return;
}

View File

@ -239,9 +239,11 @@ export default new class E2EE extends BuiltinModule {
const MessageContent = await ReactComponents.getComponent('MessageContent');
this.patch(MessageContent.component.prototype, 'render', this.beforeRenderMessageContent, 'before');
this.patch(MessageContent.component.prototype, 'render', this.afterRenderMessageContent);
MessageContent.forceUpdateAll();
const ImageWrapper = await ReactComponents.getComponent('ImageWrapper');
this.patch(ImageWrapper.component.prototype, 'render', this.beforeRenderImageWrapper, 'before');
ImageWrapper.forceUpdateAll();
}
beforeRenderMessageContent(component) {

View File

@ -12,7 +12,7 @@ import BuiltinModule from './BuiltinModule';
import path from 'path';
import { request } from 'vendor';
import { Utils, FileUtils } from 'common';
import { Utils, FileUtils, ClientLogger as Logger } from 'common';
import { DiscordApi, Settings, Globals, Reflection, ReactComponents, Database } from 'modules';
import { DiscordContextMenu } from 'ui';
@ -131,6 +131,8 @@ export default new class EmoteModule extends BuiltinModule {
this.database.set(id, { id: emote.value.id || value, type });
}
Logger.log('EmoteModule', ['Loaded emote database']);
}
async loadUserData() {

View File

@ -397,8 +397,10 @@ export class ReactAutoPatcher {
}
static async patchImageWrapper() {
ReactComponents.componentAliases.ImageWrapper = 'Image';
const { selector } = Reflection.resolve('imageWrapper');
this.ImageWrapper = await ReactComponents.getComponent('ImageWrapper', {selector});
this.ImageWrapper = await ReactComponents.getComponent('ImageWrapper', {selector}, c => typeof c.defaultProps.children === 'function');
}
static async patchChannelMember() {
@ -541,8 +543,7 @@ export class ReactAutoPatcher {
this.UserPopout = await ReactComponents.getComponent('UserPopout', {selector}, c => c.prototype.renderHeader);
this.unpatchUserPopout = MonkeyPatch('BD:ReactComponents', this.UserPopout.component.prototype).after('render', (component, args, retVal) => {
Logger.log('ReactComponents', ['Rendering UserPopout', component, args, retVal]);
const root = retVal.props.children[0] || retVal.props.children;
const root = retVal.props.children[0] || retVal.props.children;
const { user, guild, guildMember } = component.props;
if (!user) return;
root.props['data-user-id'] = user.id;