diff options
author | Vendicated <vendicated@riseup.net> | 2023-10-06 18:44:22 +0200 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2023-10-06 18:44:22 +0200 |
commit | 664dd0a9920aa697359b1bb07b98795ff0f1beaf (patch) | |
tree | 9050e307cf802d4384f918598900e60db624320f | |
parent | f66e35b65875e7669e5ccdb2710d83f10f41baa3 (diff) | |
download | Vencord-664dd0a9920aa697359b1bb07b98795ff0f1beaf.tar.gz Vencord-664dd0a9920aa697359b1bb07b98795ff0f1beaf.tar.bz2 Vencord-664dd0a9920aa697359b1bb07b98795ff0f1beaf.zip |
ReviewDB: allow deleting reviews on own profile
-rw-r--r-- | src/plugins/reviewDB/components/ReviewComponent.tsx | 8 | ||||
-rw-r--r-- | src/plugins/reviewDB/components/ReviewsView.tsx | 4 | ||||
-rw-r--r-- | src/plugins/reviewDB/utils.tsx | 8 |
3 files changed, 12 insertions, 8 deletions
diff --git a/src/plugins/reviewDB/components/ReviewComponent.tsx b/src/plugins/reviewDB/components/ReviewComponent.tsx index 07bcdb2..5792400 100644 --- a/src/plugins/reviewDB/components/ReviewComponent.tsx +++ b/src/plugins/reviewDB/components/ReviewComponent.tsx @@ -20,7 +20,7 @@ import { openUserProfile } from "@utils/discord"; import { classes } from "@utils/misc"; import { LazyComponent } from "@utils/react"; import { filters, findBulk } from "@webpack"; -import { Alerts, moment, Parser, Timestamp, UserStore } from "@webpack/common"; +import { Alerts, moment, Parser, Timestamp } from "@webpack/common"; import { Review, ReviewType } from "../entities"; import { deleteReview, reportReview } from "../reviewDbApi"; @@ -30,7 +30,7 @@ import { DeleteButton, ReportButton } from "./MessageButton"; import ReviewBadge from "./ReviewBadge"; export default LazyComponent(() => { - // this is terrible, blame ven + // this is terrible, blame mantika const p = filters.byProps; const [ { cozyMessage, buttons, message, buttonsInner, groupStart }, @@ -48,7 +48,7 @@ export default LazyComponent(() => { const dateFormat = new Intl.DateTimeFormat(); - return function ReviewComponent({ review, refetch }: { review: Review; refetch(): void; }) { + return function ReviewComponent({ review, refetch, profileId }: { review: Review; refetch(): void; profileId: string; }) { function openModal() { openUserProfile(review.sender.discordID); } @@ -135,7 +135,7 @@ export default LazyComponent(() => { <div className={classes(buttonClasses.wrapper, buttonsInner)} > <ReportButton onClick={reportRev} /> - {canDeleteReview(review, UserStore.getCurrentUser().id) && ( + {canDeleteReview(profileId, review) && ( <DeleteButton onClick={delReview} /> )} </div> diff --git a/src/plugins/reviewDB/components/ReviewsView.tsx b/src/plugins/reviewDB/components/ReviewsView.tsx index e5bc426..5eb370f 100644 --- a/src/plugins/reviewDB/components/ReviewsView.tsx +++ b/src/plugins/reviewDB/components/ReviewsView.tsx @@ -79,6 +79,7 @@ export default function ReviewsView({ refetch={refetch} reviews={reviewData!.reviews} hideOwnReview={hideOwnReview} + profileId={discordId} /> {showInput && ( @@ -93,7 +94,7 @@ export default function ReviewsView({ ); } -function ReviewList({ refetch, reviews, hideOwnReview }: { refetch(): void; reviews: Review[]; hideOwnReview: boolean; }) { +function ReviewList({ refetch, reviews, hideOwnReview, profileId }: { refetch(): void; reviews: Review[]; hideOwnReview: boolean; profileId: string; }) { const myId = UserStore.getCurrentUser().id; return ( @@ -104,6 +105,7 @@ function ReviewList({ refetch, reviews, hideOwnReview }: { refetch(): void; revi key={review.id} review={review} refetch={refetch} + profileId={profileId} /> )} diff --git a/src/plugins/reviewDB/utils.tsx b/src/plugins/reviewDB/utils.tsx index a9c8ca5..63ab84d 100644 --- a/src/plugins/reviewDB/utils.tsx +++ b/src/plugins/reviewDB/utils.tsx @@ -20,7 +20,7 @@ import { classNameFactory } from "@api/Styles"; import { Logger } from "@utils/Logger"; import { openModal } from "@utils/modal"; import { findByProps } from "@webpack"; -import { React, Toasts } from "@webpack/common"; +import { React, Toasts, UserStore } from "@webpack/common"; import { Review, UserType } from "./entities"; import { settings } from "./settings"; @@ -73,9 +73,11 @@ export function showToast(text: string) { }); } -export function canDeleteReview(review: Review, userId: string) { +export function canDeleteReview(profileId: string, review: Review) { + const myId = UserStore.getCurrentUser().id; return ( - review.sender.discordID === userId + myId === profileId + || review.sender.discordID === profileId || settings.store.user?.type === UserType.Admin ); } |