Skip to content

Commit 2e86fc9

Browse files
BP602claude
andauthored
fix(7tv): guard channel avatar URL to prevent includes on undefined (#47)
* Fix cross-platform icon compatibility - Add cross-platform icon handling for Linux/macOS support - Convert Windows .ico to .png for non-Windows platforms - Update tray and thumbar icons to use platform-appropriate format Fixes application crashes on Linux due to unsupported .ico format 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(7tv): null-guard channel avatar in EmoteDialogs to prevent includes on undefined. Fixes #46 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 748fe92 commit 2e86fc9

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/renderer/src/components/Chat/Input/EmoteDialogs.jsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ const SevenTVEmoteDialog = memo(
114114
.filter((section) => section.emotes && section.emotes.length > 0);
115115
}, [sevenTVEmotes, searchTerm]);
116116

117+
// Compute a safe avatar URL for the channel section (if present)
118+
const channelSet = useMemo(() => sevenTVEmotes?.find((set) => set.type === "channel"), [sevenTVEmotes]);
119+
const channelAvatar = channelSet?.user?.avatar_url;
120+
const channelAvatarSrc = useMemo(() => {
121+
if (!channelAvatar) return STVLogo; // fallback to 7TV logo if missing
122+
// If it's a full URL or Twitch CDN URL, use as-is; otherwise, prefix https:
123+
if (channelAvatar.startsWith("http") || channelAvatar.includes("static-cdn.jtvnw.net")) return channelAvatar;
124+
return `https:${channelAvatar}`;
125+
}, [channelAvatar]);
126+
117127
return (
118128
<>
119129
{isDialogOpen && (
@@ -142,12 +152,7 @@ const SevenTVEmoteDialog = memo(
142152
<button
143153
className={clsx("dialogHeadMenuItem", currentSection === "channel" && "active")}
144154
onClick={() => setCurrentSection(currentSection === "channel" ? null : "channel")}>
145-
<img
146-
src={`${sevenTVEmotes?.find((set) => set.type === "channel")?.user?.avatar_url.includes("static-cdn.jtvnw.net") ? sevenTVEmotes?.find((set) => set.type === "channel")?.user?.avatar_url : `https:${sevenTVEmotes?.find((set) => set.type === "channel")?.user?.avatar_url}`}`}
147-
height={24}
148-
width={24}
149-
alt="Channel Emotes"
150-
/>
155+
<img src={channelAvatarSrc} height={24} width={24} alt="Channel Emotes" />
151156
</button>
152157
)}
153158
{sevenTVEmotes?.find((set) => set.type === "global" && set?.emotes?.length > 0) && (

0 commit comments

Comments
 (0)