mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-28 07:54:22 -04:00
Feat(plugin + fix ) GithubRepos & Pluginsettings (#185)
* Updated Pluginsettings.tsx (https://github.com/Vendicated/Vencord/pull/3293) Added GithubRepos (https://github.com/Vendicated/Vencord/pull/3292) Also added Equicord Contrib to needed people * Fixed lint error * Hopefully fixed it? * Resolved conflicts --------- Co-authored-by: Crxa <c@crxaw.tech> Co-authored-by: thororen <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
parent
bc29549586
commit
14db952e94
12 changed files with 835 additions and 1 deletions
102
src/equicordplugins/githubRepos/index.tsx
Normal file
102
src/equicordplugins/githubRepos/index.tsx
Normal file
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2025 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import "./styles.css";
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByCodeLazy } from "@webpack";
|
||||
import { React } from "@webpack/common";
|
||||
|
||||
import { GitHubReposComponent } from "./components/GitHubReposComponent";
|
||||
import { settings } from "./utils/settings";
|
||||
|
||||
const getProfileThemeProps = findByCodeLazy(".getPreviewThemeColors", "primaryColor:");
|
||||
|
||||
const logger = new Logger("GitHubRepos");
|
||||
logger.info("Plugin loaded");
|
||||
|
||||
const profilePopoutComponent = ErrorBoundary.wrap(
|
||||
(props: { user: any; displayProfile?: any; }) => {
|
||||
return (
|
||||
<GitHubReposComponent
|
||||
{...props}
|
||||
id={props.user.id}
|
||||
theme={getProfileThemeProps(props).theme}
|
||||
/>
|
||||
);
|
||||
},
|
||||
{
|
||||
noop: true,
|
||||
onError: err => {
|
||||
logger.error("Error in profile popout component", err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export default definePlugin({
|
||||
name: "GitHubRepos",
|
||||
description: "Displays a user's public GitHub repositories in their profile",
|
||||
authors: [EquicordDevs.talhakf],
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: ".hasAvatarForGuild(null==",
|
||||
replacement: {
|
||||
match: /currentUser:\i,guild:\i}\)(?<=user:(\i),bio:null==(\i)\?.+?)/,
|
||||
replace: (m, user, profile) => {
|
||||
return `${m},$self.profilePopoutComponent({ user: ${user}, displayProfile: ${profile} })`;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
find: "renderBio",
|
||||
replacement: {
|
||||
match: /renderBio\(\){.+?return (.*?)}/s,
|
||||
replace: (m, returnStatement) => {
|
||||
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;
|
||||
}
|
||||
}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
start() {
|
||||
logger.info("Plugin started");
|
||||
},
|
||||
|
||||
stop() {
|
||||
logger.info("Plugin stopped");
|
||||
},
|
||||
|
||||
profilePopoutComponent
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue