Merge branch 'dev' into modules-proxy-patches
This commit is contained in:
commit
7f3cad2528
|
@ -17,7 +17,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { User } from "discord-types/general";
|
|
||||||
import { ComponentType, HTMLProps } from "react";
|
import { ComponentType, HTMLProps } from "react";
|
||||||
|
|
||||||
import Plugins from "~plugins";
|
import Plugins from "~plugins";
|
||||||
|
@ -79,14 +78,14 @@ export function _getBadges(args: BadgeUserArgs) {
|
||||||
: badges.push({ ...badge, ...args });
|
: badges.push({ ...badge, ...args });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getDonorBadges(args.user.id);
|
const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getDonorBadges(args.userId);
|
||||||
if (donorBadges) badges.unshift(...donorBadges);
|
if (donorBadges) badges.unshift(...donorBadges);
|
||||||
|
|
||||||
return badges;
|
return badges;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BadgeUserArgs {
|
export interface BadgeUserArgs {
|
||||||
user: User;
|
userId: string;
|
||||||
guildId: string;
|
guildId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,11 +131,16 @@ if (!IS_VANILLA) {
|
||||||
|
|
||||||
process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord");
|
process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord");
|
||||||
|
|
||||||
// Monkey patch commandLine to disable WidgetLayering: Fix DevTools context menus https://github.com/electron/electron/issues/38790
|
// Monkey patch commandLine to:
|
||||||
|
// - disable WidgetLayering: Fix DevTools context menus https://github.com/electron/electron/issues/38790
|
||||||
|
// - disable UseEcoQoSForBackgroundProcess: Work around Discord unloading when in background
|
||||||
const originalAppend = app.commandLine.appendSwitch;
|
const originalAppend = app.commandLine.appendSwitch;
|
||||||
app.commandLine.appendSwitch = function (...args) {
|
app.commandLine.appendSwitch = function (...args) {
|
||||||
if (args[0] === "disable-features" && !args[1]?.includes("WidgetLayering")) {
|
if (args[0] === "disable-features") {
|
||||||
args[1] += ",WidgetLayering";
|
const disabledFeatures = new Set((args[1] ?? "").split(","));
|
||||||
|
disabledFeatures.add("WidgetLayering");
|
||||||
|
disabledFeatures.add("UseEcoQoSForBackgroundProcess");
|
||||||
|
args[1] += [...disabledFeatures].join(",");
|
||||||
}
|
}
|
||||||
return originalAppend.apply(this, args);
|
return originalAppend.apply(this, args);
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,18 +18,20 @@
|
||||||
|
|
||||||
import "./fixBadgeOverflow.css";
|
import "./fixBadgeOverflow.css";
|
||||||
|
|
||||||
import { BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges";
|
import { _getBadges, BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges";
|
||||||
import DonateButton from "@components/DonateButton";
|
import DonateButton from "@components/DonateButton";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
import { Heart } from "@components/Heart";
|
import { Heart } from "@components/Heart";
|
||||||
import { openContributorModal } from "@components/PluginSettings/ContributorModal";
|
import { openContributorModal } from "@components/PluginSettings/ContributorModal";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
import { Logger } from "@utils/Logger";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { isPluginDev } from "@utils/misc";
|
import { isPluginDev } from "@utils/misc";
|
||||||
import { closeModal, Modals, openModal } from "@utils/modal";
|
import { closeModal, Modals, openModal } from "@utils/modal";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { Forms, Toasts } from "@webpack/common";
|
import { Forms, Toasts, UserStore } from "@webpack/common";
|
||||||
|
import { User } from "discord-types/general";
|
||||||
|
|
||||||
const CONTRIBUTOR_BADGE = "https://vencord.dev/assets/favicon.png";
|
const CONTRIBUTOR_BADGE = "https://vencord.dev/assets/favicon.png";
|
||||||
|
|
||||||
|
@ -37,8 +39,8 @@ const ContributorBadge: ProfileBadge = {
|
||||||
description: "Vencord Contributor",
|
description: "Vencord Contributor",
|
||||||
image: CONTRIBUTOR_BADGE,
|
image: CONTRIBUTOR_BADGE,
|
||||||
position: BadgePosition.START,
|
position: BadgePosition.START,
|
||||||
shouldShow: ({ user }) => isPluginDev(user.id),
|
shouldShow: ({ userId }) => isPluginDev(userId),
|
||||||
onClick: (_, { user }) => openContributorModal(user)
|
onClick: (_, { userId }) => openContributorModal(UserStore.getUser(userId))
|
||||||
};
|
};
|
||||||
|
|
||||||
let DonorBadges = {} as Record<string, Array<Record<"tooltip" | "badge", string>>>;
|
let DonorBadges = {} as Record<string, Array<Record<"tooltip" | "badge", string>>>;
|
||||||
|
@ -66,7 +68,7 @@ export default definePlugin({
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /&&(\i)\.push\(\{id:"premium".+?\}\);/,
|
match: /&&(\i)\.push\(\{id:"premium".+?\}\);/,
|
||||||
replace: "$&$1.unshift(...Vencord.Api.Badges._getBadges(arguments[0]));",
|
replace: "$&$1.unshift(...$self.getBadges(arguments[0]));",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// alt: "", aria-hidden: false, src: originalSrc
|
// alt: "", aria-hidden: false, src: originalSrc
|
||||||
|
@ -82,7 +84,36 @@ export default definePlugin({
|
||||||
// conditionally override their onClick with badge.onClick if it exists
|
// conditionally override their onClick with badge.onClick if it exists
|
||||||
{
|
{
|
||||||
match: /href:(\i)\.link/,
|
match: /href:(\i)\.link/,
|
||||||
replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, arguments[0]) }),$&"
|
replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
/* new profiles */
|
||||||
|
{
|
||||||
|
find: ".PANEL]:14",
|
||||||
|
replacement: {
|
||||||
|
match: /(?<=(\i)=\(0,\i\.default\)\(\i\);)return 0===\i.length\?/,
|
||||||
|
replace: "$1.unshift(...$self.getBadges(arguments[0].displayProfile));$&"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: ".description,delay:",
|
||||||
|
replacement: [
|
||||||
|
{
|
||||||
|
// alt: "", aria-hidden: false, src: originalSrc
|
||||||
|
match: /alt:" ","aria-hidden":!0,src:(?=.{0,20}(\i)\.icon)/,
|
||||||
|
// ...badge.props, ..., src: badge.image ?? ...
|
||||||
|
replace: "...$1.props,$& $1.image??"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: /(?<=text:(\i)\.description,.{0,50})children:/,
|
||||||
|
replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :"
|
||||||
|
},
|
||||||
|
// conditionally override their onClick with badge.onClick if it exists
|
||||||
|
{
|
||||||
|
match: /href:(\i)\.link/,
|
||||||
|
replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -104,6 +135,17 @@ export default definePlugin({
|
||||||
await loadBadges();
|
await loadBadges();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getBadges(props: { userId: string; user?: User; guildId: string; }) {
|
||||||
|
try {
|
||||||
|
props.userId ??= props.user?.id!;
|
||||||
|
|
||||||
|
return _getBadges(props);
|
||||||
|
} catch (e) {
|
||||||
|
new Logger("BadgeAPI#hasBadges").error(e);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
renderBadgeComponent: ErrorBoundary.wrap((badge: ProfileBadge & BadgeUserArgs) => {
|
renderBadgeComponent: ErrorBoundary.wrap((badge: ProfileBadge & BadgeUserArgs) => {
|
||||||
const Component = badge.component!;
|
const Component = badge.component!;
|
||||||
return <Component {...badge} />;
|
return <Component {...badge} />;
|
||||||
|
|
|
@ -60,6 +60,7 @@ export default definePlugin({
|
||||||
// FIXME: remove once change merged to stable
|
// FIXME: remove once change merged to stable
|
||||||
{
|
{
|
||||||
find: "Messages.ACTIVITY_SETTINGS",
|
find: "Messages.ACTIVITY_SETTINGS",
|
||||||
|
noWarn: true,
|
||||||
replacement: {
|
replacement: {
|
||||||
get match() {
|
get match() {
|
||||||
switch (Settings.plugins.Settings.settingsLocation) {
|
switch (Settings.plugins.Settings.settingsLocation) {
|
||||||
|
|
|
@ -130,9 +130,9 @@ const PlatformIndicator = ({ user, wantMargin = true, wantTopMargin = false, sma
|
||||||
};
|
};
|
||||||
|
|
||||||
const badge: ProfileBadge = {
|
const badge: ProfileBadge = {
|
||||||
component: p => <PlatformIndicator {...p} wantMargin={false} />,
|
component: p => <PlatformIndicator {...p} user={UserStore.getUser(p.userId)} wantMargin={false} />,
|
||||||
position: BadgePosition.START,
|
position: BadgePosition.START,
|
||||||
shouldShow: userInfo => !!Object.keys(getStatus(userInfo.user.id) ?? {}).length,
|
shouldShow: userInfo => !!Object.keys(getStatus(userInfo.userId) ?? {}).length,
|
||||||
key: "indicator"
|
key: "indicator"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,16 @@ const settings = definePluginSettings({
|
||||||
default: true,
|
default: true,
|
||||||
description: "Show role colors in the voice chat user list",
|
description: "Show role colors in the voice chat user list",
|
||||||
restartNeeded: true
|
restartNeeded: true
|
||||||
|
},
|
||||||
|
reactorsList: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: true,
|
||||||
|
description: "Show role colors in the reactors list",
|
||||||
|
restartNeeded: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "RoleColorEverywhere",
|
name: "RoleColorEverywhere",
|
||||||
authors: [Devs.KingFish, Devs.lewisakura, Devs.AutumnVN],
|
authors: [Devs.KingFish, Devs.lewisakura, Devs.AutumnVN],
|
||||||
|
@ -99,6 +106,14 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
predicate: () => settings.store.voiceUsers,
|
predicate: () => settings.store.voiceUsers,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: ".reactorDefault",
|
||||||
|
replacement: {
|
||||||
|
match: /\.openUserContextMenu\)\((\i),(\i),\i\).{0,250}tag:"strong"/,
|
||||||
|
replace: "$&,style:{color:$self.getColor($2?.id,$1)}"
|
||||||
|
},
|
||||||
|
predicate: () => settings.store.reactorsList,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
settings,
|
settings,
|
||||||
|
|
|
@ -74,15 +74,28 @@ interface ConnectionPlatform {
|
||||||
icon: { lightSVG: string, darkSVG: string; };
|
icon: { lightSVG: string, darkSVG: string; };
|
||||||
}
|
}
|
||||||
|
|
||||||
const profilePopoutComponent = ErrorBoundary.wrap((props: { user: User, displayProfile; }) =>
|
const profilePopoutComponent = ErrorBoundary.wrap(
|
||||||
<ConnectionsComponent id={props.user.id} theme={getProfileThemeProps(props).theme} />
|
(props: { user: User; displayProfile?: any; simplified?: boolean; }) => (
|
||||||
|
<ConnectionsComponent
|
||||||
|
{...props}
|
||||||
|
id={props.user.id}
|
||||||
|
theme={getProfileThemeProps(props).theme}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
{ noop: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const profilePanelComponent = ErrorBoundary.wrap(({ id }: { id: string; }) =>
|
const profilePanelComponent = ErrorBoundary.wrap(
|
||||||
<ConnectionsComponent id={id} theme={ThemeStore.theme} />
|
(props: { id: string; simplified?: boolean; }) => (
|
||||||
|
<ConnectionsComponent
|
||||||
|
{...props}
|
||||||
|
theme={ThemeStore.theme}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
{ noop: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
function ConnectionsComponent({ id, theme }: { id: string, theme: string; }) {
|
function ConnectionsComponent({ id, theme, simplified }: { id: string, theme: string, simplified?: boolean; }) {
|
||||||
const profile = UserProfileStore.getUserProfile(id);
|
const profile = UserProfileStore.getUserProfile(id);
|
||||||
if (!profile)
|
if (!profile)
|
||||||
return null;
|
return null;
|
||||||
|
@ -91,6 +104,19 @@ function ConnectionsComponent({ id, theme }: { id: string, theme: string; }) {
|
||||||
if (!connections?.length)
|
if (!connections?.length)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
const connectionsContainer = (
|
||||||
|
<Flex style={{
|
||||||
|
marginTop: !simplified ? "8px" : undefined,
|
||||||
|
gap: getSpacingPx(settings.store.iconSpacing),
|
||||||
|
flexWrap: "wrap"
|
||||||
|
}}>
|
||||||
|
{connections.map(connection => <CompactConnectionComponent connection={connection} theme={theme} />)}
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (simplified)
|
||||||
|
return connectionsContainer;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Section>
|
<Section>
|
||||||
<Text
|
<Text
|
||||||
|
@ -100,13 +126,7 @@ function ConnectionsComponent({ id, theme }: { id: string, theme: string; }) {
|
||||||
>
|
>
|
||||||
Connections
|
Connections
|
||||||
</Text>
|
</Text>
|
||||||
<Flex style={{
|
{connectionsContainer}
|
||||||
marginTop: "8px",
|
|
||||||
gap: getSpacingPx(settings.store.iconSpacing),
|
|
||||||
flexWrap: "wrap"
|
|
||||||
}}>
|
|
||||||
{connections.map(connection => <CompactConnectionComponent connection={connection} theme={theme} />)}
|
|
||||||
</Flex>
|
|
||||||
</Section>
|
</Section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +152,7 @@ function CompactConnectionComponent({ connection, theme }: { connection: Connect
|
||||||
<Tooltip
|
<Tooltip
|
||||||
text={
|
text={
|
||||||
<span className="vc-sc-tooltip">
|
<span className="vc-sc-tooltip">
|
||||||
{connection.name}
|
<span className="vc-sc-connection-name">{connection.name}</span>
|
||||||
{connection.verified && <VerifiedIcon />}
|
{connection.verified && <VerifiedIcon />}
|
||||||
<TooltipIcon height={16} width={16} />
|
<TooltipIcon height={16} width={16} />
|
||||||
</span>
|
</span>
|
||||||
|
@ -188,6 +208,13 @@ export default definePlugin({
|
||||||
match: /\(0,\i\.jsx\)\(\i\.\i,\{\}\).{0,100}setNote:(?=.+?channelId:(\i).id)/,
|
match: /\(0,\i\.jsx\)\(\i\.\i,\{\}\).{0,100}setNote:(?=.+?channelId:(\i).id)/,
|
||||||
replace: "$self.profilePanelComponent({ id: $1.recipients[0] }),$&"
|
replace: "$self.profilePanelComponent({ id: $1.recipients[0] }),$&"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: "autoFocusNote:!0})",
|
||||||
|
replacement: {
|
||||||
|
match: /{autoFocusNote:!1}\)}\)(?<=user:(\i),bio:null==(\i)\?.+?)/,
|
||||||
|
replace: "$&,$self.profilePopoutComponent({ user: $1, displayProfile: $2, simplified: true })"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
settings,
|
settings,
|
||||||
|
|
|
@ -9,3 +9,11 @@
|
||||||
gap: 0.25em;
|
gap: 0.25em;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vc-sc-connection-name {
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-sc-tooltip svg {
|
||||||
|
min-width: 16px;
|
||||||
|
}
|
||||||
|
|
|
@ -69,13 +69,6 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
find: "=!1,canUsePremiumCustomization:",
|
|
||||||
replacement: {
|
|
||||||
match: /(\i)\.premiumType/,
|
|
||||||
replace: "$self.patchPremiumType($1)||$&"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: "BannerLoadingStatus:function",
|
find: "BannerLoadingStatus:function",
|
||||||
replacement: {
|
replacement: {
|
||||||
|
|
Loading…
Reference in a new issue