mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-04-26 07:49:22 -05:00
Add null/bounds checks for media arrays and Splatfest results
Guard against accessing undefined media arrays in FileWriter, ImageWriter, and protect against findIndex returning -1 in SplatfestResultsBox. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
abb6eff676
commit
c1a290e7bc
|
|
@ -11,18 +11,20 @@ export default class FileWriter extends Client {
|
||||||
async send(status, generator) {
|
async send(status, generator) {
|
||||||
await mkdirp(this.dir);
|
await mkdirp(this.dir);
|
||||||
|
|
||||||
let imgFilename = `${this.dir}/${generator.key}.png`;
|
if (status.media?.length > 0) {
|
||||||
await fs.writeFile(imgFilename, status.media[0].file);
|
let imgFilename = `${this.dir}/${generator.key}.png`;
|
||||||
|
await fs.writeFile(imgFilename, status.media[0].file);
|
||||||
|
|
||||||
let text = [
|
let text = [
|
||||||
'Status:',
|
'Status:',
|
||||||
status.status,
|
status.status,
|
||||||
'',
|
'',
|
||||||
'Alt text:',
|
'Alt text:',
|
||||||
status.media[0].altText,
|
status.media[0].altText,
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
|
||||||
let textFilename = `${this.dir}/${generator.key}.txt`;
|
let textFilename = `${this.dir}/${generator.key}.txt`;
|
||||||
await fs.writeFile(textFilename, text);
|
await fs.writeFile(textFilename, text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ export default class ImageWriter extends Client {
|
||||||
dir = 'dist/status-screenshots'; // `/screenshots` points to the page used by puppeteer
|
dir = 'dist/status-screenshots'; // `/screenshots` points to the page used by puppeteer
|
||||||
|
|
||||||
async send(status, generator) {
|
async send(status, generator) {
|
||||||
|
if (!status.media?.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await mkdirp(this.dir);
|
await mkdirp(this.dir);
|
||||||
|
|
||||||
let imgFilename = `${this.dir}/${generator.key}.png`;
|
let imgFilename = `${this.dir}/${generator.key}.png`;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<ProductContainer class="pt-10 pb-4" bg="bg-camo-purple" :bg-style="`background-color: ${toRgba(winner.color)};`">
|
<ProductContainer v-if="winner" class="pt-10 pb-4" bg="bg-camo-purple" :bg-style="`background-color: ${toRgba(winner.color)};`">
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<div class="font-splatoon1 text-2xl lg:text-3xl text-shadow mx-2">
|
<div class="font-splatoon1 text-2xl lg:text-3xl text-shadow mx-2">
|
||||||
{{ $t('festival.results.title') }}
|
{{ $t('festival.results.title') }}
|
||||||
|
|
@ -89,7 +89,7 @@ const resultRows = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const winnerIndex = computed(() => props.festival.teams.findIndex(t => t.result.isWinner));
|
const winnerIndex = computed(() => props.festival.teams.findIndex(t => t.result.isWinner));
|
||||||
const winner = computed(() => props.festival.teams[winnerIndex.value]);
|
const winner = computed(() => winnerIndex.value >= 0 ? props.festival.teams[winnerIndex.value] : null);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user