Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
Optimized rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
zt64 committed Jun 25, 2021
1 parent 3526ff6 commit 483eade
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
9 changes: 5 additions & 4 deletions components/Preview.jsx
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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 () {
Expand All @@ -26,12 +27,12 @@ class Preview extends React.PureComponent {
const [ typingUsersFlat, typingUsers ] = this.fetchPreviewUsers();

return <Card className='dmti-preview'>
<DefaultHomeButton user={'previewUser'} typingUsersFlat={typingUsersFlat} typingUsers={typingUsers}/>
<this.DefaultHomeButton user={'previewUser'} typingUsersFlat={typingUsersFlat} typingUsers={typingUsers}/>
</Card>;
}

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: {} };

Expand Down
5 changes: 2 additions & 3 deletions components/TypingIndicator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 483eade

Please sign in to comment.