From 483eadea6f564e47b6a4d79789a1737d9ecf7bca Mon Sep 17 00:00:00 2001 From: litleck Date: Thu, 24 Jun 2021 23:09:55 -0400 Subject: [PATCH] Optimized rendering --- components/Preview.jsx | 9 +++++---- components/TypingIndicator.jsx | 5 ++--- i18n/en-US.json | 2 +- manifest.json | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/Preview.jsx b/components/Preview.jsx index 6419274..a363fa6 100644 --- a/components/Preview.jsx +++ b/components/Preview.jsx @@ -1,8 +1,6 @@ const { React, Flux, getModule } = require('powercord/webpack'); const { Card, AsyncComponent } = require('powercord/components'); -const DefaultHomeButton = AsyncComponent.from(getModule([ 'DefaultHomeButton' ]).then(m => m.DefaultHomeButton)); - class Preview extends React.PureComponent { constructor (props) { super(props); @@ -12,6 +10,9 @@ class Preview extends React.PureComponent { typingRotation: null, currentRotation: 0 }; + + this.DefaultHomeButton = AsyncComponent.from(getModule([ 'DefaultHomeButton' ]).then(m => m.DefaultHomeButton)); + this.getUsers = getModule([ 'getUsers' ], false).getUsers; } componentWillMount () { @@ -26,12 +27,12 @@ class Preview extends React.PureComponent { const [ typingUsersFlat, typingUsers ] = this.fetchPreviewUsers(); return - + ; } fetchPreviewUsers () { - const cachedUsers = Object.values(getModule([ 'getUsers' ], false).getUsers());// .filter(user => user.id !== this.props.main.currentUserId); + const cachedUsers = Object.values(this.getUsers());// .filter(user => user.id !== this.props.main.currentUserId); const getRandomUserId = () => cachedUsers[Math.floor(Math.random() * cachedUsers.length)].id; const typingUsers = { 1337: {} }; diff --git a/components/TypingIndicator.jsx b/components/TypingIndicator.jsx index 914ab4f..3f19a75 100644 --- a/components/TypingIndicator.jsx +++ b/components/TypingIndicator.jsx @@ -9,18 +9,17 @@ module.exports = class TypingIndicator extends React.PureComponent { this.getSetting = props.getSetting; this.channelStore = getModule([ 'hasChannel' ], false); this.channelUtils = getModule([ 'openPrivateChannel' ], false); + this.transitionTo = getModule([ 'transitionTo'], false).transitionTo; } async handleOpenPrivateChannel (typingUsers, user) { - const { transitionTo } = await getModule([ 'transitionTo' ]); - const channelIds = Object.keys(typingUsers); const privateGroupChannel = Object.values(this.channelStore.getMutablePrivateChannels()).find(channel => ( channel.isGroupDM() && channel.id === channelIds[0] )); if (privateGroupChannel) { - return transitionTo(Routes.CHANNEL('@me', privateGroupChannel.id)); + return this.transitionTo(Routes.CHANNEL('@me', privateGroupChannel.id)); } return this.channelUtils.openPrivateChannel(user.id); diff --git a/i18n/en-US.json b/i18n/en-US.json index 58258ce..6cbdfd1 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -13,7 +13,7 @@ "DTMI_SWITCH_IGNORE_NON_FRIEND": "Ignore Non-Friend Users", "DTMI_SWITCH_IGNORE_NON_FRIEND_NOTE": "Don't show indicator for users who you are not friends with.", "DTMI_SWITCH_ANIMATE_INDICATOR": "Animate Indicator", - "DTMI_SWITCH_ANIMATE_INDICATOR_NOTE": "Animate the indicator even if the Discord window isnt focused.", + "DTMI_SWITCH_ANIMATE_INDICATOR_NOTE": "Animate the indicator.", "DTMI_TYPING_USERS_COUNT": "{count, number} typing...", "DTMI_SLIDER_MAX_USERS": "Tooltip Max Users", "DTMI_SLIDER_MAX_USERS_NOTE": "The maximum amount of users to display on the tooltip." diff --git a/manifest.json b/manifest.json index c4ed49c..60e9767 100644 --- a/manifest.json +++ b/manifest.json @@ -3,5 +3,5 @@ "description": "Displays whenever a user is typing in your DMs.", "author": "Moth, M|-|4r13y ツ", "license": "MIT", - "version": "3.1.7" + "version": "3.1.8" }