From b159d31eeaaf5bdbb69e34fc5a86e3ee3dd8a429 Mon Sep 17 00:00:00 2001
From: 1Lighty <49841131+1Lighty@users.noreply.github.com>
Date: Sat, 26 Jun 2021 06:09:52 +0200
Subject: [PATCH] Fix performance issues, updating issues and a UX issue (#6)
* fix possible failure bricking updating on pc
* fix constant hard rerendering issues
* fix webpack search in render and rerendering issue
* make UX slightly better by adding min height
* bump version
---
components/TypingIndicator.jsx | 23 +++++++++++++---------
index.js | 35 ++++++++++++++++++++++------------
manifest.json | 4 ++--
stores/dmTypingStore.js | 3 ++-
style.css | 1 +
5 files changed, 42 insertions(+), 24 deletions(-)
diff --git a/components/TypingIndicator.jsx b/components/TypingIndicator.jsx
index 3f19a75..bf97609 100644
--- a/components/TypingIndicator.jsx
+++ b/components/TypingIndicator.jsx
@@ -2,27 +2,32 @@
const { React, getModule, i18n: { Messages }, constants: { Routes } } = require('powercord/webpack');
const { Tooltip, Spinner } = require('powercord/components');
+const ChannelStore = getModule([ 'hasChannel' ], false);
+const ChannelUtils = getModule([ 'openPrivateChannel' ], false);
+const Router = getModule([ 'transitionTo' ], false);
+
module.exports = class TypingIndicator extends React.PureComponent {
constructor (props) {
super(props);
this.getSetting = props.getSetting;
- this.channelStore = getModule([ 'hasChannel' ], false);
- this.channelUtils = getModule([ 'openPrivateChannel' ], false);
- this.transitionTo = getModule([ 'transitionTo'], false).transitionTo;
+ // bind has to happen here, if you do bind in render, then it will just
+ // rerender every single time needlessly
+ this.handleOpenPrivateChannel = this.handleOpenPrivateChannel.bind(this);
}
- async handleOpenPrivateChannel (typingUsers, user) {
+ handleOpenPrivateChannel () {
+ const { typingUsers, typingUsersFlat: [ user ] } = this.props;
const channelIds = Object.keys(typingUsers);
- const privateGroupChannel = Object.values(this.channelStore.getMutablePrivateChannels()).find(channel => (
+ const privateGroupChannel = Object.values(ChannelStore.getMutablePrivateChannels()).find(channel => (
channel.isGroupDM() && channel.id === channelIds[0]
));
if (privateGroupChannel) {
- return this.transitionTo(Routes.CHANNEL('@me', privateGroupChannel.id));
+ return Router.transitionTo(Routes.CHANNEL('@me', privateGroupChannel.id));
}
- return this.channelUtils.openPrivateChannel(user.id);
+ return ChannelUtils.openPrivateChannel(user.id);
}
formatUsernames () {
@@ -91,7 +96,7 @@ module.exports = class TypingIndicator extends React.PureComponent {
}
render () {
- const { clickable, typingUsers, typingUsersFlat } = this.props;
+ const { clickable, typingUsersFlat } = this.props;
if (typingUsersFlat.length === 0) return null;
@@ -102,7 +107,7 @@ module.exports = class TypingIndicator extends React.PureComponent {
return