fix lack of null emote URL checks
This commit is contained in:
parent
598ebc4ed2
commit
f6191b2efe
2 changed files with 8 additions and 7 deletions
|
@ -21,17 +21,14 @@ function Home() {
|
||||||
let base_url = emote.data.host.url;
|
let base_url = emote.data.host.url;
|
||||||
// get the largest emote size, append it to the base url
|
// get the largest emote size, append it to the base url
|
||||||
let largest = emote.data.host.files[emote.data.host.files.length - 1];
|
let largest = emote.data.host.files[emote.data.host.files.length - 1];
|
||||||
// if width != height, skip it
|
// could be null
|
||||||
if (largest.width !== largest.height) {
|
if (!largest || largest.width !== largest.height) {
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `https:${base_url}/${largest.name}`;
|
return `https:${base_url}/${largest.name}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove null values
|
|
||||||
|
|
||||||
emoteUrls = emoteUrls.filter((emote: any) => emote !== null);
|
|
||||||
|
|
||||||
setEmotes(emoteUrls);
|
setEmotes(emoteUrls);
|
||||||
setCurrentEmote(Math.floor(Math.random() * emoteUrls.length));
|
setCurrentEmote(Math.floor(Math.random() * emoteUrls.length));
|
||||||
});
|
});
|
||||||
|
|
|
@ -55,6 +55,10 @@ function UserPage(props: UserPageProps) {
|
||||||
let base_url = emote.data.host.url;
|
let base_url = emote.data.host.url;
|
||||||
// get the largest emote size, append it to the base url
|
// get the largest emote size, append it to the base url
|
||||||
let largest = emote.data.host.files[emote.data.host.files.length - 1];
|
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}`;
|
emotes["7tv"][emote.data.name] = `https:${base_url}/${largest.name}`;
|
||||||
});
|
});
|
||||||
// same for global emotes
|
// same for global emotes
|
||||||
|
|
Loading…
Reference in a new issue