From 4584300d4a8e494231fa66e7c3bd3a0e0efed20d Mon Sep 17 00:00:00 2001 From: Volpeon Date: Tue, 19 Oct 2021 09:05:52 +0200 Subject: Fix dedupe --- src/api/e621/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/api') diff --git a/src/api/e621/index.ts b/src/api/e621/index.ts index 47d5dd1..32b7fc0 100644 --- a/src/api/e621/index.ts +++ b/src/api/e621/index.ts @@ -52,7 +52,7 @@ async function loadDedupeDb() { const dd = JSON.parse(d); if (dd instanceof Array) { - dedupeDb = dd.slice(0, -1 * dedupeMax); + dedupeDb = dd.slice(-1 * dedupeMax); } else { dedupeDb = []; } @@ -101,6 +101,7 @@ export async function getRandomPost(query: GetPostQuery) { const post = response.posts[postIndex]; if (dedupeDb.includes(post.id)) { + await new Promise((resolve) => setTimeout(resolve, 1000)); return getRandomPost(query); } -- cgit v1.2.3-70-g09d2