)
}
+ {review.id !== 0 && (
+
+ {score}
+
+ )}
{(review.comment.length > 200 && !showAll)
@@ -177,6 +217,8 @@ export default function ReviewComponent({ review, refetch, profileId }: { review
{canReportReview(review) && }
{canBlockReviewAuthor(profileId, review) && }
{canDeleteReview(profileId, review) && }
+ submitVote(true)} />
+ submitVote(false)} />
)}
diff --git a/src/plugins/reviewDB/components/ReviewsView.tsx b/src/plugins/reviewDB/components/ReviewsView.tsx
index e53e0bbd58..bd9a94826b 100644
--- a/src/plugins/reviewDB/components/ReviewsView.tsx
+++ b/src/plugins/reviewDB/components/ReviewsView.tsx
@@ -61,7 +61,7 @@ export default function ReviewsView({
}: Props) {
const [signal, refetch] = useForceUpdater(true);
- const [reviewData] = useAwaiter(() => getReviews(discordId, { offset: (page - 1) * REVIEWS_PER_PAGE }), {
+ const [reviewData] = useAwaiter(() => getReviews(discordId, { offset: (page - 1) * REVIEWS_PER_PAGE, fetchVotes: true }), {
fallbackValue: null,
deps: [refetchSignal, signal, page],
onSuccess: data => {
diff --git a/src/plugins/reviewDB/entities.ts b/src/plugins/reviewDB/entities.ts
index a871d90f2b..be50844832 100644
--- a/src/plugins/reviewDB/entities.ts
+++ b/src/plugins/reviewDB/entities.ts
@@ -93,8 +93,10 @@ export interface ReviewAuthor {
export interface Review {
comment: string,
id: number,
+ score?: number,
star: number,
sender: ReviewAuthor,
timestamp: number;
type?: ReviewType;
+ userVote?: boolean | null;
}
diff --git a/src/plugins/reviewDB/reviewDbApi.ts b/src/plugins/reviewDB/reviewDbApi.ts
index 94c3697707..39badcb2cb 100644
--- a/src/plugins/reviewDB/reviewDbApi.ts
+++ b/src/plugins/reviewDB/reviewDbApi.ts
@@ -36,6 +36,16 @@ export interface UserReviewsData {
hasOptedOut: boolean;
}
+export interface ReviewVote {
+ reviewID: number;
+ isUpvote: boolean;
+}
+
+interface ReviewVotesData {
+ message?: string;
+ votes: ReviewVote[];
+}
+
const WarningFlag = 0b00000010;
async function rdbRequest(path: string, options: RequestInit = {}) {
@@ -48,7 +58,7 @@ async function rdbRequest(path: string, options: RequestInit = {}) {
});
}
-export async function getReviews(id: string, { limit, offset = 0 }: { limit?: number; offset?: number; } = {}): Promise