From 4f402d43a47966d191c186bf46f7e1a8a9099963 Mon Sep 17 00:00:00 2001 From: notfire Date: Sun, 7 Sep 2025 19:17:17 -0400 Subject: [PATCH] hopefully fix 429s and the setDeleted error --- src/components/still-image/still-image.js | 25 +++++++++++++++-------- src/modules/statuses.js | 6 ++++-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/components/still-image/still-image.js b/src/components/still-image/still-image.js index a4c24df7..2765178a 100644 --- a/src/components/still-image/still-image.js +++ b/src/components/still-image/still-image.js @@ -58,6 +58,13 @@ const StillImage = { } }, detectAnimationWithFetch (image) { + if (!this.$store.fetchedimgs) + this.$store.fetchedimgs = [] + else + if (this.$store.fetchedimgs.indexOf(image.src) === -1) + this.$store.fetchedimgs.push(image.src) + else + return // Browser Cache should ensure image doesn't get loaded twice if cache exists fetch(image.src, { referrerPolicy: 'same-origin' @@ -110,7 +117,7 @@ const StillImage = { // this.setLabel('PNG') // return // } - + // Hail mary for extensionless if (extension.includes('/')) { // Don't mind the CORS error barrage @@ -170,14 +177,14 @@ const StillImage = { drawThumbnail() { const canvas = this.$refs.canvas; if (!canvas) return; - + const context = canvas.getContext('2d'); const image = this.$refs.src; const parentElement = canvas.parentElement; - + // Draw the quick, unscaled version first context.drawImage(image, 0, 0, parentElement.clientWidth, parentElement.clientHeight); - + // Use requestAnimationFrame to schedule the scaling to the next frame requestAnimationFrame(() => { // Compute scaling ratio between the natural dimensions of the image and its display dimensions @@ -191,13 +198,13 @@ const StillImage = { canvas.style.width = `${parentElement.clientWidth}px`; canvas.style.height = `${parentElement.clientHeight}px`; context.scale(ratio, ratio); - + // Maintain the aspect ratio of the image const imgAspectRatio = image.naturalWidth / image.naturalHeight; const canvasAspectRatio = parentElement.clientWidth / parentElement.clientHeight; - + let drawWidth, drawHeight; - + if (imgAspectRatio > canvasAspectRatio) { drawWidth = parentElement.clientWidth; drawHeight = parentElement.clientWidth / imgAspectRatio; @@ -205,7 +212,7 @@ const StillImage = { drawHeight = parentElement.clientHeight; drawWidth = parentElement.clientHeight * imgAspectRatio; } - + context.clearRect(0, 0, canvas.width, canvas.height); // Clear the previous unscaled image context.imageSmoothingEnabled = true; context.imageSmoothingQuality = 'high'; @@ -215,7 +222,7 @@ const StillImage = { const dy = (parentElement.clientHeight - drawHeight) / 2; context.drawImage(image, dx, dy, drawWidth, drawHeight); }); - } + } }, updated () { // On computed animated change diff --git a/src/modules/statuses.js b/src/modules/statuses.js index bb1eac2f..2d017a93 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -467,8 +467,10 @@ export const mutations = { newStatus.bookmarked = status.bookmarked }, setDeleted (state, { status }) { - const newStatus = state.allStatusesObject[status.id] - if (newStatus) newStatus.deleted = true + if (status) { + const newStatus = state.allStatusesObject[status.id] + if (newStatus) newStatus.deleted = true + } }, setManyDeleted (state, condition) { Object.values(state.allStatusesObject).forEach(status => {