Skip to content

Commit

Permalink
Nullcheck and show all Platforms for the current User
Browse files Browse the repository at this point in the history
  • Loading branch information
domi-btnr committed Jun 27, 2024
1 parent 399fbd3 commit 9284661
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
9 changes: 5 additions & 4 deletions PlatformIndicators/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class PlatformIndicators {
start() {
this.patchDMs();
this.patchMemberList();
this.patchUsername();
this.patchChat();
this.patchBadges();
this.patchFriendList();
Styles.load();
Expand Down Expand Up @@ -87,12 +87,13 @@ export default class PlatformIndicators {
}
}

patchUsername() {
patchChat() {
const [ChatUsername, key] = Webpack.getWithKey(Webpack.Filters.byStrings(".guildMemberAvatar&&null!="));

Patcher.before(ChatUsername, key, (_, props) => {
const mainProps = props[0];
if (!Settings.get("showInChat", true)) return;
if (Settings.get("ignoreBots", true) && mainProps.message.author.bot) return;
if (Settings.get("ignoreBots", true) && mainProps?.author?.bot) return;
if (!Array.isArray(mainProps?.decorations[1]) && mainProps && mainProps?.decorations) mainProps.decorations[1] = [];
// for some reason props just won't exist.
mainProps?.decorations[1]?.unshift(
Expand All @@ -101,7 +102,7 @@ export default class PlatformIndicators {
type="Chat"
/>
);
})
});
}

patchBadges() {
Expand Down
14 changes: 9 additions & 5 deletions PlatformIndicators/modules/usePlatformStores.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ export default function usePlatformStores(userId, type) {

const clients = (() => {
if (user?.id === UserStore.getCurrentUser()?.id) {
const session = SessionsStore.getSession();
if (session) {
return {
[session.clientInfo.client]: isStreaming() ? "streaming" : session.status
};
const sessions = SessionsStore.getSessions();
if (sessions) {
const clientStatuses = Object.entries(sessions).reduce((acc, [, sessionData]) => {
const client = sessionData.clientInfo.client;
const status = isStreaming() ? "streaming" : sessionData.status;
acc[client] = status;
return acc;
}, {});
return clientStatuses;
}
return {};
}
Expand Down

0 comments on commit 9284661

Please sign in to comment.