Fix Constants & Merge Dev

This commit is contained in:
thororen1234 2024-09-08 12:48:22 -04:00
commit d83abb7437
7 changed files with 161 additions and 15 deletions

View file

@ -8,6 +8,7 @@ import "./style.css";
import { classNameFactory } from "@api/Styles";
import { Button, ButtonLooks, GuildStore, useStateFromStores } from "@webpack/common";
import { HiddenServersStore } from "../HiddenServersStore";
import { openHiddenServersModal } from "./HiddenServersMenu";

View file

@ -17,7 +17,7 @@ import {
openModal,
} from "@utils/modal";
import { findByPropsLazy } from "@webpack";
import { Button, Forms, IconUtils, Text, useState, useStateFromStores } from "@webpack/common";
import { Button, Forms, IconUtils, Text, useStateFromStores } from "@webpack/common";
import { Guild } from "discord-types/general";
import { HiddenServersStore } from "../HiddenServersStore";
@ -91,7 +91,7 @@ export function HiddenServersMenu({ servers }: { servers: Guild[]; }) {
</Text>
)}
</div>;
};
}
export function openHiddenServersModal() {
const key = openModal(modalProps => {

View file

@ -0,0 +1,7 @@
# AccountPanelServerProfile
Right click your account panel in the bottom left to view your profile in the current server
![](https://github.com/user-attachments/assets/3228497d-488f-479c-93d2-a32ccdb08f0f)
![](https://github.com/user-attachments/assets/6fc45363-d95f-4810-812f-2f9fb28b41b5)

View file

@ -0,0 +1,134 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { definePluginSettings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import { getCurrentChannel } from "@utils/discord";
import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
import { ContextMenuApi, Menu, useEffect, useRef } from "@webpack/common";
import { User } from "discord-types/general";
interface UserProfileProps {
popoutProps: Record<string, any>;
currentUser: User;
originalPopout: () => React.ReactNode;
}
const UserProfile = findComponentByCodeLazy("UserProfilePopoutWrapper: user cannot be undefined");
const styles = findByPropsLazy("accountProfilePopoutWrapper");
let openAlternatePopout = false;
let accountPanelRef: React.MutableRefObject<Record<PropertyKey, any> | null> = { current: null };
const AccountPanelContextMenu = ErrorBoundary.wrap(() => {
const { prioritizeServerProfile } = settings.use(["prioritizeServerProfile"]);
return (
<Menu.Menu
navId="vc-ap-server-profile"
onClose={ContextMenuApi.closeContextMenu}
>
<Menu.MenuItem
id="vc-ap-view-alternate-popout"
label={prioritizeServerProfile ? "View Account Profile" : "View Server Profile"}
disabled={getCurrentChannel()?.getGuildId() == null}
action={e => {
openAlternatePopout = true;
accountPanelRef.current?.props.onMouseDown();
accountPanelRef.current?.props.onClick(e);
}}
/>
<Menu.MenuCheckboxItem
id="vc-ap-prioritize-server-profile"
label="Prioritize Server Profile"
checked={prioritizeServerProfile}
action={() => settings.store.prioritizeServerProfile = !prioritizeServerProfile}
/>
</Menu.Menu>
);
}, { noop: true });
const settings = definePluginSettings({
prioritizeServerProfile: {
type: OptionType.BOOLEAN,
description: "Prioritize Server Profile when left clicking your account panel",
default: false
}
});
export default definePlugin({
name: "AccountPanelServerProfile",
description: "Right click your account panel in the bottom left to view your profile in the current server",
authors: [Devs.Nuckyz, Devs.relitrix],
settings,
patches: [
{
find: ".Messages.ACCOUNT_SPEAKING_WHILE_MUTED",
group: true,
replacement: [
{
match: /(?<=\.SIZE_32\)}\);)/,
replace: "$self.useAccountPanelRef();"
},
{
match: /(\.AVATAR,children:.+?renderPopout:(\i)=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/,
replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},originalPopout:()=>{${originalPopout}}})`
},
{
match: /\.AVATAR,children:.+?(?=renderPopout:)/,
replace: "$&onRequestClose:$self.onPopoutClose,"
},
{
match: /(?<=.avatarWrapper,)/,
replace: "ref:$self.accountPanelRef,onContextMenu:$self.openAccountPanelContextMenu,"
}
]
}
],
get accountPanelRef() {
return accountPanelRef;
},
useAccountPanelRef() {
useEffect(() => () => {
accountPanelRef.current = null;
}, []);
return (accountPanelRef = useRef(null));
},
openAccountPanelContextMenu(event: React.UIEvent) {
ContextMenuApi.openContextMenu(event, AccountPanelContextMenu);
},
onPopoutClose() {
openAlternatePopout = false;
},
UserProfile: ErrorBoundary.wrap(({ popoutProps, currentUser, originalPopout }: UserProfileProps) => {
if (
(settings.store.prioritizeServerProfile && openAlternatePopout) ||
(!settings.store.prioritizeServerProfile && !openAlternatePopout)
) {
return originalPopout();
}
const currentChannel = getCurrentChannel();
if (currentChannel?.getGuildId() == null) {
return originalPopout();
}
return (
<div className={styles.accountProfilePopoutWrapper}>
<UserProfile {...popoutProps} userId={currentUser.id} guildId={currentChannel.getGuildId()} channelId={currentChannel.id} />
</div>
);
}, { noop: true })
});

View file

@ -88,7 +88,7 @@ export const userContextPatch: NavContextMenuPatchCallback = (children, { user }
export default definePlugin({
name: "BiggerStreamPreview",
description: "This plugin allows you to enlarge stream previews",
authors: [Devs.philhk],
authors: [Devs.phil],
contextMenus: {
"user-context": userContextPatch,
"stream-context": streamContextPatch

View file

@ -19,7 +19,7 @@
import "./styles.css";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import { Devs, EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types";
import VoiceActivityIcon from "./components/VoiceActivityIcon";
@ -29,7 +29,7 @@ import { VoiceActivityProps } from "./types";
export default definePlugin({
name: "UserVoiceShow",
description: "Shows users' voice activity information in profiles and members lists",
authors: [Devs.LordElias, Devs.llytz],
authors: [Devs.LordElias, EquicordDevs.llytz],
tags: ["voice", "activity"],
settings,

View file

@ -321,8 +321,8 @@ export const Devs = /* #__PURE__*/ Object.freeze({
name: "amia",
id: 142007603549962240n
},
philhk: {
name: "philhk",
phil: {
name: "phil",
id: 305288513941667851n
},
ImLvna: {
@ -523,7 +523,7 @@ export const Devs = /* #__PURE__*/ Object.freeze({
},
nyx: {
name: "verticalsync",
id: 1207087393929171095n
id: 328165170536775680n
},
nekohaxx: {
name: "nekohaxx",
@ -557,9 +557,9 @@ export const Devs = /* #__PURE__*/ Object.freeze({
name: "Lumap",
id: 585278686291427338n,
},
llytz: {
name: "llytz",
id: 1271128098301022240n
Obsidian: {
name: "Obsidian",
id: 683171006717755446n,
},
SerStars: {
name: "SerStars",
@ -569,9 +569,9 @@ export const Devs = /* #__PURE__*/ Object.freeze({
name: "niko",
id: 341377368075796483n,
},
Obsidian: {
name: "Obsidian",
id: 683171006717755446n,
relitrix: {
name: "Relitrix",
id: 423165393901715456n,
},
RamziAH: {
name: "RamziAH",
@ -791,7 +791,11 @@ export const EquicordDevs = Object.freeze({
bep: {
name: "bep",
id: 0n,
}
},
llytz: {
name: "llytz",
id: 1271128098301022240n
},
} satisfies Record<string, Dev>);
// iife so #__PURE__ works correctly