mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-08 22:23:02 -04:00
Fixes For ReviewDB
This commit is contained in:
parent
d5cb4ab849
commit
355a2a8d78
2 changed files with 3 additions and 52 deletions
|
@ -20,18 +20,16 @@ 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 { NotesIcon, 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 { classes } from "@utils/misc";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { Alerts, Button, Menu, Parser, TooltipContainer, useState } from "@webpack/common";
|
import { Alerts, Button, Menu, Parser, TooltipContainer } 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";
|
||||||
import { openReviewsModal } from "./components/ReviewModal";
|
import { openReviewsModal } from "./components/ReviewModal";
|
||||||
import ReviewsView from "./components/ReviewsView";
|
|
||||||
import { NotificationType } from "./entities";
|
import { NotificationType } from "./entities";
|
||||||
import { getCurrentUserInfo, readNotification } from "./reviewDbApi";
|
import { getCurrentUserInfo, readNotification } from "./reviewDbApi";
|
||||||
import { settings } from "./settings";
|
import { settings } from "./settings";
|
||||||
|
@ -78,28 +76,12 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
|
||||||
find: "showBorder:null",
|
|
||||||
replacement: {
|
|
||||||
match: /user:(\i),setNote:\i,canDM.+?\}\)/,
|
|
||||||
replace: "$&,$self.getReviewsComponent($1)"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
find: /inline:!1,profileViewedAnalytics:\i}\),/,
|
|
||||||
replacement: {
|
|
||||||
match: /currentUser:\i,guild:\i}\)(?<=user:(\i),bio:null==\i\?.+?)/,
|
|
||||||
replace: "$&,$self.getReviewsComponent($1)"
|
|
||||||
},
|
|
||||||
predicate: () => !settings.store.preferButtonOverDropdown
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: ".BITE_SIZE,user:",
|
find: ".BITE_SIZE,user:",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /{profileType:\i\.\i\.BITE_SIZE,children:\[/,
|
match: /{profileType:\i\.\i\.BITE_SIZE,children:\[/,
|
||||||
replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user}),"
|
replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user}),"
|
||||||
},
|
}
|
||||||
predicate: () => settings.store.preferButtonOverDropdown
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: ".FULL_SIZE,user:",
|
find: ".FULL_SIZE,user:",
|
||||||
|
@ -171,31 +153,6 @@ export default definePlugin({
|
||||||
}, 4000);
|
}, 4000);
|
||||||
},
|
},
|
||||||
|
|
||||||
getReviewsComponent: ErrorBoundary.wrap((user: User) => {
|
|
||||||
const [reviewCount, setReviewCount] = useState<number>();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ExpandableHeader
|
|
||||||
headerText="User Reviews"
|
|
||||||
onMoreClick={() => openReviewsModal(user.id, user.username)}
|
|
||||||
moreTooltipText={
|
|
||||||
reviewCount && reviewCount > 50
|
|
||||||
? `View all ${reviewCount} reviews`
|
|
||||||
: "Open Review Modal"
|
|
||||||
}
|
|
||||||
onDropDownClick={state => settings.store.reviewsDropdownState = !state}
|
|
||||||
defaultState={settings.store.reviewsDropdownState}
|
|
||||||
>
|
|
||||||
<ReviewsView
|
|
||||||
discordId={user.id}
|
|
||||||
name={user.username}
|
|
||||||
onFetchReviews={r => setReviewCount(r.reviewCount)}
|
|
||||||
showInput
|
|
||||||
/>
|
|
||||||
</ExpandableHeader>
|
|
||||||
);
|
|
||||||
}, { message: "Failed to render Reviews" }),
|
|
||||||
|
|
||||||
BiteSizeReviewsButton: ErrorBoundary.wrap(({ user }: { user: User; }) => {
|
BiteSizeReviewsButton: ErrorBoundary.wrap(({ user }: { user: User; }) => {
|
||||||
return (
|
return (
|
||||||
<TooltipContainer text="View Reviews">
|
<TooltipContainer text="View Reviews">
|
||||||
|
|
|
@ -54,12 +54,6 @@ export const settings = definePluginSettings({
|
||||||
description: "Hide reviews from blocked users",
|
description: "Hide reviews from blocked users",
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
preferButtonOverDropdown: {
|
|
||||||
description: "Show a button instead of dropdown to view reviews",
|
|
||||||
type: OptionType.BOOLEAN,
|
|
||||||
default: true,
|
|
||||||
restartNeeded: true
|
|
||||||
},
|
|
||||||
buttons: {
|
buttons: {
|
||||||
type: OptionType.COMPONENT,
|
type: OptionType.COMPONENT,
|
||||||
description: "ReviewDB buttons",
|
description: "ReviewDB buttons",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue