Skip to content

Commit 6378982

Browse files
fix platform indicators (#482)
* fix: platform indicators * chore(PlatformIndicators): bump version
1 parent ed76833 commit 6378982

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

PlatformIndicators/index.jsx

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ export default class PlatformIndicators {
2828
patchDMList() {
2929
const UserContext = React.createContext(null);
3030
const ChannelWrapper = Webpack.getBySource("activities", "isMultiUserDM", "isMobile");
31-
const [NameWrapper, Key_NW] = Webpack.getWithKey(x => x.toString().includes(".nameAndDecorators") && !x.toString().includes('"listitem"'));
31+
const [NameWrapper, Key_NW] = Webpack.getWithKey(
32+
Webpack.Filters.byStrings("MEMBER_LIST", "listitem", "avatar", "decorators")
33+
);
3234
const ChannelClasses = Webpack.getByKeys("channel", "decorator");
35+
const nameAndDecoratorsClass = Webpack.getByKeys('nameAndDecorators').nameAndDecorators;
3336

34-
Patcher.after(ChannelWrapper, "ZP", (_, __, res) => {
35-
if (!Settings.get("showInDmsList", true)) return;
37+
Patcher.after(ChannelWrapper, "Ay", (_, __, res) => {
38+
if(!Settings.get("showInDmsList", true)) return;
3639
Patcher.after(res, "type", (_, [props], res) => {
37-
if (!props.user) return; // Its a group DM
38-
if (Settings.get("ignoreBots", true) && props.user.bot) return;
40+
if(!props.user) return; // Its a group DM
41+
if(Settings.get("ignoreBots", true) && props.user.bot) return;
3942

4043
return (
4144
<UserContext.Provider value={props.user}>
@@ -46,19 +49,19 @@ export default class PlatformIndicators {
4649
});
4750

4851
const ChannelWrapperElement = document.querySelector(`h2 + .${ChannelClasses.channel}`);
49-
if (ChannelWrapperElement) {
52+
if(ChannelWrapperElement) {
5053
const ChannelWrapperInstance = ReactUtils.getOwnerInstance(ChannelWrapperElement);
51-
if (ChannelWrapperInstance) ChannelWrapperInstance.forceUpdate();
54+
if(ChannelWrapperInstance) ChannelWrapperInstance.forceUpdate();
5255
}
5356

5457
Patcher.after(NameWrapper, Key_NW, (_, __, res) => {
55-
if (!Settings.get("showInDmsList", true)) return;
58+
if(!Settings.get("showInDmsList", true)) return;
5659

5760
const user = React.useContext(UserContext);
58-
if (!user) return;
61+
if(!user) return;
5962

60-
const child = Utils.findInTree(res, e => e?.className?.includes("nameAndDecorators"), { walkable: ["children", "props"] });
61-
if (!child) return;
63+
const child = Utils.findInTree(res, e => e?.className?.includes(nameAndDecoratorsClass), { walkable: ["children", "props"] });
64+
if(!child) return;
6265

6366
child.style = { justifyContent: "unset" };
6467
child.children.push(
@@ -75,13 +78,13 @@ export default class PlatformIndicators {
7578
const MemberListClasses = Webpack.getByKeys("member", "memberInner");
7679

7780
Patcher.after(MemberItem, key, (_, [props], ret) => {
78-
if (ret?.props?.className?.includes("placeholder")) return;
79-
if (!Settings.get("showInMemberList", true)) return;
80-
if (Settings.get("ignoreBots", true) && props?.user.bot) return;
81+
if(ret?.props?.className?.includes("placeholder")) return;
82+
if(!Settings.get("showInMemberList", true)) return;
83+
if(Settings.get("ignoreBots", true) && props?.user.bot) return;
8184
const children = ret.props.children();
8285
const user = findInReactTree(children, e => e?.avatar && e?.name);
8386
let childs = children?.props?.name?.props?.children;
84-
if (user && childs) {
87+
if(user && childs) {
8588
children.props.name.props.children = [
8689
childs,
8790
<StatusIndicators
@@ -94,9 +97,9 @@ export default class PlatformIndicators {
9497
});
9598

9699
const MemberListUserElement = document.querySelector(`.${MemberListClasses.member}`);
97-
if (MemberListUserElement) {
100+
if(MemberListUserElement) {
98101
const MemberListUserInstance = ReactUtils.getOwnerInstance(MemberListUserElement);
99-
if (MemberListUserInstance) MemberListUserInstance.forceUpdate();
102+
if(MemberListUserInstance) MemberListUserInstance.forceUpdate();
100103
}
101104
}
102105

@@ -105,11 +108,11 @@ export default class PlatformIndicators {
105108

106109
Patcher.before(ChatUsername, key, (_, props) => {
107110
const mainProps = props[0];
108-
if (!Settings.get("showInChat", true)) return;
109-
if (Settings.get("ignoreBots", true) && mainProps?.author?.bot) return;
110-
if (!mainProps?.decorations) return;
111+
if(!Settings.get("showInChat", true)) return;
112+
if(Settings.get("ignoreBots", true) && mainProps?.author?.bot) return;
113+
if(!mainProps?.decorations) return;
111114
const target = mainProps.decorations?.[1];
112-
if (!Array.isArray(target)) mainProps.decorations[1] = target ? [target] : [];
115+
if(!Array.isArray(target)) mainProps.decorations[1] = target ? [target] : [];
113116
mainProps.decorations[1].unshift(
114117
<StatusIndicators
115118
userId={mainProps.message.author.id}
@@ -123,9 +126,9 @@ export default class PlatformIndicators {
123126
const [BadgeList, Key_BL] = Webpack.getWithKey(Webpack.Filters.byStrings("badges", "badgeClassName", ".BADGE"));
124127

125128
Patcher.after(BadgeList, Key_BL, (_, [{ displayProfile }], res) => {
126-
if (!Settings.get("showInBadges", true)) return;
127-
if (Settings.get("ignoreBots", true) && displayProfile?.application) return;
128-
if (!displayProfile?.userId) return;
129+
if(!Settings.get("showInBadges", true)) return;
130+
if(Settings.get("ignoreBots", true) && displayProfile?.application) return;
131+
if(!displayProfile?.userId) return;
129132
res.props.children.push(
130133
<StatusIndicators
131134
userId={displayProfile.userId}
@@ -146,7 +149,7 @@ export default class PlatformIndicators {
146149
`);
147150

148151
Patcher.after(UserInfo, key, (_, __, res) => {
149-
if (!Settings.get("showInFriendsList", true)) return;
152+
if(!Settings.get("showInFriendsList", true)) return;
150153
const unpatch = Patcher.after(res.props.children[1].props.children[0], "type", (_, [props], res) => {
151154
unpatch();
152155
const unpatch_ = Patcher.after(res, "type", (_, __, res) => {

PlatformIndicators/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "APlatformIndicators",
3-
"version": "1.5.22",
3+
"version": "1.5.23",
44
"author": "Strencher",
55
"authorId": "415849376598982656",
66
"description": "Adds indicators for every platform that the user is using.",

0 commit comments

Comments
 (0)