Rename ReactComponentHelpers to ReactHelpers

This commit is contained in:
Samuel Elliott 2018-04-01 15:16:30 +01:00
parent 7f5fa44fd3
commit 554b8d195b
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
3 changed files with 15 additions and 9 deletions

View File

@ -16,7 +16,7 @@ export { default as Vendor } from './vendor';
export * from './webpackmodules';
export * from './patcher';
export { ReactComponents, ReactAutoPatcher, Helpers as ReactComponentHelpers } from './reactcomponents';
export * from './reactcomponents';
export { default as EventListener } from './eventlistener';
export { default as SocketProxy } from './socketproxy';
export { default as EventHook } from './eventhook';

View File

@ -16,7 +16,7 @@ import { MonkeyPatch, Patcher } from './patcher';
import { WebpackModules, Filters } from './webpackmodules';
import DiscordApi from './discordapi';
export class Helpers {
class Helpers {
static get plannedActions() {
return this._plannedActions || (this._plannedActions = new Map());
}
@ -163,6 +163,8 @@ export class Helpers {
}
}
export { Helpers as ReactHelpers };
class ReactComponent {
constructor(id, component, retVal) {
this._id = id;

View File

@ -8,7 +8,7 @@
* LICENSE file in the root directory of this source tree.
*/
import { EventListener, ReactComponents, ReactComponentHelpers as Helpers, MonkeyPatch } from 'modules';
import { EventListener, ReactComponents, ReactHelpers, MonkeyPatch } from 'modules';
import { ClientLogger as Logger } from 'common';
import DOM from './dom';
import { BdBadge, BdMessageBadge } from './components/bd';
@ -110,7 +110,7 @@ export default class extends EventListener {
this.unpatchChannelMemberRender = MonkeyPatch('ProfileBadges', ChannelMember.component.prototype).after('render', (component, args, retVal) => {
if (!retVal.props || !retVal.props.children) return;
const user = Helpers.findProp(component, 'user');
const user = ReactHelpers.findProp(component, 'user');
if (!user) return;
const c = contributors.find(c => c.id === user.id);
if (!c) return;
@ -135,7 +135,7 @@ export default class extends EventListener {
try {
if (!retVal.props || !retVal.props.children) return;
const user = Helpers.findProp(this, 'user');
const user = ReactHelpers.findProp(this, 'user');
if (!user) return;
const c = contributors.find(c => c.id === user.id);
if (!c) return;
@ -151,24 +151,28 @@ export default class extends EventListener {
}
componentDidMount() {
const element = Helpers.ReactDOM.findDOMNode(this);
const element = ReactHelpers.ReactDOM.findDOMNode(this);
if (!element) return;
ProfileBadges.injectMessageBadges(element);
}
componentDidUpdate() {
const element = Helpers.ReactDOM.findDOMNode(this);
const element = ReactHelpers.ReactDOM.findDOMNode(this);
if (!element) return;
// ProfileBadges.injectMessageBadges(element);
ProfileBadges.injectMessageBadges(element);
}
};
}
injectMessageBadges(element) {
for (const beo of element.getElementsByClassName('bd-badge-outer')) this.injectNameTagBadge(beo);
for (const beo of element.getElementsByClassName('bd-badge-outer')) this.injectMessageBadge(beo);
}
injectMessageBadge(root) {
while (root.firstChild) {
root.removeChild(root.firstChild);
}
const { userid } = root.dataset;
if (!userid) return;