ReviewDB: Fix Limit + Change Profile Component A Little

This commit is contained in:
thororen1234 2026-03-18 18:09:54 -04:00
parent a62ea7da82
commit aaf311feb2
No known key found for this signature in database
2 changed files with 20 additions and 16 deletions

View file

@ -157,7 +157,7 @@ export default definePlugin({
},
renderProfileComponent: ErrorBoundary.wrap(({ user, isSideBar = false }: { user: User; isSideBar?: boolean; }) => {
const [reviewData] = useAwaiter(() => getReviews(user.id), { deps: [user.id], fallbackValue: null });
const [reviewData] = useAwaiter(() => getReviews(user.id, 0, true), { deps: [user.id], fallbackValue: null });
// Discord are masters at using a crap ton of html elements and css classes to create a simple ui that could have
// been made with less than half of the number of elements, so we have to do this insanity to replicate their ui
@ -170,20 +170,24 @@ export default definePlugin({
<Paragraph size={isSideBar ? "sm" : "xs"} weight="medium">User Reviews</Paragraph>
{!!reviewData?.reviewCount && (
<div className={ProfileCardContainerClasses.icons}>
{reviewData.reviews.slice(0, 4).map((review, idx) => {
const showCount = idx === 3 && reviewData.reviewCount > 4;
{reviewData.reviews
.filter(review => review.id !== 0)
.slice(0, 4)
.reverse()
.map((review, idx) => {
const showCount = idx === 3 && reviewData.reviewCount > 4;
return (
<div className={ProfileCardContainerClasses.icon} key={review.id}>
<img src={review.sender.profilePhoto} alt={review.sender.username} className={showCount ? ProfileCardContainerClasses.displayCount : undefined} />
{showCount && (
<div className={ProfileCardContainerClasses.displayCountText}>
<Span className={ProfileCardContainerClasses.displayCountTextColor} size="xs" weight="medium">+{reviewData.reviewCount - 3}</Span>
</div>
)}
</div>
);
})}
return (
<div className={ProfileCardContainerClasses.icon} key={review.id}>
<img src={review.sender.profilePhoto} alt={review.sender.username} className={showCount ? ProfileCardContainerClasses.displayCount : undefined} />
{showCount && (
<div className={ProfileCardContainerClasses.displayCountText}>
<Span className={ProfileCardContainerClasses.displayCountTextColor} size="xs" weight="medium">+{reviewData.reviewCount - 3}</Span>
</div>
)}
</div>
);
})}
</div>
)}
</div>

View file

@ -47,14 +47,14 @@ async function rdbRequest(path: string, options: RequestInit = {}) {
});
}
export async function getReviews(id: string, offset = 0): Promise<UserReviewsData> {
export async function getReviews(id: string, offset = 0, isProfileComponent = false): Promise<UserReviewsData> {
let flags = 0;
if (!settings.store.showWarning) flags |= WarningFlag;
const params = new URLSearchParams({
flags: String(flags),
offset: String(offset),
limit: "4"
...(isProfileComponent ? { limit: "4" } : {})
});
const req = await fetch(`${API_URL}/users/${id}/reviews?${params}`);