Fix Broken Patches (#643)
* ShowConnections: fix patch * PermissionViewer: fix * AlwaysExpandRoles: fix patch * bleh * tidy up * bleh * AlwaysExpandRoles: Fix Hide Arrow --------- Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
parent
ef2daf752c
commit
54a90a8b08
6 changed files with 30 additions and 35 deletions
|
|
@ -69,8 +69,8 @@ export default definePlugin({
|
|||
{
|
||||
find: ".hasAvatarForGuild(null==",
|
||||
replacement: {
|
||||
match: /currentUser:\i,guild:\i.{0,15}\}\).{0,100}(?=\])/,
|
||||
replace: "$&,$self.ProfilePopoutComponent({ user: arguments[0].user, displayProfile: arguments[0].displayProfile })"
|
||||
match: /userId:\i\.id,guild:\i.{0,15}\}\).{0,100}(?=\])/,
|
||||
replace: "$&,$self.ProfilePopoutComponent(arguments[0])"
|
||||
}
|
||||
},
|
||||
// User Profile Modal v1
|
||||
|
|
@ -78,7 +78,7 @@ export default definePlugin({
|
|||
find: ".connections,userId:",
|
||||
replacement: {
|
||||
match: /user:(\i).{0,15}displayProfile:(\i).*?application\.id\)\)\}\)/,
|
||||
replace: "$&,$self.ProfilePopoutComponent({ user: arguments[0].user, displayProfile: arguments[0].displayProfile }),"
|
||||
replace: "$&,$self.ProfilePopoutComponent(arguments[0]),"
|
||||
}
|
||||
},
|
||||
// User Profile Modal v2
|
||||
|
|
|
|||
|
|
@ -17,12 +17,9 @@
|
|||
*/
|
||||
|
||||
import { definePluginSettings, migratePluginSettings } from "@api/Settings";
|
||||
import { disableStyle, enableStyle } from "@api/Styles";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
||||
import style from "./style.css?managed";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
hideArrow: {
|
||||
type: OptionType.BOOLEAN,
|
||||
|
|
@ -38,28 +35,27 @@ export default definePlugin({
|
|||
description: "Always expands the role list in profile popouts",
|
||||
authors: [Devs.surgedevs],
|
||||
isModified: true,
|
||||
settings,
|
||||
patches: [
|
||||
{
|
||||
find: 'action:"EXPAND_ROLES"',
|
||||
find: "hasDeveloperContextMenu:",
|
||||
replacement: [
|
||||
{
|
||||
match: /(roles:\i(?=.+?(\i)\(!0\)[,;]\i\({action:"EXPAND_ROLES"}\)).+?\[\i,\2\]=\i\.useState\()!1\)/,
|
||||
replace: (_, rest, setExpandedRoles) => `${rest}!0)`
|
||||
match: /(?<=\?\i\.current\[\i\].{0,100})useState\(!1\)/,
|
||||
replace: "useState(!0)"
|
||||
},
|
||||
{
|
||||
// Fix not calculating non-expanded roles because the above patch makes the default "expanded",
|
||||
// which makes the collapse button never show up and calculation never occur
|
||||
match: /(?<=useLayoutEffect\(\(\)=>{if\()\i/,
|
||||
replace: isExpanded => "false"
|
||||
match: /(?<=useLayoutEffect\(\(\)=>\{if\()\i/,
|
||||
replace: "false"
|
||||
},
|
||||
{
|
||||
match: /\(\)=>\i\.length<\i\.length/,
|
||||
replace: "()=>false",
|
||||
predicate: () => settings.store.hideArrow
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
settings,
|
||||
start() {
|
||||
if (settings.store.hideArrow) enableStyle(style);
|
||||
},
|
||||
stop() {
|
||||
if (settings.store.hideArrow) disableStyle(style);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
[aria-label]:has(> [class*="collapseButton"]) {
|
||||
display: none
|
||||
}
|
||||
|
|
@ -39,14 +39,13 @@ interface UserPermission {
|
|||
|
||||
type UserPermissions = Array<UserPermission>;
|
||||
|
||||
const { RoleRootClasses, RoleClasses, RoleBorderClasses } = proxyLazyWebpack(() => {
|
||||
const [RoleRootClasses, RoleClasses, RoleBorderClasses] = findBulk(
|
||||
filters.byProps("root", "expandButton", "collapseButton"),
|
||||
filters.byProps("role", "roleCircle", "roleName"),
|
||||
filters.byProps("roleCircle", "dot", "dotBorderColor")
|
||||
const { RoleClasses, RoleBorderClasses } = proxyLazyWebpack(() => {
|
||||
const [RoleClasses, RoleBorderClasses] = findBulk(
|
||||
filters.byProps("root", "role", "roleRemoveButton", "roleName"),
|
||||
filters.byProps("roleCircle", "dotBorderColor")
|
||||
) as Record<string, string>[];
|
||||
|
||||
return { RoleRootClasses, RoleClasses, RoleBorderClasses };
|
||||
return { RoleClasses, RoleBorderClasses };
|
||||
});
|
||||
|
||||
interface FakeRoleProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
|
|
@ -193,7 +192,7 @@ function UserPermissionsComponent({ guild, guildMember, closePopout }: { guild:
|
|||
</div>
|
||||
</div>
|
||||
{userPermissions.length > 0 && (
|
||||
<div className={classes(RoleRootClasses.root)}>
|
||||
<div className={classes(RoleClasses.root)}>
|
||||
{userPermissions.map(({ permission, roleColor, roleName }) => (
|
||||
<Tooltip
|
||||
key={permission}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import { TooltipContainer } from "@components/TooltipContainer";
|
|||
import { Devs } from "@utils/constants";
|
||||
import { classes } from "@utils/misc";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { type Guild, type GuildMember, RoleOrUserPermission } from "@vencord/discord-types";
|
||||
import { type Guild, RoleOrUserPermission } from "@vencord/discord-types";
|
||||
import { PermissionOverwriteType } from "@vencord/discord-types/enums";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { Button, ChannelStore, Dialog, GuildMemberStore, GuildRoleStore, GuildStore, match, Menu, PermissionsBits, Popout, useRef, UserStore } from "@webpack/common";
|
||||
|
|
@ -167,13 +167,16 @@ export default definePlugin({
|
|||
{
|
||||
find: "#{intl::COLLAPSE_ROLES}",
|
||||
replacement: {
|
||||
match: /className:(\i\.expandButton),.+?null,/,
|
||||
replace: "$&$self.ViewPermissionsButton({className:$1,props:arguments[0]}),"
|
||||
match: /(?<=\i\.id\)\),\i\(\))(?=,\i\?)/,
|
||||
replace: ",$self.ViewPermissionsButton(arguments[0])"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
ViewPermissionsButton: ErrorBoundary.wrap(({ className, props: { guild, guildMember } }: { className: string, props: { guild: Guild; guildMember: GuildMember; }; }) => {
|
||||
ViewPermissionsButton: ErrorBoundary.wrap(({ className, guild, userId }: { className: string; guild: Guild; userId: string; }) => {
|
||||
const guildMember = GuildMemberStore.getMember(guild.id, userId);
|
||||
if (!guildMember) return null;
|
||||
|
||||
const buttonRef = useRef(null);
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -166,10 +166,10 @@ export default definePlugin({
|
|||
|
||||
patches: [
|
||||
{
|
||||
find: ".hasAvatarForGuild(null==",
|
||||
find: "UserProfilePopoutBody",
|
||||
replacement: {
|
||||
match: /currentUser:\i,guild:\i[^}]*?\}\)(?=])(?<=user:(\i),bio:null==(\i)\?.+?)/,
|
||||
replace: "$&,$self.profilePopoutComponent({ user: $1, displayProfile: $2 })"
|
||||
match: /userId:\i\.id,guild:\i\}\)(?=])/,
|
||||
replace: "$&,$self.profilePopoutComponent(arguments[0])"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue