mirror of
https://github.com/Equicord/Equicord.git
synced 2025-04-01 13:11:57 -04:00
Fix GitHubRepos Patch
This commit is contained in:
parent
b65b58f94e
commit
3c9275fb9f
1 changed files with 9 additions and 44 deletions
|
@ -12,6 +12,7 @@ import { Logger } from "@utils/Logger";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByCodeLazy } from "@webpack";
|
import { findByCodeLazy } from "@webpack";
|
||||||
import { React } from "@webpack/common";
|
import { React } from "@webpack/common";
|
||||||
|
import { User } from "discord-types/general";
|
||||||
|
|
||||||
import { GitHubReposComponent } from "./components/GitHubReposComponent";
|
import { GitHubReposComponent } from "./components/GitHubReposComponent";
|
||||||
import { settings } from "./utils/settings";
|
import { settings } from "./utils/settings";
|
||||||
|
@ -21,8 +22,8 @@ const getProfileThemeProps = findByCodeLazy(".getPreviewThemeColors", "primaryCo
|
||||||
const logger = new Logger("GitHubRepos");
|
const logger = new Logger("GitHubRepos");
|
||||||
logger.info("Plugin loaded");
|
logger.info("Plugin loaded");
|
||||||
|
|
||||||
const profilePopoutComponent = ErrorBoundary.wrap(
|
const ProfilePopoutComponent = ErrorBoundary.wrap(
|
||||||
(props: { user: any; displayProfile?: any; }) => {
|
(props: { user: User; displayProfile?: any; }) => {
|
||||||
return (
|
return (
|
||||||
<GitHubReposComponent
|
<GitHubReposComponent
|
||||||
{...props}
|
{...props}
|
||||||
|
@ -50,53 +51,17 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: ".hasAvatarForGuild(null==",
|
find: ".hasAvatarForGuild(null==",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /currentUser:\i,guild:\i}\)(?<=user:(\i),bio:null==(\i)\?.+?)/,
|
match: /(?<=user:(\i),bio:null==(\i)\?.+?currentUser:\i,guild:\i}\))/,
|
||||||
replace: (m, user, profile) => {
|
replace: ",$self.ProfilePopoutComponent({ user: $1, displayProfile: $2 })"
|
||||||
return `${m},$self.profilePopoutComponent({ user: ${user}, displayProfile: ${profile} })`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: "renderBio",
|
find: "action:\"PRESS_APP_CONNECTION\"",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /renderBio\(\){.+?return (.*?)}/s,
|
match: /(?<=user:(\i).{0,15}displayProfile:(\i).*?#{intl::USER_PROFILE_MEMBER_SINCE}.{0,90}\}\)\}\))/,
|
||||||
replace: (m, returnStatement) => {
|
replace: "$&,$self.ProfilePopoutComponent({ user: $1, displayProfile: $2 }),"
|
||||||
return `renderBio(){
|
|
||||||
const originalReturn = ${returnStatement};
|
|
||||||
const user = this.props.user;
|
|
||||||
if (!user) return originalReturn;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const component = $self.profilePopoutComponent({
|
|
||||||
user: user,
|
|
||||||
displayProfile: this.props.displayProfile
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!originalReturn) return component;
|
|
||||||
|
|
||||||
return React.createElement(
|
|
||||||
React.Fragment,
|
|
||||||
null,
|
|
||||||
originalReturn,
|
|
||||||
component
|
|
||||||
);
|
|
||||||
} catch (err) {
|
|
||||||
console.error("[GitHubRepos] Error in bio patch:", err);
|
|
||||||
return originalReturn;
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
ProfilePopoutComponent
|
||||||
start() {
|
|
||||||
logger.info("Plugin started");
|
|
||||||
},
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
logger.info("Plugin stopped");
|
|
||||||
},
|
|
||||||
|
|
||||||
profilePopoutComponent
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue