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

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
zt64 committed May 21, 2021
2 parents 707d207 + 50fdac5 commit 3526ff6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,25 @@ module.exports = class DMTypingIndicator extends Plugin {
this.injectTypingIndicator();
}

injectTypingIndicator () {
const { DefaultHomeButton } = getModule([ 'DefaultHomeButton' ], false);
const _this = this;
async injectTypingIndicator () {
const HomeButtonsModule = await getModule([ 'DefaultHomeButton' ]);

inject('dm-typing-indicator', DefaultHomeButton.prototype, 'render', function (_, res) {
inject('dm-typing-indicator', HomeButtonsModule, 'DefaultHomeButton', ([ props ], res) => {
if (!Array.isArray(res)) res = [ res ];

const badgeContainer = findInReactTree(res, n => n.type?.displayName === 'BlobMask');

const typingUsersFlat = this.props.typingUsersFlat || dmTypingStore.getFlattenedDMTypingUsers();
const typingUsers = this.props.typingUsers || dmTypingStore.getDMTypingUsers();
const typingUsersFlat = props.typingUsersFlat || dmTypingStore.getFlattenedDMTypingUsers();
const typingUsers = props.typingUsers || dmTypingStore.getDMTypingUsers();

const ConnectedTypingIndicator = Flux.connectStores([ powercord.api.settings.store, dmTypingStore ], () => ({
typingUsers,
typingUsersFlat,
...powercord.api.settings._fluxProps('dm-typing-indicator')
}))(TypingIndicator);

const indicatorStyle = _this.settings.get('indicatorStyle', 'icon');
const hideWhenViewed = _this.settings.get('hideWhenViewed', true);
const indicatorStyle = this.settings.get('indicatorStyle', 'icon');
const hideWhenViewed = this.settings.get('hideWhenViewed', true);

if (hideWhenViewed) {
const currentDMChannelId = window.location.href.match(/@me\/(\d+)/) && window.location.href.match(/@me\/(\d+)/)[1];
Expand All @@ -70,7 +69,7 @@ module.exports = class DMTypingIndicator extends Plugin {
badgeContainer.props.lowerBadge = React.createElement(ConnectedTypingIndicator, { badge: true });
} else {
res.splice(1, 0, React.createElement(ConnectedTypingIndicator, {
className: _this.classes.listItem,
className: this.classes.listItem,
clickable: typingUsersFlat.length === 1
}));
}
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.6"
"version": "3.1.7"
}

0 comments on commit 3526ff6

Please sign in to comment.