diff --git a/src/components/Icons.tsx b/src/components/Icons.tsx index 4d4d27d2b..d076df75b 100644 --- a/src/components/Icons.tsx +++ b/src/components/Icons.tsx @@ -308,3 +308,24 @@ export function SafetyIcon(props: IconProps) { ); } + +export function NotesIcon(props: IconProps) { + return ( + + + + + ); +} diff --git a/src/plugins/reviewDB/components/ReviewModal.tsx b/src/plugins/reviewDB/components/ReviewModal.tsx index 9669a2b32..e12a98acd 100644 --- a/src/plugins/reviewDB/components/ReviewModal.tsx +++ b/src/plugins/reviewDB/components/ReviewModal.tsx @@ -27,7 +27,7 @@ import { cl } from "../utils"; import ReviewComponent from "./ReviewComponent"; import ReviewsView, { ReviewsInputComponent } from "./ReviewsView"; -function Modal({ modalProps, discordId, name }: { modalProps: any; discordId: string; name: string; }) { +function Modal({ modalProps, modalKey, discordId, name }: { modalProps: any; modalKey: string, discordId: string; name: string; }) { const [data, setData] = useState(); const [signal, refetch] = useForceUpdater(true); const [page, setPage] = useState(1); @@ -76,6 +76,7 @@ function Modal({ modalProps, discordId, name }: { modalProps: any; discordId: st discordId={discordId} name={name} refetch={refetch} + modalKey={modalKey} /> {!!reviewCount && ( @@ -95,11 +96,14 @@ function Modal({ modalProps, discordId, name }: { modalProps: any; discordId: st } export function openReviewsModal(discordId: string, name: string) { + const modalKey = "vc-rdb-modal-" + Date.now(); + openModal(props => ( - )); + ), { modalKey }); } diff --git a/src/plugins/reviewDB/components/ReviewsView.tsx b/src/plugins/reviewDB/components/ReviewsView.tsx index 79e5e8ccc..76a0be475 100644 --- a/src/plugins/reviewDB/components/ReviewsView.tsx +++ b/src/plugins/reviewDB/components/ReviewsView.tsx @@ -119,7 +119,9 @@ function ReviewList({ refetch, reviews, hideOwnReview, profileId }: { refetch(): } -export function ReviewsInputComponent({ discordId, isAuthor, refetch, name }: { discordId: string, name: string; isAuthor: boolean; refetch(): void; }) { +export function ReviewsInputComponent( + { discordId, isAuthor, refetch, name, modalKey }: { discordId: string, name: string; isAuthor: boolean; refetch(): void; modalKey?: string; } +) { const { token } = Auth; const editorRef = useRef(null); const inputType = ChatInputTypes.FORM; @@ -148,6 +150,7 @@ export function ReviewsInputComponent({ discordId, isAuthor, refetch, name }: { type={inputType} disableThemedBackground={true} setEditorRef={ref => editorRef.current = ref} + parentModalKey={modalKey} textValue="" onSubmit={ async res => { diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index 9f303dfe5..800de4a1f 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -21,10 +21,12 @@ import "./style.css"; import { NavContextMenuPatchCallback } from "@api/ContextMenu"; import ErrorBoundary from "@components/ErrorBoundary"; import { ExpandableHeader } from "@components/ExpandableHeader"; -import { OpenExternalIcon } from "@components/Icons"; +import { NotesIcon, OpenExternalIcon } from "@components/Icons"; import { Devs } from "@utils/constants"; +import { classes } from "@utils/misc"; import definePlugin from "@utils/types"; -import { Alerts, Menu, Parser, useState } from "@webpack/common"; +import { findByPropsLazy } from "@webpack"; +import { Alerts, Button, Menu, Parser, TooltipContainer, useState } from "@webpack/common"; import { Guild, User } from "discord-types/general"; import { Auth, initAuth, updateAuth } from "./auth"; @@ -35,6 +37,9 @@ import { getCurrentUserInfo, readNotification } from "./reviewDbApi"; import { settings } from "./settings"; import { showToast } from "./utils"; +const PopoutClasses = findByPropsLazy("container", "scroller", "list"); +const RoleButtonClasses = findByPropsLazy("button", "buttonInner", "icon", "text"); + const guildPopoutPatch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild, onClose(): void; }) => { if (!guild) return; children.push( @@ -80,6 +85,13 @@ export default definePlugin({ match: /user:(\i),setNote:\i,canDM.+?\}\)/, replace: "$&,$self.getReviewsComponent($1)" } + }, + { + find: ".VIEW_FULL_PROFILE,", + replacement: { + match: /(?<=\.BITE_SIZE,children:\[)\(0,\i\.jsx\)\(\i\.\i,\{user:(\i),/, + replace: "$self.BiteSizeReviewsButton({user:$1}),$&" + } } ], @@ -160,5 +172,22 @@ export default definePlugin({ /> ); - }, { message: "Failed to render Reviews" }) + }, { message: "Failed to render Reviews" }), + + BiteSizeReviewsButton: ErrorBoundary.wrap(({ user }: { user: User; }) => { + return ( + + + + ); + }, { noop: true }) });