/* * Vencord, a modification for Discord's desktop app * Copyright (c) 2023 Vendicated and contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import ErrorBoundary from "@components/ErrorBoundary"; import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; import { useForceUpdater } from "@utils/react"; import { Paginator, Text, useRef, useState } from "@webpack/common"; import { Response, REVIEWS_PER_PAGE } from "../reviewDbApi"; import { settings } from "../settings"; import { cl } from "../utils"; import ReviewComponent from "./ReviewComponent"; import ReviewsView, { ReviewsInputComponent } from "./ReviewsView"; function Modal({ modalProps, discordId, name }: { modalProps: any; discordId: string; name: string; }) { const [data, setData] = useState(); const [signal, refetch] = useForceUpdater(true); const [page, setPage] = useState(1); const ref = useRef(null); const reviewCount = data?.reviewCount; const ownReview = data?.reviews.find(r => r.sender.discordID === settings.store.user?.discordID); return ( {name}'s Reviews {!!reviewCount && ({reviewCount} Reviews)}
ref.current?.scrollTo({ top: 0, behavior: "smooth" })} hideOwnReview />
{ownReview && ( )} {!!reviewCount && ( )}
); } export function openReviewsModal(discordId: string, name: string) { openModal(props => ( )); }