Skip to content

Commit a65de56

Browse files
committed
Merge branch 'main' of https://github.com/doggybootsy/vx
2 parents ba7b8e7 + b8d493d commit a65de56

File tree

7 files changed

+249
-23
lines changed

7 files changed

+249
-23
lines changed

packages/mod/src/api/modals/code.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function openCodeModal(options: Omit<CodeBlockProps, "canOpenInModal">) {
66
return openModal((props) => (
77
<ModalComponents.Root
88
transitionState={props.transitionState}
9-
size={ModalComponents.Size.MEDIUM}
9+
size={ModalComponents.Size.DYNAMIC}
1010
className="vx-codeblock-modal"
1111
>
1212
<CodeBlock

packages/mod/src/api/quick-actions/hmba.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {MenuComponents, openMenu} from "../menu";
22
import {closeAllModals} from "../modals";
3-
import {addPlainTextPatch} from "@webpack";
3+
import {addPlainTextPatch, getProxy} from "@webpack";
44

55
addPlainTextPatch({
66
match: "Messages.DISCODO_DISABLED",
77
find: /.tutorialContainer,/,
88
replace: '$&onContextMenu:$vxi.HMBA?.openContextMenu,'
99
})
1010

11-
export default class HomeButtonContextMenuApi {
11+
export class HomeButtonContextMenuApi {
1212
items: Map<string, React.ReactElement | (() => React.ReactElement)>;
1313
constructor() {
1414
this.items = new Map();
@@ -40,4 +40,4 @@ export default class HomeButtonContextMenuApi {
4040
}
4141
}
4242

43-
export const HMBA = __self__.HMBA = new HomeButtonContextMenuApi();
43+
export const HMBA = __self__.HMBA = new HomeButtonContextMenuApi();
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import {Tooltip} from "../../components";
2+
import {addPlainTextPatch} from "@webpack";
3+
import {React} from "../../../../../types";
4+
5+
addPlainTextPatch(
6+
{
7+
match: "markdownSyntax:",
8+
find: /(\((\w+),.{10,20}markdownSyntax:"spoiler".{75,100})]/,
9+
replace: `$1,$vxi.STAPI.renderButtons($2)]`
10+
},
11+
{
12+
match: /\w+.\w+.edges\(\w+.selection\)/,
13+
find: /(onClick:\s*\(\)\s*=>\s*\{)(\s*)(null\s*!=\s*(\w+)\s*&&\s*\w+\.\w+\.withSingleEntry\([^)]+\))/,
14+
replace: "$1if(arguments[0]?.onClick){arguments[0].onClick?.()}else if(null!=$4)$3"
15+
}
16+
)
17+
18+
interface ButtonConfig {
19+
label: string;
20+
icon: React.Component;
21+
onClick: () => void;
22+
tooltip?: string;
23+
}
24+
25+
class DynamicButtonAPI {
26+
private buttonConfigs: ButtonConfig[];
27+
28+
constructor() {
29+
this.buttonConfigs = [];
30+
}
31+
32+
renderButtons(T?: any) {
33+
return this.buttonConfigs.map((config, index) => (
34+
<Tooltip key={index} text={config.tooltip || config.label}>
35+
{(props) => {
36+
const ButtonWrapper = T || 'div';
37+
return (
38+
<ButtonWrapper>
39+
<div
40+
{...props}
41+
style={{
42+
display: "flex",
43+
justifyContent: "center",
44+
alignItems: "center",
45+
height: "100%"
46+
}}
47+
onClick={config.onClick}>
48+
{config.icon}
49+
</div>
50+
</ButtonWrapper>
51+
);
52+
}}
53+
</Tooltip>
54+
));
55+
}
56+
57+
addButton(config: ButtonConfig) {
58+
this.buttonConfigs.push(config);
59+
}
60+
}
61+
62+
export const SlateToolbarAPI = __self__.STAPI = new DynamicButtonAPI();

packages/mod/src/plugins/github-in-discord/githubModal.tsx

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useEffect, useState} from 'react';
1+
import {Component, useEffect, useState} from 'react';
22
import {ModalComponents, openCodeModal, openImageModal, openModal, openVideoModal} from '../../api/modals';
33
import {Button, Flex, Icons, Markdown, SystemDesign} from "../../components";
44
import {settings} from "./index";
@@ -256,6 +256,16 @@ export class GitHubService {
256256
return await this.fetchFromGitHub(`${endpoint}?ref=${repoDetails.default_branch}`);
257257
}
258258
}
259+
260+
async getCommitsForPullRequest(user: string, repo: string, pullNumber: number) {
261+
const endpoint = `/repos/${user}/${repo}/pulls/${pullNumber}/commits`;
262+
return this.fetchFromGitHub(endpoint);
263+
}
264+
265+
async getCommitDetails(user: string, repo: string, commitSha: string) {
266+
const endpoint = `/repos/${user}/${repo}/commits/${commitSha}`;
267+
return this.fetchFromGitHub(endpoint);
268+
}
259269
}
260270

261271
interface GitHubModalProps {
@@ -429,6 +439,16 @@ function format(size: number) {
429439
return `${size.toPrecision(3)} ${[ "", "K", "M", "G", "T", "P" ][count]}B`;
430440
}
431441

442+
class ArchivedBanner extends Component<{created_at: string}> {
443+
render() {
444+
return <div className="vx-gm-archived-banner">
445+
<span>
446+
This repo has been archived since {new Date(this.props.created_at).toLocaleString()}
447+
</span>
448+
</div>;
449+
}
450+
}
451+
432452
const ControlBar: React.FC<{
433453
forksList: any[];
434454
branches: any[];
@@ -523,7 +543,44 @@ const IssueList: React.FC<{ issues: any[]; setCurrentPage: (page: 'files' | 'rel
523543
);
524544
};
525545

526-
const PullRequestList: React.FC<{ pullRequests: any[]; setCurrentPage: (page: 'files' | 'releases' | 'pullRequests' | 'issues') => void }> = ({ pullRequests, setCurrentPage }) => {
546+
const PullRequestList: React.FC<{
547+
pullRequests: any[];
548+
setCurrentPage: (page: 'files' | 'releases' | 'pullRequests' | 'issues') => void
549+
}> = ({ pullRequests, setCurrentPage }) => {
550+
const [commits, setCommits] = useState<any[]>([]);
551+
552+
useEffect(() => {
553+
const fetchCommits = async () => {
554+
const allCommits = await Promise.all(pullRequests.map(async (pr) => {
555+
const commits = await githubService.getCommitsForPullRequest(pr.base.repo.owner.login, pr.base.repo.name, pr.number);
556+
const commitDetails = await Promise.all(commits.map(async (commit) => {
557+
const details = await githubService.getCommitDetails(pr.base.repo.owner.login, pr.base.repo.name, commit.sha);
558+
return { ...commit, files: details.files, pr };
559+
}));
560+
return commitDetails;
561+
}));
562+
setCommits(allCommits.flat());
563+
};
564+
fetchCommits();
565+
}, [pullRequests]);
566+
567+
const handleCommitClick = async (commit: any) => {
568+
const commitDetails = await githubService.getCommitDetails(commit.pr.base.repo.owner.login, commit.pr.base.repo.name, commit.sha);
569+
openCodeModal({
570+
content: commitDetails.commit.message,
571+
language: 'markdown',
572+
title: commit.commit.message
573+
});
574+
};
575+
576+
const handleFileClick = (file: any) => {
577+
openCodeModal({
578+
content: file.patch,
579+
language: 'diff',
580+
title: file.filename
581+
});
582+
};
583+
527584
return (
528585
<div className="vx-gm-pull-requests-container">
529586
{pullRequests.map((pr: any) => (
@@ -537,6 +594,26 @@ const PullRequestList: React.FC<{ pullRequests: any[]; setCurrentPage: (page: 'f
537594
rel="noopener noreferrer">
538595
View on GitHub
539596
</a>
597+
<div className="vx-gm-commits-container">
598+
{commits.filter((commit) => commit.pr.id === pr.id).map((commit) => (
599+
<div key={commit.sha} className="vx-gm-commit-item">
600+
<div onClick={() => handleCommitClick(commit)}>
601+
<span>{commit.commit.message}</span>
602+
</div>
603+
<Flex direction={Flex.Direction.HORIZONTAL} className="vx-gm-commit-files">
604+
{commit.files && commit.files.map((file: any) => (
605+
<Button
606+
key={file.filename}
607+
onClick={() => handleFileClick(file)}
608+
className="vx-gm-file-button"
609+
>
610+
{file.filename}
611+
</Button>
612+
))}
613+
</Flex>
614+
</div>
615+
))}
616+
</div>
540617
</div>
541618
))}
542619
<Button
@@ -867,7 +944,7 @@ const GitHubModal: React.FC<GitHubModalProps> = ({ url, onClose, props }) => {
867944
setRepoInfo(fullRepoInfo);
868945

869946
setRepoArchived(repoArchiveDetails)
870-
947+
871948
const [forks, branchesData, contributorsData, releasesData, pullRequestsData, issuesData] = await Promise.all([
872949
githubService.getForks(fullRepoInfo.user, fullRepoInfo.repo),
873950
githubService.getBranches(fullRepoInfo.user, fullRepoInfo.repo),

packages/mod/src/plugins/github-in-discord/index.css

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,10 @@
420420
padding: 8px 12px;
421421
cursor: pointer;
422422
border-radius: 6px;
423-
color: var(--vx-text-default, #1F2328);
423+
color: var(--vx-text-default);
424+
background-color: var(--vx-background-default, #1F2328);
424425
text-decoration: none;
425426
font-size: 14px;
426-
background: transparent;
427427
border: none;
428428
}
429429

@@ -569,18 +569,18 @@
569569
.vx-gm-pull-requests-container {
570570
margin-top: 20px;
571571
padding: 16px;
572-
border-top: 1px solid #e1e4e8;
572+
border-top: 1px solid var(--vx-border-default);
573573
}
574574

575575
.vx-gm-pull-requests-container h3 {
576-
font-size: 18px;
576+
font-size: 20px;
577577
font-weight: 600;
578578
margin-bottom: 16px;
579579
color: var(--vx-text-default);
580580
}
581581

582582
.vx-gm-pr-item {
583-
border: 1px solid #e1e4e8;
583+
border: 1px solid var(--vx-border-default);
584584
border-radius: 6px;
585585
padding: 16px;
586586
margin-bottom: 16px;
@@ -594,7 +594,7 @@
594594
color: var(--vx-text-default);
595595
}
596596

597-
.vx-gm-pr-item p {
597+
.vx-gm-pr-item .vx-gm-markdown {
598598
font-size: 14px;
599599
margin: 0 0 16px;
600600
color: var(--vx-text-default);
@@ -604,7 +604,7 @@
604604
.vx-gm-pr-item .vx-gm-pr-link {
605605
display: inline-block;
606606
margin-right: 16px;
607-
color: #0366d6;
607+
color: var(--vx-accent-primary);
608608
text-decoration: none;
609609
font-size: 14px;
610610
}
@@ -789,4 +789,69 @@
789789

790790
.vx-gm-json-viewer span {
791791
cursor: pointer;
792+
}
793+
794+
795+
.vx-gm-pr-item {
796+
border: 1px solid var(--vx-border-default);
797+
border-radius: 6px;
798+
padding: 16px;
799+
margin-bottom: 16px;
800+
background-color: var(--vx-background-secondary);
801+
}
802+
803+
.vx-gm-pr-item .vx-gm-pr-title {
804+
font-size: 16px;
805+
font-weight: 600;
806+
margin: 0 0 8px;
807+
color: var(--vx-text-default);
808+
}
809+
810+
.vx-gm-pr-item .vx-gm-markdown {
811+
font-size: 14px;
812+
margin: 0 0 16px;
813+
color: var(--vx-text-default);
814+
line-height: 1.5;
815+
}
816+
817+
.vx-gm-pr-item .vx-gm-pr-link {
818+
display: inline-block;
819+
margin-right: 16px;
820+
color: var(--vx-accent-primary);
821+
text-decoration: none;
822+
font-size: 14px;
823+
}
824+
825+
.vx-gm-pr-item .vx-gm-pr-link:hover {
826+
text-decoration: underline;
827+
}
828+
829+
.vx-gm-commits-container {
830+
margin-top: 16px;
831+
border-top: 1px solid var(--vx-border-default);
832+
padding-top: 16px;
833+
}
834+
835+
.vx-gm-commit-item {
836+
margin-bottom: 16px;
837+
padding: 8px;
838+
background-color: var(--vx-background-default);
839+
border: 1px solid var(--vx-border-default);
840+
border-radius: 6px;
841+
}
842+
843+
.vx-gm-commit-message {
844+
font-size: 14px;
845+
color: var(--vx-text-default);
846+
cursor: pointer;
847+
padding: 8px;
848+
border-bottom: 1px solid var(--vx-border-default);
849+
}
850+
851+
.vx-gm-commit-message:hover {
852+
background-color: var(--vx-background-tertiary);
853+
}
854+
855+
.vx-gm-commit-files {
856+
margin-top: 8px;
792857
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { definePlugin } from "vx:plugins";
2+
import { Developers } from "../../constants";
3+
import { Icons } from "../../components";
4+
5+
import { TextAreaInput } from "@webpack/common";
6+
import {SlateToolbarAPI} from "../../api/quick-actions/slate-toolbar";
7+
8+
const insertMaskedLink = (selectedText: string | null) => {
9+
if (selectedText) {
10+
TextAreaInput.insertText(`[dummy text](${selectedText})`);
11+
}
12+
};
13+
14+
export default definePlugin({
15+
authors: [Developers.kaan],
16+
requiresRestart: false,
17+
start(signal: AbortSignal) {
18+
SlateToolbarAPI.addButton(
19+
{
20+
label: "Mask List",
21+
icon: Icons.Plus,
22+
onClick: () => {
23+
const selectedText = getSelection()?.toString();
24+
if (!selectedText) return
25+
insertMaskedLink(selectedText)
26+
},
27+
tooltip: "Mask List"
28+
}
29+
)
30+
},
31+
});

packages/mod/src/plugins/webhook-messenger/index.css

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,6 @@
5656
margin: 0;
5757
}
5858

59-
.vx-gm-file-item {
60-
background-color: #40444b;
61-
color: #dcddde;
62-
padding: 8px 12px;
63-
border-radius: 3px;
64-
margin-bottom: 8px;
65-
font-size: 14px;
66-
}
67-
6859
.vx-gm-section-title {
6960
color: #ffffff;
7061
font-weight: 600;

0 commit comments

Comments
 (0)