diff --git a/src/equicordplugins/whosWatching/index.tsx b/src/equicordplugins/whosWatching/index.tsx index ae1a0627..71c932e1 100644 --- a/src/equicordplugins/whosWatching/index.tsx +++ b/src/equicordplugins/whosWatching/index.tsx @@ -37,20 +37,9 @@ const settings = definePluginSettings({ }, }); -function encodeStreamKey(stream) { - const { streamType, guildId, channelId, ownerId } = stream; - switch (streamType) { - case "guild": - return [streamType, guildId, channelId, ownerId].join(":"); - case "call": - return [streamType, channelId, ownerId].join(":"); - default: - throw console.log("Unknown stream type ".concat(streamType)); - } -} - function Watching({ userIds, guildId }: WatchingProps): JSX.Element { - // Missing Users happen when UserStore.getUser(id) returns null -- The client should automatically cache spectators, so this might not be possible but it's better to be sure just in case + // Missing Users happen when UserStore.getUser(id) returns null + // The client should automatically cache spectators, so this might not be possible but it's better to be sure just in case let missingUsers = 0; const users = userIds.map(id => UserStore.getUser(id)).filter(user => Boolean(user) ? true : (missingUsers += 1, false)); return ( @@ -82,13 +71,13 @@ export default definePlugin({ name: "WhosWatching", description: "Hover over the screenshare icon to view what users are watching your stream", authors: [EquicordDevs.Fres], - settings: settings, + settings, patches: [ { find: ".Masks.STATUS_SCREENSHARE,width:32", replacement: { - match: /(\i):function\(\)\{return (\i)\}/, - replace: "$1:function(){return $self.component({OriginalComponent:$2})}" + match: /jsx\)\((\i\.\i),{mask:/, + replace: "jsx)($self.component({OriginalComponent:$1}),{mask:" } }, { @@ -102,11 +91,9 @@ export default definePlugin({ ], WrapperComponent: ErrorBoundary.wrap(props => { const stream = useStateFromStores([ApplicationStreamingStore], () => ApplicationStreamingStore.getCurrentUserActiveStream()); - if (!stream) return
{props.children}
; - const userIds = ApplicationStreamingStore.getViewerIds(encodeStreamKey(stream)); - + const userIds: string[] = ApplicationStreamingStore.getViewerIds(stream); let missingUsers = 0; const users = userIds.map(id => UserStore.getUser(id)).filter(user => Boolean(user) ? true : (missingUsers += 1, false)); @@ -133,15 +120,15 @@ export default definePlugin({
{users.length ? <> - {i18n.Messages.SPECTATORS.format({ numViewers: userIds.length })} + + {i18n.Messages.SPECTATORS.format({ numViewers: userIds.length })} + ( { - const stream = useStateFromStores([ApplicationStreamingStore], () => ApplicationStreamingStore.getCurrentUserActiveStream()); - const viewers = ApplicationStreamingStore.getViewerIds(encodeStreamKey(stream)); + const stream = useStateFromStores( + [ApplicationStreamingStore], + () => ApplicationStreamingStore.getCurrentUserActiveStream() + ); + if (!stream) return null; + const viewers = ApplicationStreamingStore.getViewerIds(stream); return }> {({ onMouseEnter, onMouseLeave }) => (