Skip to content

Commit

Permalink
fix crash on scaling original
Browse files Browse the repository at this point in the history
  • Loading branch information
7nik committed Nov 14, 2023
1 parent ae98d32 commit 748cc56
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ap-vk-poster",
"version": "2.6.1",
"version": "2.6.2",
"private": true,
"scripts": {
"build": "rollup -c --environment PROD",
Expand Down
20 changes: 9 additions & 11 deletions src/PostMaker.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@
return file;
});
// create and keep updated a preview object for the post
$: if (pubtimeDate) {
previews = previews.sort((a, b) => b.date - a.date);
}
const Vk = new VkApi(SETTINGS.APP_ID, ["photos", "wall"]);
// upload photo
Expand Down Expand Up @@ -111,6 +106,12 @@
}
posts.sort((a, b) => b.date - a.date);
const scheduler = SETTINGS.scheduleMethod === "step"
? proposeDateByStep
: proposeDateBySchedule;
pubtimeStr = scheduler(posts[0]?.date*1000).toISOString().slice(0, -1);
await picture;
// generate previews of scheduled posts including the current one
previews = posts.map(post => {
if (!post.attachments) return null;
Expand All @@ -127,17 +128,14 @@
}
return null;
}).filter((p): p is PostPreview => p !== null);
await picture;
previews.unshift({
preview: previewUrl,
link: "",
date: pubtimeDate?.getTime() ?? 0,
});
const scheduler = SETTINGS.scheduleMethod === "step"
? proposeDateByStep
: proposeDateBySchedule;
pubtimeStr = scheduler(posts[0]?.date*1000).toISOString().slice(0, -1);
if (pubtimeDate) {
previews = previews.sort((a, b) => b.date - a.date);
}
})();
async function makePost() {
Expand Down
3 changes: 2 additions & 1 deletion src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ async function getPostInfo () {
},
relation: { removetime: string|null },
}>,
file_url: string,
} = await fetch(`/api/v3/posts/${postId}`).then((resp) => resp.json());

const artists = Array.from(document.querySelectorAll(".tags li.orange a"))
.map((a) => a.textContent ?? "")
.filter((s) => s !== "tagme (artist)");
const previewUrl = SETTINGS.imgSize === "orig"
? `https://anime-pictures.net/pictures/get_image/${postId}-original.png`
? `https://anime-pictures.net/pictures/get_image/${post.file_url}`
: post.post[`${SETTINGS.imgSize}_preview`];
const message = makeMessage(artists, `anime-pictures.net/posts/${postId}?lang=ru`);

Expand Down

0 comments on commit 748cc56

Please sign in to comment.