add ReviewDB in new profiles
This commit is contained in:
parent
6d4c9339dc
commit
e0d99e2f6c
4 changed files with 63 additions and 6 deletions
|
@ -308,3 +308,24 @@ export function SafetyIcon(props: IconProps) {
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function NotesIcon(props: IconProps) {
|
||||||
|
return (
|
||||||
|
<Icon
|
||||||
|
{...props}
|
||||||
|
className={classes(props.className, "vc-notes-icon")}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill="currentColor"
|
||||||
|
d="M8 3C7.44771 3 7 3.44772 7 4V5C7 5.55228 7.44772 6 8 6H16C16.5523 6 17 5.55228 17 5V4C17 3.44772 16.5523 3 16 3H15.1245C14.7288 3 14.3535 2.82424 14.1002 2.52025L13.3668 1.64018C13.0288 1.23454 12.528 1 12 1C11.472 1 10.9712 1.23454 10.6332 1.64018L9.8998 2.52025C9.64647 2.82424 9.27121 3 8.8755 3H8Z"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
fillRule="evenodd"
|
||||||
|
clipRule="evenodd"
|
||||||
|
fill="currentColor"
|
||||||
|
d="M19 4.49996V4.99996C19 6.65681 17.6569 7.99996 16 7.99996H8C6.34315 7.99996 5 6.65681 5 4.99996V4.49996C5 4.22382 4.77446 3.99559 4.50209 4.04109C3.08221 4.27826 2 5.51273 2 6.99996V19C2 20.6568 3.34315 22 5 22H19C20.6569 22 22 20.6568 22 19V6.99996C22 5.51273 20.9178 4.27826 19.4979 4.04109C19.2255 3.99559 19 4.22382 19 4.49996ZM8 12C7.44772 12 7 12.4477 7 13C7 13.5522 7.44772 14 8 14H16C16.5523 14 17 13.5522 17 13C17 12.4477 16.5523 12 16 12H8ZM7 17C7 16.4477 7.44772 16 8 16H13C13.5523 16 14 16.4477 14 17C14 17.5522 13.5523 18 13 18H8C7.44772 18 7 17.5522 7 17Z"
|
||||||
|
/>
|
||||||
|
</Icon>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ 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, 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<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);
|
||||||
|
@ -76,6 +76,7 @@ function Modal({ modalProps, discordId, name }: { modalProps: any; discordId: st
|
||||||
discordId={discordId}
|
discordId={discordId}
|
||||||
name={name}
|
name={name}
|
||||||
refetch={refetch}
|
refetch={refetch}
|
||||||
|
modalKey={modalKey}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{!!reviewCount && (
|
{!!reviewCount && (
|
||||||
|
@ -95,11 +96,14 @@ function Modal({ modalProps, discordId, name }: { modalProps: any; discordId: st
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openReviewsModal(discordId: string, name: string) {
|
export function openReviewsModal(discordId: string, name: string) {
|
||||||
|
const modalKey = "vc-rdb-modal-" + Date.now();
|
||||||
|
|
||||||
openModal(props => (
|
openModal(props => (
|
||||||
<Modal
|
<Modal
|
||||||
|
modalKey={modalKey}
|
||||||
modalProps={props}
|
modalProps={props}
|
||||||
discordId={discordId}
|
discordId={discordId}
|
||||||
name={name}
|
name={name}
|
||||||
/>
|
/>
|
||||||
));
|
), { modalKey });
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 { token } = Auth;
|
||||||
const editorRef = useRef<any>(null);
|
const editorRef = useRef<any>(null);
|
||||||
const inputType = ChatInputTypes.FORM;
|
const inputType = ChatInputTypes.FORM;
|
||||||
|
@ -148,6 +150,7 @@ export function ReviewsInputComponent({ discordId, isAuthor, refetch, name }: {
|
||||||
type={inputType}
|
type={inputType}
|
||||||
disableThemedBackground={true}
|
disableThemedBackground={true}
|
||||||
setEditorRef={ref => editorRef.current = ref}
|
setEditorRef={ref => editorRef.current = ref}
|
||||||
|
parentModalKey={modalKey}
|
||||||
textValue=""
|
textValue=""
|
||||||
onSubmit={
|
onSubmit={
|
||||||
async res => {
|
async res => {
|
||||||
|
|
|
@ -21,10 +21,12 @@ import "./style.css";
|
||||||
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { ExpandableHeader } from "@components/ExpandableHeader";
|
import { ExpandableHeader } from "@components/ExpandableHeader";
|
||||||
import { OpenExternalIcon } from "@components/Icons";
|
import { NotesIcon, OpenExternalIcon } from "@components/Icons";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
import { classes } from "@utils/misc";
|
||||||
import definePlugin from "@utils/types";
|
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 { Guild, User } from "discord-types/general";
|
||||||
|
|
||||||
import { Auth, initAuth, updateAuth } from "./auth";
|
import { Auth, initAuth, updateAuth } from "./auth";
|
||||||
|
@ -35,6 +37,9 @@ import { getCurrentUserInfo, readNotification } from "./reviewDbApi";
|
||||||
import { settings } from "./settings";
|
import { settings } from "./settings";
|
||||||
import { showToast } from "./utils";
|
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; }) => {
|
const guildPopoutPatch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild, onClose(): void; }) => {
|
||||||
if (!guild) return;
|
if (!guild) return;
|
||||||
children.push(
|
children.push(
|
||||||
|
@ -80,6 +85,13 @@ export default definePlugin({
|
||||||
match: /user:(\i),setNote:\i,canDM.+?\}\)/,
|
match: /user:(\i),setNote:\i,canDM.+?\}\)/,
|
||||||
replace: "$&,$self.getReviewsComponent($1)"
|
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({
|
||||||
/>
|
/>
|
||||||
</ExpandableHeader>
|
</ExpandableHeader>
|
||||||
);
|
);
|
||||||
}, { message: "Failed to render Reviews" })
|
}, { message: "Failed to render Reviews" }),
|
||||||
|
|
||||||
|
BiteSizeReviewsButton: ErrorBoundary.wrap(({ user }: { user: User; }) => {
|
||||||
|
return (
|
||||||
|
<TooltipContainer text="View Reviews">
|
||||||
|
<Button
|
||||||
|
onClick={() => openReviewsModal(user.id, user.username)}
|
||||||
|
look={Button.Looks.FILLED}
|
||||||
|
size={Button.Sizes.NONE}
|
||||||
|
color={RoleButtonClasses.color}
|
||||||
|
className={classes(RoleButtonClasses.button, RoleButtonClasses.banner)}
|
||||||
|
innerClassName={classes(RoleButtonClasses.buttonInner, RoleButtonClasses.banner)}
|
||||||
|
>
|
||||||
|
<NotesIcon height={16} width={16} />
|
||||||
|
</Button>
|
||||||
|
</TooltipContainer>
|
||||||
|
);
|
||||||
|
}, { noop: true })
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue