From 928466167180c31a2feb27ba954529be5c89aaeb Mon Sep 17 00:00:00 2001 From: domi-btnr Date: Thu, 27 Jun 2024 11:40:17 +0200 Subject: [PATCH] Nullcheck and show all Platforms for the current User --- PlatformIndicators/index.jsx | 9 +++++---- PlatformIndicators/modules/usePlatformStores.js | 14 +++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/PlatformIndicators/index.jsx b/PlatformIndicators/index.jsx index b1e3d9f..172c544 100644 --- a/PlatformIndicators/index.jsx +++ b/PlatformIndicators/index.jsx @@ -15,7 +15,7 @@ export default class PlatformIndicators { start() { this.patchDMs(); this.patchMemberList(); - this.patchUsername(); + this.patchChat(); this.patchBadges(); this.patchFriendList(); Styles.load(); @@ -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( @@ -101,7 +102,7 @@ export default class PlatformIndicators { type="Chat" /> ); - }) + }); } patchBadges() { diff --git a/PlatformIndicators/modules/usePlatformStores.js b/PlatformIndicators/modules/usePlatformStores.js index 237da9b..4e5169c 100644 --- a/PlatformIndicators/modules/usePlatformStores.js +++ b/PlatformIndicators/modules/usePlatformStores.js @@ -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 {}; }