From f6191b2efeaa81021a1f2e46ce36d0341888bce9 Mon Sep 17 00:00:00 2001
From: 3zachm <3zachn4@gmail.com>
Date: Fri, 21 Apr 2023 10:08:32 -0700
Subject: [PATCH] fix lack of null emote URL checks

---
 pages/index.tsx                 | 11 ++++-------
 pages/user/[username]/index.tsx |  4 ++++
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/pages/index.tsx b/pages/index.tsx
index 3c6802a..abb0291 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -21,17 +21,14 @@ function Home() {
           let base_url = emote.data.host.url;
           // get the largest emote size, append it to the base url
           let largest = emote.data.host.files[emote.data.host.files.length - 1];
-          // if width != height, skip it
-          if (largest.width !== largest.height) {
-            return null;
+          // could be null
+          if (!largest || largest.width !== largest.height) {
+            return false;
           }
+
           return `https:${base_url}/${largest.name}`;
         });
 
-        // remove null values
-
-        emoteUrls = emoteUrls.filter((emote: any) => emote !== null);
-
         setEmotes(emoteUrls);
         setCurrentEmote(Math.floor(Math.random() * emoteUrls.length));
       });
diff --git a/pages/user/[username]/index.tsx b/pages/user/[username]/index.tsx
index 660115d..e3db5f8 100644
--- a/pages/user/[username]/index.tsx
+++ b/pages/user/[username]/index.tsx
@@ -55,6 +55,10 @@ function UserPage(props: UserPageProps) {
           let base_url = emote.data.host.url;
           // get the largest emote size, append it to the base url
           let largest = emote.data.host.files[emote.data.host.files.length - 1];
+          // if null return
+          if (!largest) {
+            return false;
+          }
           emotes["7tv"][emote.data.name] = `https:${base_url}/${largest.name}`;
         });
         // same for global emotes