Merge pull request #16 from Invest-Bot/hotfix/null-handle

Hotfix: Lack of null emote URL checks
This commit is contained in:
zach 2023-04-21 10:11:19 -07:00 committed by GitHub
commit b1829d7156
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View file

@ -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));
});

View file

@ -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