aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc
diff options
context:
space:
mode:
authorkamtschatka <simon.schatka@gmx.at>2024-07-21 23:08:06 +0200
committerGitHub <noreply@github.com>2024-07-21 22:08:06 +0100
commitc5c62de28944077004f01960ee9f7e12b7d26c2c (patch)
treea31c88ff70938c4afe062afbdb078ea3cb83df9a /packages/trpc
parent4c23ea931dc01e0d99869eb518c85f891d006baa (diff)
downloadkarakeep-c5c62de28944077004f01960ee9f7e12b7d26c2c.tar.zst
fix: async/await issues with the new queue (#319)
Diffstat (limited to 'packages/trpc')
-rw-r--r--packages/trpc/routers/bookmarks.ts10
-rw-r--r--packages/trpc/routers/tags.ts14
2 files changed, 13 insertions, 11 deletions
diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts
index 43bb4db7..d2aa36bb 100644
--- a/packages/trpc/routers/bookmarks.ts
+++ b/packages/trpc/routers/bookmarks.ts
@@ -323,7 +323,7 @@ export const bookmarksAppRouter = router({
break;
}
}
- triggerSearchReindex(bookmark.id);
+ await triggerSearchReindex(bookmark.id);
return bookmark;
}),
@@ -353,7 +353,7 @@ export const bookmarksAppRouter = router({
message: "Bookmark not found",
});
}
- triggerSearchReindex(input.bookmarkId);
+ await triggerSearchReindex(input.bookmarkId);
return res[0];
}),
@@ -379,7 +379,7 @@ export const bookmarksAppRouter = router({
message: "Bookmark not found",
});
}
- triggerSearchReindex(input.bookmarkId);
+ await triggerSearchReindex(input.bookmarkId);
}),
deleteBookmark: authedProcedure
@@ -405,7 +405,7 @@ export const bookmarksAppRouter = router({
eq(bookmarks.id, input.bookmarkId),
),
);
- triggerSearchDeletion(input.bookmarkId);
+ await triggerSearchDeletion(input.bookmarkId);
if (deleted.changes > 0 && bookmark) {
await cleanupAssetForBookmark({
asset: bookmark.asset,
@@ -747,7 +747,7 @@ export const bookmarksAppRouter = router({
})),
)
.onConflictDoNothing();
- triggerSearchReindex(input.bookmarkId);
+ await triggerSearchReindex(input.bookmarkId);
return {
bookmarkId: input.bookmarkId,
attached: allIds,
diff --git a/packages/trpc/routers/tags.ts b/packages/trpc/routers/tags.ts
index 7cb2c971..e76a09ec 100644
--- a/packages/trpc/routers/tags.ts
+++ b/packages/trpc/routers/tags.ts
@@ -115,8 +115,10 @@ export const tagsAppRouter = router({
if (res.changes == 0) {
throw new TRPCError({ code: "NOT_FOUND" });
}
- affectedBookmarks.forEach(({ bookmarkId }) =>
- triggerSearchReindex(bookmarkId),
+ await Promise.all(
+ affectedBookmarks.map(({ bookmarkId }) =>
+ triggerSearchReindex(bookmarkId),
+ ),
);
}),
deleteUnused: authedProcedure
@@ -185,11 +187,11 @@ export const tagsAppRouter = router({
},
},
);
- await Promise.all([
+ await Promise.all(
affectedBookmarks
.map((b) => b.bookmarkId)
.map((id) => triggerSearchReindex(id)),
- ]);
+ );
} catch (e) {
// Best Effort attempt to reindex affected bookmarks
console.error("Failed to reindex affected bookmarks", e);
@@ -304,9 +306,9 @@ export const tagsAppRouter = router({
);
try {
- await Promise.all([
+ await Promise.all(
affectedBookmarks.map((id) => triggerSearchReindex(id)),
- ]);
+ );
} catch (e) {
// Best Effort attempt to reindex affected bookmarks
console.error("Failed to reindex affected bookmarks", e);