Fix notFound

This commit is contained in:
Bingus_Violet 2024-01-27 15:41:08 -06:00
parent 16bab47844
commit bc4b82965b

View file

@ -68,8 +68,7 @@ function get_img_url(activity) {
if (activity.name in activityImages) {
return decodeURIComponent(activityImages[activity.name])
} else {
return ''
// This was supposed to be temporary but it kinda stuck honestly lol (It's an ultrakill icon)
return null
}
}
}
@ -200,6 +199,7 @@ async function pageUpdate() {
function get_img(activity) {
if (get_img_url(activity)) {
var fn = sha256(get_img_url(activity))
var fp = path.join(staticpath, 'cached', fn)
@ -208,6 +208,9 @@ async function pageUpdate() {
} else if (fs.statSync(fp).size < 1000) {
fs.rmSync(fp)
}
} else {
return 'imgs/notFound.png'
}
return '/cached/' + fn
}
@ -402,13 +405,14 @@ lanyard.addEventListener("message", (res) => {
for (let index = 0; index < lanyardData.activities.length; index++) {
const activity = lanyardData.activities[index];
if (get_img_url(activity)) {
var fn = sha256(get_img_url(activity))
var fp = path.join(__dirname, 'static/cached', fn)
if (!fs.existsSync(fp)) {
var wrst = fs.createWriteStream(fp)
if (get_img_url(activity)) {
fetch(`${get_img_url(activity)}`)
.then((response) => response.body)
.then((body) => {