Merge Dev & Optimize Some Stuff

This commit is contained in:
thororen1234 2025-05-14 14:46:57 -04:00
commit 0fae2ee510
No known key found for this signature in database
16 changed files with 233 additions and 200 deletions

View file

@ -1,7 +1,7 @@
{
"name": "equicord",
"private": "true",
"version": "1.12.0",
"version": "1.12.1",
"description": "The other cutest Discord client mod",
"homepage": "https://github.com/Equicord/Equicord#readme",
"bugs": {

View file

@ -186,7 +186,7 @@ export const globPlugins = kind => ({
const mod = `p${i}`;
code += `import ${mod} from "./${dir}/${fileName.replace(/\.tsx?$/, "")}";\n`;
pluginsCode += `[${mod}.name]:${mod},\n`;
metaCode += `[${mod}.name]:${JSON.stringify({ folderName, userPlugin })},\n`; // TODO: add excluded plugins to display in the UI?
metaCode += `[${mod}.name]:${JSON.stringify({ folderName, userPlugin })},\n`;
i++;
}
}

View file

@ -33,7 +33,7 @@ import { openUpdaterModal } from "@components/VencordSettings/UpdaterTab";
import { StartAt } from "@utils/types";
import { get as dsGet } from "./api/DataStore";
import { showNotification } from "./api/Notifications";
import { NotificationData, showNotification } from "./api/Notifications";
import { PlainSettings, Settings } from "./api/Settings";
import { patches, PMLogger, startAllPlugins } from "./plugins";
import { localStorage } from "./utils/localStorage";
@ -105,6 +105,46 @@ async function syncSettings() {
}
}
let notifiedForUpdatesThisSession = false;
async function runUpdateCheck() {
const notify = (data: NotificationData) => {
if (notifiedForUpdatesThisSession) return;
notifiedForUpdatesThisSession = true;
setTimeout(() => showNotification({
permanent: true,
noPersist: true,
...data
}), 10_000);
};
try {
const isOutdated = await checkForUpdates();
if (!isOutdated) return;
if (Settings.autoUpdate) {
await update();
if (Settings.autoUpdateNotification) {
notify({
title: "Equicord has been updated!",
body: "Click here to restart",
onClick: relaunch
});
}
return;
}
notify({
title: "A Equicord update is available!",
body: "Click here to view the update",
onClick: openUpdaterModal!
});
} catch (err) {
UpdateLogger.error("Failed to check for updates", err);
}
}
async function init() {
await onceReady;
startAllPlugins(StartAt.WebpackReady);
@ -112,34 +152,8 @@ async function init() {
syncSettings();
if (!IS_WEB && !IS_UPDATER_DISABLED) {
try {
const isOutdated = await checkForUpdates();
if (!isOutdated) return;
if (Settings.autoUpdate) {
await update();
if (Settings.updateRelaunch) return relaunch;
if (Settings.autoUpdateNotification)
setTimeout(() => showNotification({
title: "Equicord has been updated!",
body: "Click here to restart",
permanent: true,
noPersist: true,
onClick: relaunch
}), 10_000);
return;
}
setTimeout(() => showNotification({
title: "A Equicord update is available!",
body: "Click here to view the update",
permanent: true,
noPersist: true,
onClick: openUpdaterModal!
}), 10_000);
} catch (err) {
UpdateLogger.error("Failed to check for updates", err);
}
runUpdateCheck();
setInterval(runUpdateCheck, 1000 * 60 * 30); // 30 minutes
}
if (IS_DEV) {

View file

@ -39,7 +39,6 @@ export interface Settings {
themeLinks: string[];
frameless: boolean;
transparent: boolean;
updateRelaunch: boolean;
winCtrlQ: boolean;
macosVibrancyStyle:
| "content"
@ -101,7 +100,6 @@ const DefaultSettings: Settings = {
winCtrlQ: false,
macosVibrancyStyle: undefined,
disableMinSize: false,
updateRelaunch: false,
winNativeTitleBar: false,
plugins: {},

View file

@ -41,7 +41,7 @@ export function VCDonateButton({
);
}
export default function DonateButton({
export function DonateButton({
look = Button.Looks.LINK,
color = Button.Colors.TRANSPARENT,
...props

View file

@ -106,8 +106,6 @@ function Updatable(props: CommonProps) {
const [updates, setUpdates] = React.useState(changes);
const [isChecking, setIsChecking] = React.useState(false);
const [isUpdating, setIsUpdating] = React.useState(false);
const settings = useSettings(["updateRelaunch"]);
const isOutdated = (updates?.length ?? 0) > 0;
return (
@ -119,7 +117,6 @@ function Updatable(props: CommonProps) {
onClick={withDispatcher(setIsUpdating, async () => {
if (await update()) {
setUpdates([]);
if (settings.updateRelaunch) return relaunch();
return await new Promise<void>(r => {
Alerts.show({
title: "Update Success!",
@ -191,7 +188,7 @@ function Newer(props: CommonProps) {
}
function Updater() {
const settings = useSettings(["autoUpdate", "updateRelaunch", "autoUpdateNotification"]);
const settings = useSettings(["autoUpdate", "autoUpdateNotification"]);
const [repo, err, repoPending] = useAwaiter(getRepo, { fallbackValue: "Loading..." });
@ -217,30 +214,12 @@ function Updater() {
</Switch>
<Switch
value={settings.autoUpdateNotification}
onChange={(v: boolean) => {
settings.autoUpdateNotification = v;
if (settings.updateRelaunch) {
settings.updateRelaunch = !v;
}
}}
onChange={(v: boolean) => settings.autoUpdateNotification = v}
note="Shows a notification when Equicord automatically updates"
disabled={!settings.autoUpdate}
>
Get notified when an automatic update completes
</Switch>
<Switch
value={settings.updateRelaunch}
onChange={(v: boolean) => {
settings.updateRelaunch = v;
if (settings.autoUpdateNotification) {
settings.autoUpdateNotification = !v;
}
}}
note="Relaunches the app after updating with no prompt"
disabled={!settings.autoUpdate}
>
Automatically relaunch after updating
</Switch>
<Forms.FormTitle tag="h5">Repo</Forms.FormTitle>

View file

@ -9,7 +9,7 @@ import "./VencordTab.css";
import { openNotificationLogModal } from "@api/Notifications/notificationLog";
import { useSettings } from "@api/Settings";
import { classNameFactory } from "@api/Styles";
import DonateButton, { InviteButton } from "@components/DonateButton";
import { DonateButton, InviteButton } from "@components/DonateButton";
import { openContributorModal } from "@components/PluginSettings/ContributorModal";
import { openPluginModal } from "@components/PluginSettings/PluginModal";
import { gitRemote } from "@shared/vencordUserAgent";

View file

@ -19,21 +19,18 @@
import "./fixDiscordBadgePadding.css";
import { _getBadges, BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges";
import DonateButton, { VCDonateButton } from "@components/DonateButton";
import ErrorBoundary from "@components/ErrorBoundary";
import { Flex } from "@components/Flex";
import { Heart } from "@components/Heart";
import { openContributorModal } from "@components/PluginSettings/ContributorModal";
import { isEquicordDonor } from "@components/VencordSettings/VencordTab";
import { Devs } from "@utils/constants";
import { Logger } from "@utils/Logger";
import { Margins } from "@utils/margins";
import { isEquicordPluginDev, isPluginDev } from "@utils/misc";
import { closeModal, ModalContent, ModalFooter, ModalHeader, ModalRoot, openModal } from "@utils/modal";
import definePlugin from "@utils/types";
import { Forms, Toasts, UserStore } from "@webpack/common";
import { Toasts, UserStore } from "@webpack/common";
import { User } from "discord-types/general";
import { EquicordDonorModal, VencordDonorModal } from "./modals";
const CONTRIBUTOR_BADGE = "https://vencord.dev/assets/favicon.png";
const EQUICORD_CONTRIBUTOR_BADGE = "https://i.imgur.com/57ATLZu.png";
const EQUICORD_DONOR_BADGE = "https://cdn.nest.rip/uploads/78cb1e77-b7a6-4242-9089-e91f866159bf.png";
@ -62,6 +59,9 @@ const EquicordDonorBadge: ProfileBadge = {
const donorBadges = EquicordDonorBadges[userId]?.map(badge => badge.badge);
const hasDonorBadge = donorBadges?.includes("https://cdn.nest.rip/uploads/78cb1e77-b7a6-4242-9089-e91f866159bf.png");
return isEquicordDonor(userId) && !hasDonorBadge;
},
onClick: () => {
return EquicordDonorModal();
}
};
@ -83,6 +83,7 @@ async function loadAllBadges(noCache = false) {
EquicordDonorBadges = equicordBadges;
}
let intervalId: any;
export default definePlugin({
name: "BadgeAPI",
@ -117,6 +118,15 @@ export default definePlugin({
}
],
// for access from the console or other plugins
get DonorBadges() {
return DonorBadges;
},
get EquicordDonorBadges() {
return EquicordDonorBadges;
},
toolboxActions: {
async "Refetch Badges"() {
await loadAllBadges(true);
@ -128,11 +138,16 @@ export default definePlugin({
}
},
userProfileBadges: [ContributorBadge, EquicordContributorBadge, EquicordDonorBadge],
async start() {
Vencord.Api.Badges.addProfileBadge(ContributorBadge);
Vencord.Api.Badges.addProfileBadge(EquicordContributorBadge);
Vencord.Api.Badges.addProfileBadge(EquicordDonorBadge);
await loadAllBadges();
clearInterval(intervalId);
intervalId = setInterval(loadAllBadges, 1000 * 60 * 30); // 30 minutes
},
async stop() {
clearInterval(intervalId);
},
getBadges(props: { userId: string; user?: User; guildId: string; }) {
@ -166,59 +181,7 @@ export default definePlugin({
}
},
onClick() {
const modalKey = openModal(props => (
<ErrorBoundary noop onError={() => {
closeModal(modalKey);
VencordNative.native.openExternal("https://github.com/sponsors/Vendicated");
}}>
<ModalRoot {...props}>
<ModalHeader>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<Forms.FormTitle
tag="h2"
style={{
width: "100%",
textAlign: "center",
margin: 0
}}
>
<Heart />
Vencord Donor
</Forms.FormTitle>
</Flex>
</ModalHeader>
<ModalContent>
<Flex>
<img
role="presentation"
src="https://cdn.discordapp.com/emojis/1026533070955872337.png"
alt=""
style={{ margin: "auto" }}
/>
<img
role="presentation"
src="https://cdn.discordapp.com/emojis/1026533090627174460.png"
alt=""
style={{ margin: "auto" }}
/>
</Flex>
<div style={{ padding: "1em" }}>
<Forms.FormText>
This Badge is a special perk for Vencord Donors
</Forms.FormText>
<Forms.FormText className={Margins.top20}>
Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!
</Forms.FormText>
</div>
</ModalContent>
<ModalFooter>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<VCDonateButton />
</Flex>
</ModalFooter>
</ModalRoot>
</ErrorBoundary>
));
return VencordDonorModal();
},
}));
},
@ -235,60 +198,7 @@ export default definePlugin({
}
},
onClick() {
const modalKey = openModal(props => (
<ErrorBoundary noop onError={() => {
closeModal(modalKey);
// Will get my own in the future
VencordNative.native.openExternal("https://github.com/sponsors/Vendicated");
}}>
<ModalRoot {...props}>
<ModalHeader>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<Forms.FormTitle
tag="h2"
style={{
width: "100%",
textAlign: "center",
margin: 0
}}
>
<Heart />
Equicord Donor
</Forms.FormTitle>
</Flex>
</ModalHeader>
<ModalContent>
<Flex>
<img
role="presentation"
src="https://cdn.discordapp.com/emojis/1026533070955872337.png"
alt=""
style={{ margin: "auto" }}
/>
<img
role="presentation"
src="https://cdn.discordapp.com/emojis/1026533090627174460.png"
alt=""
style={{ margin: "auto" }}
/>
</Flex>
<div style={{ padding: "1em" }}>
<Forms.FormText>
This Badge is a special perk for Equicord (Not Vencord) Donors
</Forms.FormText>
<Forms.FormText className={Margins.top20}>
Please consider supporting the development of Equicord by becoming a donor. It would mean a lot! :3
</Forms.FormText>
</div>
</ModalContent>
<ModalFooter>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<DonateButton />
</Flex>
</ModalFooter>
</ModalRoot>
</ErrorBoundary>
));
return EquicordDonorModal();
},
}));
}

View file

@ -0,0 +1,126 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { DonateButton, VCDonateButton } from "@components/DonateButton";
import { Flex } from "@components/Flex";
import { Heart } from "@components/Heart";
import { ErrorBoundary } from "@components/index";
import { Margins } from "@utils/margins";
import { closeModal, ModalContent, ModalFooter, ModalHeader, ModalRoot, openModal } from "@utils/modal";
import { Forms } from "@webpack/common";
export function VencordDonorModal() {
const modalKey = openModal(props => (
<ErrorBoundary noop onError={() => {
closeModal(modalKey);
VencordNative.native.openExternal("https://github.com/sponsors/Vendicated");
}}>
<ModalRoot {...props}>
<ModalHeader>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<Forms.FormTitle
tag="h2"
style={{
width: "100%",
textAlign: "center",
margin: 0
}}
>
<Heart />
Vencord Donor
</Forms.FormTitle>
</Flex>
</ModalHeader>
<ModalContent>
<Flex>
<img
role="presentation"
src="https://cdn.discordapp.com/emojis/1026533070955872337.png"
alt=""
style={{ margin: "auto" }}
/>
<img
role="presentation"
src="https://cdn.discordapp.com/emojis/1026533090627174460.png"
alt=""
style={{ margin: "auto" }}
/>
</Flex>
<div style={{ padding: "1em" }}>
<Forms.FormText>
This Badge is a special perk for Vencord Donors
</Forms.FormText>
<Forms.FormText className={Margins.top20}>
Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!
</Forms.FormText>
</div>
</ModalContent>
<ModalFooter>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<VCDonateButton />
</Flex>
</ModalFooter>
</ModalRoot>
</ErrorBoundary>
));
}
export function EquicordDonorModal() {
const modalKey = openModal(props => (
<ErrorBoundary noop onError={() => {
closeModal(modalKey);
// Will get my own in the future
VencordNative.native.openExternal("https://github.com/sponsors/thororen1234");
}}>
<ModalRoot {...props}>
<ModalHeader>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<Forms.FormTitle
tag="h2"
style={{
width: "100%",
textAlign: "center",
margin: 0
}}
>
<Heart />
Equicord Donor
</Forms.FormTitle>
</Flex>
</ModalHeader>
<ModalContent>
<Flex>
<img
role="presentation"
src="https://cdn.discordapp.com/emojis/1026533070955872337.png"
alt=""
style={{ margin: "auto" }}
/>
<img
role="presentation"
src="https://cdn.discordapp.com/emojis/1026533090627174460.png"
alt=""
style={{ margin: "auto" }}
/>
</Flex>
<div style={{ padding: "1em" }}>
<Forms.FormText>
This Badge is a special perk for Equicord (Not Vencord) Donors
</Forms.FormText>
<Forms.FormText className={Margins.top20}>
Please consider supporting the development of Equicord by becoming a donor. It would mean a lot! :3
</Forms.FormText>
</div>
</ModalContent>
<ModalFooter>
<Flex style={{ width: "100%", justifyContent: "center" }}>
<DonateButton />
</Flex>
</ModalFooter>
</ModalRoot>
</ErrorBoundary>
));
}

View file

@ -133,7 +133,7 @@ for (const p of pluginsValues) if (isPluginEnabled(p.name)) {
if (p.renderMessageAccessory) neededApiPlugins.add("MessageAccessoriesAPI");
if (p.renderMessageDecoration) neededApiPlugins.add("MessageDecorationsAPI");
if (p.renderMessagePopoverButton) neededApiPlugins.add("MessagePopoverAPI");
if (p.userProfileBadge) neededApiPlugins.add("BadgeAPI");
if (p.userProfileBadges) neededApiPlugins.add("BadgeAPI");
for (const key of pluginKeysToBind) {
p[key] &&= p[key].bind(p) as any;
@ -261,7 +261,7 @@ export function subscribeAllPluginsFluxEvents(fluxDispatcher: typeof FluxDispatc
export const startPlugin = traceFunction("startPlugin", function startPlugin(p: Plugin) {
const {
name, commands, contextMenus, managedStyle, userProfileBadge,
name, commands, contextMenus, managedStyle, userProfileBadges,
onBeforeMessageEdit, onBeforeMessageSend, onMessageClick,
renderChatBarButton, renderMemberListDecorator, renderNicknameIcon, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton
} = p;
@ -307,7 +307,7 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p:
if (managedStyle) enableStyle(managedStyle);
if (userProfileBadge) addProfileBadge(userProfileBadge);
if (userProfileBadges) userProfileBadges.forEach(e => addProfileBadge(e));
if (onBeforeMessageEdit) addMessagePreEditListener(onBeforeMessageEdit);
if (onBeforeMessageSend) addMessagePreSendListener(onBeforeMessageSend);
@ -325,7 +325,7 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p:
export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plugin) {
const {
name, commands, contextMenus, managedStyle, userProfileBadge,
name, commands, contextMenus, managedStyle, userProfileBadges,
onBeforeMessageEdit, onBeforeMessageSend, onMessageClick,
renderChatBarButton, renderMemberListDecorator, renderNicknameIcon, renderMessageAccessory, renderMessageDecoration, renderMessagePopoverButton
} = p;
@ -369,7 +369,7 @@ export const stopPlugin = traceFunction("stopPlugin", function stopPlugin(p: Plu
if (managedStyle) disableStyle(managedStyle);
if (userProfileBadge) removeProfileBadge(userProfileBadge);
if (userProfileBadges) userProfileBadges.forEach(e => removeProfileBadge(e));
if (onBeforeMessageEdit) removeMessagePreEditListener(onBeforeMessageEdit);
if (onBeforeMessageSend) removeMessagePreSendListener(onBeforeMessageSend);

View file

@ -110,7 +110,7 @@ export default definePlugin({
patches: [
{
// Indicator
find: "#{intl::MESSAGE_EDITED}",
find: ".SEND_FAILED,",
replacement: {
match: /let\{className:\i,message:\i[^}]*\}=(\i)/,
replace: "try {$1 && $self.INV_REGEX.test($1.message.content) ? $1.content.push($self.indicator()) : null } catch {};$&"

View file

@ -487,22 +487,23 @@ export default definePlugin({
],
},
{
// Message content renderer
find: "#{intl::MESSAGE_EDITED}",
replacement: [
{
find: ".SEND_FAILED,",
replacement: {
// Render editHistory in the deepest div for message content
match: /(\)\("div",\{id:.+?children:\[)/,
replace:
"$1 (!!arguments[0].message.editHistory?.length && $self.renderEdits(arguments[0])),",
replace: "$1 (!!arguments[0].message.editHistory?.length && $self.renderEdits(arguments[0])),"
}
},
{
find: "#{intl::MESSAGE_EDITED}",
replacement: {
// Make edit marker clickable
match: /"span",\{(?=className:\i\.edited,)/,
replace: "$self.EditMarker,{message:arguments[0].message,",
},
],
replace: "$self.EditMarker,{message:arguments[0].message,"
}
},
{

View file

@ -30,7 +30,7 @@ export default definePlugin({
{
find: "}searchWithoutFetchingLatest(",
replacement: {
match: /searchWithoutFetchingLatest.{20,300}get\((\i).{10,40}?reduce\(\((\i),(\i)\)=>\{/,
match: /\.get\((\i)\)\.nameMatchesChain\(\i\)\.reduce\(\((\i),(\i)\)=>\{/,
replace: "$& if ($self.shouldSkip($1, $3)) return $2;"
}
}

View file

@ -154,7 +154,7 @@ export default definePlugin({
},
// Messages
{
find: "#{intl::MESSAGE_EDITED}",
find: ".SEND_FAILED,",
replacement: {
match: /(?<=isUnsupported\]:(\i)\.isUnsupported\}\),)(?=children:\[)/,
replace: "style:$self.useMessageColorsStyle($1),"

View file

@ -177,7 +177,7 @@ export interface PluginDef {
*/
managedStyle?: string;
userProfileBadge?: ProfileBadge;
userProfileBadges?: ProfileBadge[];
onMessageClick?: MessageClickListener;
onBeforeMessageSend?: MessageSendListener;

View file

@ -39,10 +39,15 @@ async function Unwrap<T>(p: Promise<IpcRes<T>>) {
export async function checkForUpdates() {
changes = await Unwrap(VencordNative.updater.getUpdates());
// we only want to check this for the git updater, not the http updater
if (!IS_STANDALONE) {
if (changes.some(c => c.hash === gitHash)) {
isNewer = true;
return (isOutdated = false);
}
}
return (isOutdated = changes.length > 0);
}