Skip to content
This repository was archived by the owner on Apr 23, 2026. It is now read-only.

Commit 0c62b0e

Browse files
authored
fix(followUser): Discord initialization Error component
1 parent ee34329 commit 0c62b0e

1 file changed

Lines changed: 29 additions & 17 deletions

File tree

src/plugins-extra/followUser/index.tsx

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ import {
2020
React,
2121
SelectedChannelStore,
2222
Toasts,
23-
UserStore
23+
useEffect,
24+
UserStore,
25+
useState
2426
} from "@webpack/common";
2527
import type { PropsWithChildren, SVGProps } from "react";
2628

@@ -346,22 +348,32 @@ export default definePlugin({
346348

347349
FollowIndicator() {
348350
const { plugins: { FollowUser: { followUserId } } } = useSettings(["plugins.FollowUser.followUserId"]);
349-
if (followUserId) {
350-
return (
351-
<HeaderBarIcon
352-
tooltip={`Following ${UserStore.getUser(followUserId).username} (click to trigger manually, right-click to unfollow)`}
353-
icon={UnfollowIcon}
354-
onClick={() => {
355-
triggerFollow();
356-
}}
357-
onContextMenu={() => {
358-
settings.store.followUserId = "";
359-
}}
360-
/>
361-
);
362-
}
363-
364-
return null;
351+
const [followUsername, setFollowUsername] = useState<string | undefined>(undefined);
352+
353+
const updateUserName = () => {
354+
if (!followUserId) return;
355+
356+
const user = UserStore.getUser(followUserId);
357+
if (!user) {
358+
setTimeout(() => updateUserName(), 1);
359+
return;
360+
}
361+
362+
setFollowUsername(user.username);
363+
};
364+
365+
useEffect(() => updateUserName(), [followUserId]);
366+
367+
return <>
368+
{followUserId && <HeaderBarIcon
369+
tooltip={`Following ${followUsername} (click to trigger manually, right-click to unfollow)`}
370+
icon={UnfollowIcon}
371+
onClick={() => triggerFollow()}
372+
onContextMenu={() => {
373+
settings.store.followUserId = "";
374+
}}
375+
/>}
376+
</>;
365377
},
366378

367379
addIconToToolBar(e: { toolbar: React.ReactNode[] | React.ReactNode; }) {

0 commit comments

Comments
 (0)