2
0
Fork 0

hopefully fix 429s and the setDeleted error

This commit is contained in:
notfire 2025-09-07 19:17:17 -04:00
commit 4f402d43a4
No known key found for this signature in database
2 changed files with 20 additions and 11 deletions

View file

@ -58,6 +58,13 @@ const StillImage = {
} }
}, },
detectAnimationWithFetch (image) { 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 // Browser Cache should ensure image doesn't get loaded twice if cache exists
fetch(image.src, { fetch(image.src, {
referrerPolicy: 'same-origin' referrerPolicy: 'same-origin'
@ -110,7 +117,7 @@ const StillImage = {
// this.setLabel('PNG') // this.setLabel('PNG')
// return // return
// } // }
// Hail mary for extensionless // Hail mary for extensionless
if (extension.includes('/')) { if (extension.includes('/')) {
// Don't mind the CORS error barrage // Don't mind the CORS error barrage
@ -170,14 +177,14 @@ const StillImage = {
drawThumbnail() { drawThumbnail() {
const canvas = this.$refs.canvas; const canvas = this.$refs.canvas;
if (!canvas) return; if (!canvas) return;
const context = canvas.getContext('2d'); const context = canvas.getContext('2d');
const image = this.$refs.src; const image = this.$refs.src;
const parentElement = canvas.parentElement; const parentElement = canvas.parentElement;
// Draw the quick, unscaled version first // Draw the quick, unscaled version first
context.drawImage(image, 0, 0, parentElement.clientWidth, parentElement.clientHeight); context.drawImage(image, 0, 0, parentElement.clientWidth, parentElement.clientHeight);
// Use requestAnimationFrame to schedule the scaling to the next frame // Use requestAnimationFrame to schedule the scaling to the next frame
requestAnimationFrame(() => { requestAnimationFrame(() => {
// Compute scaling ratio between the natural dimensions of the image and its display dimensions // 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.width = `${parentElement.clientWidth}px`;
canvas.style.height = `${parentElement.clientHeight}px`; canvas.style.height = `${parentElement.clientHeight}px`;
context.scale(ratio, ratio); context.scale(ratio, ratio);
// Maintain the aspect ratio of the image // Maintain the aspect ratio of the image
const imgAspectRatio = image.naturalWidth / image.naturalHeight; const imgAspectRatio = image.naturalWidth / image.naturalHeight;
const canvasAspectRatio = parentElement.clientWidth / parentElement.clientHeight; const canvasAspectRatio = parentElement.clientWidth / parentElement.clientHeight;
let drawWidth, drawHeight; let drawWidth, drawHeight;
if (imgAspectRatio > canvasAspectRatio) { if (imgAspectRatio > canvasAspectRatio) {
drawWidth = parentElement.clientWidth; drawWidth = parentElement.clientWidth;
drawHeight = parentElement.clientWidth / imgAspectRatio; drawHeight = parentElement.clientWidth / imgAspectRatio;
@ -205,7 +212,7 @@ const StillImage = {
drawHeight = parentElement.clientHeight; drawHeight = parentElement.clientHeight;
drawWidth = parentElement.clientHeight * imgAspectRatio; drawWidth = parentElement.clientHeight * imgAspectRatio;
} }
context.clearRect(0, 0, canvas.width, canvas.height); // Clear the previous unscaled image context.clearRect(0, 0, canvas.width, canvas.height); // Clear the previous unscaled image
context.imageSmoothingEnabled = true; context.imageSmoothingEnabled = true;
context.imageSmoothingQuality = 'high'; context.imageSmoothingQuality = 'high';
@ -215,7 +222,7 @@ const StillImage = {
const dy = (parentElement.clientHeight - drawHeight) / 2; const dy = (parentElement.clientHeight - drawHeight) / 2;
context.drawImage(image, dx, dy, drawWidth, drawHeight); context.drawImage(image, dx, dy, drawWidth, drawHeight);
}); });
} }
}, },
updated () { updated () {
// On computed animated change // On computed animated change

View file

@ -467,8 +467,10 @@ export const mutations = {
newStatus.bookmarked = status.bookmarked newStatus.bookmarked = status.bookmarked
}, },
setDeleted (state, { status }) { setDeleted (state, { status }) {
const newStatus = state.allStatusesObject[status.id] if (status) {
if (newStatus) newStatus.deleted = true const newStatus = state.allStatusesObject[status.id]
if (newStatus) newStatus.deleted = true
}
}, },
setManyDeleted (state, condition) { setManyDeleted (state, condition) {
Object.values(state.allStatusesObject).forEach(status => { Object.values(state.allStatusesObject).forEach(status => {