diff --git a/src/plugins/reviewDB/components/ReviewComponent.tsx b/src/plugins/reviewDB/components/ReviewComponent.tsx index 993fd26c3..20bd2e029 100644 --- a/src/plugins/reviewDB/components/ReviewComponent.tsx +++ b/src/plugins/reviewDB/components/ReviewComponent.tsx @@ -23,175 +23,162 @@ import { settings } from "@plugins/reviewDB/settings"; import { canBlockReviewAuthor, canDeleteReview, canReportReview, cl, showToast } from "@plugins/reviewDB/utils"; import { openUserProfile } from "@utils/discord"; import { classes } from "@utils/misc"; -import { LazyComponent } from "@utils/react"; -import { filters, findBulk } from "@webpack"; +import { findCssClassesLazy } from "@webpack"; import { Alerts, Parser, Timestamp, useState } from "@webpack/common"; import { openBlockModal } from "./BlockedUserModal"; import { BlockButton, DeleteButton, ReportButton } from "./MessageButton"; import ReviewBadge from "./ReviewBadge"; -export default LazyComponent(() => { - // this is terrible, blame mantika - const c = filters.byClassNames; - const [ - { cozyMessage, buttons, message, buttonsInner, groupStart }, - { container, isHeader }, - { avatar, clickable, username, wrapper, cozy }, - buttonClasses, - botTag - ] = findBulk( - c("cozyMessage"), - c("container", "isHeader"), - c("avatar", "zalgo"), - c("button", "wrapper", "selected"), - c("botTagRegular") - ); +const MessageClasses = findCssClassesLazy("cozyMessage", "message", "groupStart", "buttons", "buttonsInner"); +const ContainerClasses = findCssClassesLazy("container", "isHeader"); +const AvatarClasses = findCssClassesLazy("avatar", "wrapper", "cozy", "clickable", "username"); +const ButtonClasses = findCssClassesLazy("button", "wrapper", "selected"); +const BotTagClasses = findCssClassesLazy("botTagVerified", "botTagRegular", "botText", "px", "rem"); - const dateFormat = new Intl.DateTimeFormat(); +const dateFormat = new Intl.DateTimeFormat(); - return function ReviewComponent({ review, refetch, profileId }: { review: Review; refetch(): void; profileId: string; }) { - const [showAll, setShowAll] = useState(false); +export default function ReviewComponent({ review, refetch, profileId }: { review: Review; refetch(): void; profileId: string; }) { + const [showAll, setShowAll] = useState(false); - function openModal() { - openUserProfile(review.sender.discordID); - } + function openModal() { + openUserProfile(review.sender.discordID); + } - function delReview() { - Alerts.show({ - title: "Are you sure?", - body: "Do you really want to delete this review?", - confirmText: "Delete", - cancelText: "Nevermind", - onConfirm: async () => { - if (!(await getToken())) { - return showToast("You must be logged in to delete reviews."); - } else { - deleteReview(review.id).then(res => { - if (res) { - refetch(); - } - }); - } + function delReview() { + Alerts.show({ + title: "Are you sure?", + body: "Do you really want to delete this review?", + confirmText: "Delete", + cancelText: "Nevermind", + onConfirm: async () => { + if (!(await getToken())) { + return showToast("You must be logged in to delete reviews."); + } else { + deleteReview(review.id).then(res => { + if (res) { + refetch(); + } + }); } - }); - } + } + }); + } - function reportRev() { - Alerts.show({ - title: "Are you sure?", - body: "Do you really you want to report this review?", - confirmText: "Report", - cancelText: "Nevermind", - // confirmColor: "red", this just adds a class name and breaks the submit button guh - onConfirm: async () => { - if (!(await getToken())) { - return showToast("You must be logged in to report reviews."); - } else { - reportReview(review.id); - } + function reportRev() { + Alerts.show({ + title: "Are you sure?", + body: "Do you really you want to report this review?", + confirmText: "Report", + cancelText: "Nevermind", + // confirmColor: "red", this just adds a class name and breaks the submit button guh + onConfirm: async () => { + if (!(await getToken())) { + return showToast("You must be logged in to report reviews."); + } else { + reportReview(review.id); } - }); - } + } + }); + } - const isAuthorBlocked = Auth?.user?.blockedUsers?.includes(review.sender.discordID) ?? false; + const isAuthorBlocked = Auth?.user?.blockedUsers?.includes(review.sender.discordID) ?? false; - function blockReviewSender() { - if (isAuthorBlocked) - return unblockUser(review.sender.discordID); + function blockReviewSender() { + if (isAuthorBlocked) + return unblockUser(review.sender.discordID); - Alerts.show({ - title: "Are you sure?", - body: "Do you really you want to block this user? They will be unable to leave further reviews on your profile. You can unblock users in the plugin settings.", - confirmText: "Block", - cancelText: "Nevermind", - // confirmColor: "red", this just adds a class name and breaks the submit button guh - onConfirm: async () => { - if (!(await getToken())) { - return showToast("You must be logged in to block users."); - } else { - blockUser(review.sender.discordID); - } + Alerts.show({ + title: "Are you sure?", + body: "Do you really you want to block this user? They will be unable to leave further reviews on your profile. You can unblock users in the plugin settings.", + confirmText: "Block", + cancelText: "Nevermind", + // confirmColor: "red", this just adds a class name and breaks the submit button guh + onConfirm: async () => { + if (!(await getToken())) { + return showToast("You must be logged in to block users."); + } else { + blockUser(review.sender.discordID); } - }); - } + } + }); + } - return ( -
+ return ( +
- -
+ +
+ openModal()} + > + {review.sender.username} + + + {review.type === ReviewType.System && ( openModal()} - > - {review.sender.username} - - - {review.type === ReviewType.System && ( - - - System - + className={classes(BotTagClasses.botTagVerified, BotTagClasses.botTagRegular, BotTagClasses.px, BotTagClasses.rem)} + style={{ marginLeft: "4px" }}> + + System - )} -
- {isAuthorBlocked && ( - openBlockModal()} - /> - )} - {review.sender.badges.map((badge, idx) => )} - - { - !settings.store.hideTimestamps && review.type !== ReviewType.System && ( - - {dateFormat.format(review.timestamp * 1000)} - ) - } - -
- {(review.comment.length > 200 && !showAll) - ? ( - <> - {Parser.parseGuildEventDescription(review.comment.substring(0, 200))}... -
- setShowAll(true)}>Read more] - - ) - : Parser.parseGuildEventDescription(review.comment)} -
- - {review.id !== 0 && ( -
-
- {canReportReview(review) && } - {canBlockReviewAuthor(profileId, review) && } - {canDeleteReview(profileId, review) && } -
-
+ )}
- ); - }; -}); + {isAuthorBlocked && ( + openBlockModal()} + /> + )} + {review.sender.badges.map((badge, idx) => )} + + { + !settings.store.hideTimestamps && review.type !== ReviewType.System && ( + + {dateFormat.format(review.timestamp * 1000)} + ) + } + +
+ {(review.comment.length > 200 && !showAll) + ? ( + <> + {Parser.parseGuildEventDescription(review.comment.substring(0, 200))}... +
+ setShowAll(true)}>Read more] + + ) + : Parser.parseGuildEventDescription(review.comment)} +
+ + {review.id !== 0 && ( +
+
+ {canReportReview(review) && } + {canBlockReviewAuthor(profileId, review) && } + {canDeleteReview(profileId, review) && } +
+
+ )} +
+ ); +} diff --git a/src/plugins/webContextMenus.web/index.ts b/src/plugins/webContextMenus.web/index.ts index 6e65c2cd4..ae5b8414f 100644 --- a/src/plugins/webContextMenus.web/index.ts +++ b/src/plugins/webContextMenus.web/index.ts @@ -153,12 +153,12 @@ export default definePlugin({ replace: "false" }, { - match: /(?<=#{intl::COPY_IMAGE_MENU_ITEM}\),)action:/, - replace: "action:()=>$self.copyImage(arguments[0]),oldAction:" + match: /(#{intl::COPY_IMAGE_MENU_ITEM}\),.{0,75}?)action:/, + replace: "$1action:()=>$self.copyImage(arguments[0]),oldAction:" }, { - match: /(?<=#{intl::SAVE_IMAGE_MENU_ITEM}\),)action:/, - replace: "action:()=>$self.saveImage(arguments[0]),oldAction:" + match: /(#{intl::SAVE_IMAGE_MENU_ITEM}\),.{0,75}?)action:/, + replace: "$1action:()=>$self.saveImage(arguments[0]),oldAction:" }, ] },