mirror of
https://github.com/Equicord/Equicord.git
synced 2025-01-31 03:33:36 -05: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 ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { ExpandableHeader } from "@components/ExpandableHeader";
|
||||
import { NotesIcon, OpenExternalIcon } from "@components/Icons";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { classes } from "@utils/misc";
|
||||
import definePlugin from "@utils/types";
|
||||
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 { Auth, initAuth, updateAuth } from "./auth";
|
||||
import { openReviewsModal } from "./components/ReviewModal";
|
||||
import ReviewsView from "./components/ReviewsView";
|
||||
import { NotificationType } from "./entities";
|
||||
import { getCurrentUserInfo, readNotification } from "./reviewDbApi";
|
||||
import { settings } from "./settings";
|
||||
|
@ -78,28 +76,12 @@ export default definePlugin({
|
|||
},
|
||||
|
||||
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:",
|
||||
replacement: {
|
||||
match: /{profileType:\i\.\i\.BITE_SIZE,children:\[/,
|
||||
replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user}),"
|
||||
},
|
||||
predicate: () => settings.store.preferButtonOverDropdown
|
||||
}
|
||||
},
|
||||
{
|
||||
find: ".FULL_SIZE,user:",
|
||||
|
@ -171,31 +153,6 @@ export default definePlugin({
|
|||
}, 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; }) => {
|
||||
return (
|
||||
<TooltipContainer text="View Reviews">
|
||||
|
@ -212,4 +169,4 @@ export default definePlugin({
|
|||
</TooltipContainer>
|
||||
);
|
||||
}, { noop: true })
|
||||
});
|
||||
});
|
|
@ -54,12 +54,6 @@ export const settings = definePluginSettings({
|
|||
description: "Hide reviews from blocked users",
|
||||
default: true,
|
||||
},
|
||||
preferButtonOverDropdown: {
|
||||
description: "Show a button instead of dropdown to view reviews",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true,
|
||||
restartNeeded: true
|
||||
},
|
||||
buttons: {
|
||||
type: OptionType.COMPONENT,
|
||||
description: "ReviewDB buttons",
|
||||
|
|
Loading…
Reference in a new issue