ReviewDB: Fix wording in server reviews (#2826)

This commit is contained in:
June Park 2024-09-02 17:09:45 +09:00 committed by GitHub
parent accfc15125
commit c51d7b8fb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 9 deletions

View file

@ -22,12 +22,13 @@ import { useForceUpdater } from "@utils/react";
import { Paginator, Text, useRef, useState } from "@webpack/common"; import { Paginator, Text, useRef, useState } from "@webpack/common";
import { Auth } from "../auth"; import { Auth } from "../auth";
import { ReviewType } from "../entities";
import { Response, REVIEWS_PER_PAGE } from "../reviewDbApi"; import { Response, REVIEWS_PER_PAGE } from "../reviewDbApi";
import { cl } from "../utils"; import { cl } from "../utils";
import ReviewComponent from "./ReviewComponent"; import ReviewComponent from "./ReviewComponent";
import ReviewsView, { ReviewsInputComponent } from "./ReviewsView"; 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<Response>(); const [data, setData] = useState<Response>();
const [signal, refetch] = useForceUpdater(true); const [signal, refetch] = useForceUpdater(true);
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
@ -58,6 +59,7 @@ function Modal({ modalProps, modalKey, discordId, name }: { modalProps: any; mod
onFetchReviews={setData} onFetchReviews={setData}
scrollToTop={() => ref.current?.scrollTo({ top: 0, behavior: "smooth" })} scrollToTop={() => ref.current?.scrollTo({ top: 0, behavior: "smooth" })}
hideOwnReview hideOwnReview
type={type}
/> />
</div> </div>
</ModalContent> </ModalContent>
@ -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(); const modalKey = "vc-rdb-modal-" + Date.now();
openModal(props => ( openModal(props => (
@ -104,6 +106,7 @@ export function openReviewsModal(discordId: string, name: string) {
modalProps={props} modalProps={props}
discordId={discordId} discordId={discordId}
name={name} name={name}
type={type}
/> />
), { modalKey }); ), { modalKey });
} }

View file

@ -21,7 +21,7 @@ import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpa
import { Forms, React, RelationshipStore, useRef, UserStore } from "@webpack/common"; import { Forms, React, RelationshipStore, useRef, UserStore } from "@webpack/common";
import { Auth, authorize } from "../auth"; import { Auth, authorize } from "../auth";
import { Review } from "../entities"; import { Review, ReviewType } from "../entities";
import { addReview, getReviews, Response, REVIEWS_PER_PAGE } from "../reviewDbApi"; import { addReview, getReviews, Response, REVIEWS_PER_PAGE } from "../reviewDbApi";
import { settings } from "../settings"; import { settings } from "../settings";
import { cl, showToast } from "../utils"; import { cl, showToast } from "../utils";
@ -45,6 +45,7 @@ interface Props extends UserProps {
page?: number; page?: number;
scrollToTop?(): void; scrollToTop?(): void;
hideOwnReview?: boolean; hideOwnReview?: boolean;
type: ReviewType;
} }
export default function ReviewsView({ export default function ReviewsView({
@ -56,6 +57,7 @@ export default function ReviewsView({
page = 1, page = 1,
showInput = false, showInput = false,
hideOwnReview = false, hideOwnReview = false,
type,
}: Props) { }: Props) {
const [signal, refetch] = useForceUpdater(true); const [signal, refetch] = useForceUpdater(true);
@ -80,6 +82,7 @@ export default function ReviewsView({
reviews={reviewData!.reviews} reviews={reviewData!.reviews}
hideOwnReview={hideOwnReview} hideOwnReview={hideOwnReview}
profileId={discordId} profileId={discordId}
type={type}
/> />
{showInput && ( {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; const myId = UserStore.getCurrentUser().id;
return ( return (
@ -111,7 +114,7 @@ function ReviewList({ refetch, reviews, hideOwnReview, profileId }: { refetch():
{reviews?.length === 0 && ( {reviews?.length === 0 && (
<Forms.FormText className={cl("placeholder")}> <Forms.FormText className={cl("placeholder")}>
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!
</Forms.FormText> </Forms.FormText>
)} )}
</div> </div>

View file

@ -30,7 +30,7 @@ import { Guild, User } from "discord-types/general";
import { Auth, initAuth, updateAuth } from "./auth"; import { Auth, initAuth, updateAuth } from "./auth";
import { openReviewsModal } from "./components/ReviewModal"; import { openReviewsModal } from "./components/ReviewModal";
import { NotificationType } from "./entities"; import { NotificationType, ReviewType } from "./entities";
import { getCurrentUserInfo, readNotification } from "./reviewDbApi"; import { getCurrentUserInfo, readNotification } from "./reviewDbApi";
import { settings } from "./settings"; import { settings } from "./settings";
import { showToast } from "./utils"; import { showToast } from "./utils";
@ -44,7 +44,7 @@ const guildPopoutPatch: NavContextMenuPatchCallback = (children, { guild }: { gu
label="View Reviews" label="View Reviews"
id="vc-rdb-server-reviews" id="vc-rdb-server-reviews"
icon={OpenExternalIcon} 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" label="View Reviews"
id="vc-rdb-user-reviews" id="vc-rdb-user-reviews"
icon={OpenExternalIcon} icon={OpenExternalIcon}
action={() => openReviewsModal(user.id, user.username)} action={() => openReviewsModal(user.id, user.username, ReviewType.User)}
/> />
); );
}; };
@ -157,7 +157,7 @@ export default definePlugin({
return ( return (
<TooltipContainer text="View Reviews"> <TooltipContainer text="View Reviews">
<Button <Button
onClick={() => openReviewsModal(user.id, user.username)} onClick={() => openReviewsModal(user.id, user.username, ReviewType.User)}
look={Button.Looks.FILLED} look={Button.Looks.FILLED}
size={Button.Sizes.NONE} size={Button.Sizes.NONE}
color={RoleButtonClasses.bannerColor} color={RoleButtonClasses.bannerColor}