From e5c0898dd6ee4bae213aa2d727e15714739d2f91 Mon Sep 17 00:00:00 2001 From: Manti <67705577+mantikafasi@users.noreply.github.com> Date: Thu, 21 Sep 2023 18:16:15 +0300 Subject: [PATCH] [ReviewDB] add emojis, discord markdown & notifications (#1718) Co-authored-by: V --- .../reviewDB/components/ReviewBadge.tsx | 4 +- .../reviewDB/components/ReviewComponent.tsx | 16 ++- .../reviewDB/components/ReviewsView.tsx | 117 ++++++++++++------ src/plugins/reviewDB/entities.ts | 15 +++ src/plugins/reviewDB/index.tsx | 65 +++++----- src/plugins/reviewDB/reviewDbApi.ts | 9 ++ src/plugins/reviewDB/style.css | 37 +++++- 7 files changed, 170 insertions(+), 93 deletions(-) diff --git a/src/plugins/reviewDB/components/ReviewBadge.tsx b/src/plugins/reviewDB/components/ReviewBadge.tsx index e65dff247..3c02c3542 100644 --- a/src/plugins/reviewDB/components/ReviewBadge.tsx +++ b/src/plugins/reviewDB/components/ReviewBadge.tsx @@ -28,8 +28,8 @@ export default function ReviewBadge(badge: Badge) { {({ onMouseEnter, onMouseLeave }) => ( { - // this is terrible, blame mantika + // this is terrible, blame ven const p = filters.byProps; const [ { cozyMessage, buttons, message, buttonsInner, groupStart }, { container, isHeader }, - { avatar, clickable, username, messageContent, wrapper, cozy }, + { avatar, clickable, username, wrapper, cozy }, buttonClasses, botTag ] = findBulk( @@ -124,12 +124,10 @@ export default LazyComponent(() => { ) } -

- {review.comment} -

+
+ {Parser.parseGuildEventDescription(review.comment)} +
+ {review.id !== 0 && (
. */ -import { classes } from "@utils/misc"; -import { useAwaiter, useForceUpdater } from "@utils/react"; -import { findByPropsLazy } from "@webpack"; -import { Forms, React, RelationshipStore, UserStore } from "@webpack/common"; -import type { KeyboardEvent } from "react"; +import { LazyComponent, useAwaiter, useForceUpdater } from "@utils/react"; +import { find, findByPropsLazy } from "@webpack"; +import { Forms, React, RelationshipStore, useRef, UserStore } from "@webpack/common"; import { Review } from "../entities"; import { addReview, getReviews, Response, REVIEWS_PER_PAGE } from "../reviewDbApi"; @@ -28,7 +26,12 @@ import { settings } from "../settings"; import { authorize, cl, showToast } from "../utils"; import ReviewComponent from "./ReviewComponent"; -const Classes = findByPropsLazy("inputDefault", "editable"); + +const Editor = findByPropsLazy("start", "end", "addMark"); +const Transform = findByPropsLazy("unwrapNodes"); +const InputTypes = findByPropsLazy("VOICE_CHANNEL_STATUS", "SIDEBAR"); + +const InputComponent = LazyComponent(() => find(m => m?.type?.render?.toString().includes("CHANNEL_TEXT_AREA).AnalyticsLocationProvider"))); interface UserProps { discordId: string; @@ -113,48 +116,82 @@ function ReviewList({ refetch, reviews, hideOwnReview }: { refetch(): void; revi ); } + export function ReviewsInputComponent({ discordId, isAuthor, refetch, name }: { discordId: string, name: string; isAuthor: boolean; refetch(): void; }) { const { token } = settings.store; + const editorRef = useRef(null); + const inputType = InputTypes.FORM; + inputType.disableAutoFocus = true; - function onKeyPress({ key, target }: KeyboardEvent) { - if (key === "Enter") { - addReview({ - userid: discordId, - comment: (target as HTMLInputElement).value, - star: -1 - }).then(res => { - if (res?.success) { - (target as HTMLInputElement).value = ""; // clear the input - refetch(); - } else if (res?.message) { - showToast(res.message); - } - }); - } - } + const channel = { + flags_: 256, + guild_id_: null, + id: "0", + getGuildId: () => null, + isPrivate: () => true, + isActiveThread: () => false, + isArchivedLockedThread: () => false, + isDM: () => true, + roles: { "0": { permissions: 0n } }, + getRecipientId: () => "0", + hasFlag: () => false, + }; return ( -