From c51d7b8fb4ea38f0ada2fe210f21263d2f2dd711 Mon Sep 17 00:00:00 2001 From: June Park Date: Mon, 2 Sep 2024 17:09:45 +0900 Subject: [PATCH 01/24] ReviewDB: Fix wording in server reviews (#2826) --- src/plugins/reviewDB/components/ReviewModal.tsx | 7 +++++-- src/plugins/reviewDB/components/ReviewsView.tsx | 9 ++++++--- src/plugins/reviewDB/index.tsx | 8 ++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/plugins/reviewDB/components/ReviewModal.tsx b/src/plugins/reviewDB/components/ReviewModal.tsx index e12a98acd..71ac021f0 100644 --- a/src/plugins/reviewDB/components/ReviewModal.tsx +++ b/src/plugins/reviewDB/components/ReviewModal.tsx @@ -22,12 +22,13 @@ import { useForceUpdater } from "@utils/react"; import { Paginator, Text, useRef, useState } from "@webpack/common"; import { Auth } from "../auth"; +import { ReviewType } from "../entities"; import { Response, REVIEWS_PER_PAGE } from "../reviewDbApi"; import { cl } from "../utils"; import ReviewComponent from "./ReviewComponent"; import ReviewsView, { ReviewsInputComponent } from "./ReviewsView"; -function Modal({ modalProps, modalKey, discordId, name }: { modalProps: any; modalKey: string, discordId: string; name: string; }) { +function Modal({ modalProps, modalKey, discordId, name, type }: { modalProps: any; modalKey: string, discordId: string; name: string; type: ReviewType; }) { const [data, setData] = useState(); const [signal, refetch] = useForceUpdater(true); const [page, setPage] = useState(1); @@ -58,6 +59,7 @@ function Modal({ modalProps, modalKey, discordId, name }: { modalProps: any; mod onFetchReviews={setData} scrollToTop={() => ref.current?.scrollTo({ top: 0, behavior: "smooth" })} hideOwnReview + type={type} /> @@ -95,7 +97,7 @@ function Modal({ modalProps, modalKey, discordId, name }: { modalProps: any; mod ); } -export function openReviewsModal(discordId: string, name: string) { +export function openReviewsModal(discordId: string, name: string, type: ReviewType) { const modalKey = "vc-rdb-modal-" + Date.now(); openModal(props => ( @@ -104,6 +106,7 @@ export function openReviewsModal(discordId: string, name: string) { modalProps={props} discordId={discordId} name={name} + type={type} /> ), { modalKey }); } diff --git a/src/plugins/reviewDB/components/ReviewsView.tsx b/src/plugins/reviewDB/components/ReviewsView.tsx index 76a0be475..7a7d8d020 100644 --- a/src/plugins/reviewDB/components/ReviewsView.tsx +++ b/src/plugins/reviewDB/components/ReviewsView.tsx @@ -21,7 +21,7 @@ import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpa import { Forms, React, RelationshipStore, useRef, UserStore } from "@webpack/common"; import { Auth, authorize } from "../auth"; -import { Review } from "../entities"; +import { Review, ReviewType } from "../entities"; import { addReview, getReviews, Response, REVIEWS_PER_PAGE } from "../reviewDbApi"; import { settings } from "../settings"; import { cl, showToast } from "../utils"; @@ -45,6 +45,7 @@ interface Props extends UserProps { page?: number; scrollToTop?(): void; hideOwnReview?: boolean; + type: ReviewType; } export default function ReviewsView({ @@ -56,6 +57,7 @@ export default function ReviewsView({ page = 1, showInput = false, hideOwnReview = false, + type, }: Props) { const [signal, refetch] = useForceUpdater(true); @@ -80,6 +82,7 @@ export default function ReviewsView({ reviews={reviewData!.reviews} hideOwnReview={hideOwnReview} profileId={discordId} + type={type} /> {showInput && ( @@ -94,7 +97,7 @@ export default function ReviewsView({ ); } -function ReviewList({ refetch, reviews, hideOwnReview, profileId }: { refetch(): void; reviews: Review[]; hideOwnReview: boolean; profileId: string; }) { +function ReviewList({ refetch, reviews, hideOwnReview, profileId, type }: { refetch(): void; reviews: Review[]; hideOwnReview: boolean; profileId: string; type: ReviewType; }) { const myId = UserStore.getCurrentUser().id; return ( @@ -111,7 +114,7 @@ function ReviewList({ refetch, reviews, hideOwnReview, profileId }: { refetch(): {reviews?.length === 0 && ( - Looks like nobody reviewed this user yet. You could be the first! + Looks like nobody reviewed this {type === ReviewType.User ? "user" : "server"} yet. You could be the first! )} diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index caf9bacba..1164a2c5b 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -30,7 +30,7 @@ import { Guild, User } from "discord-types/general"; import { Auth, initAuth, updateAuth } from "./auth"; import { openReviewsModal } from "./components/ReviewModal"; -import { NotificationType } from "./entities"; +import { NotificationType, ReviewType } from "./entities"; import { getCurrentUserInfo, readNotification } from "./reviewDbApi"; import { settings } from "./settings"; import { showToast } from "./utils"; @@ -44,7 +44,7 @@ const guildPopoutPatch: NavContextMenuPatchCallback = (children, { guild }: { gu label="View Reviews" id="vc-rdb-server-reviews" icon={OpenExternalIcon} - action={() => openReviewsModal(guild.id, guild.name)} + action={() => openReviewsModal(guild.id, guild.name, ReviewType.Server)} /> ); }; @@ -56,7 +56,7 @@ const userContextPatch: NavContextMenuPatchCallback = (children, { user }: { use label="View Reviews" id="vc-rdb-user-reviews" icon={OpenExternalIcon} - action={() => openReviewsModal(user.id, user.username)} + action={() => openReviewsModal(user.id, user.username, ReviewType.User)} /> ); }; @@ -157,7 +157,7 @@ export default definePlugin({ return (