mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-19 11:27:02 -04:00
ShowMeYourName Extra Settings & Fix WhosWatching
This commit is contained in:
parent
0d09c083c6
commit
efd1821fad
3 changed files with 53 additions and 24 deletions
|
@ -11,8 +11,8 @@ import { makeRange } from "@components/PluginSettings/components";
|
|||
import { debounce } from "@shared/debounce";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy, findByCode, findByProps } from "@webpack";
|
||||
import { ChannelStore, ContextMenuApi, GuildStore, IconUtils, Menu, ChannelRouter, PermissionStore, React, SelectedChannelStore, PermissionsBits, Toasts, UserStore } from "@webpack/common";
|
||||
import { findByCode, findByProps, findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
||||
import { ChannelRouter, ChannelStore, ContextMenuApi, GuildStore, Menu, PermissionsBits, PermissionStore, React, SelectedChannelStore, Toasts, UserStore } from "@webpack/common";
|
||||
|
||||
import style from "./styles.css?managed";
|
||||
|
||||
|
@ -177,7 +177,7 @@ export default definePlugin({
|
|||
}
|
||||
],
|
||||
flux: {
|
||||
VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[] }) {
|
||||
VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) {
|
||||
const currentUserId = UserStore.getCurrentUser().id;
|
||||
const myChannelId = VoiceStateStore.getVoiceStateForUser(currentUserId)?.channelId;
|
||||
if (!myChannelId || !settings.store.leaveEmpty) return;
|
||||
|
@ -188,7 +188,7 @@ export default definePlugin({
|
|||
);
|
||||
|
||||
if (othersInChannel.length === 0) {
|
||||
randomVoice()
|
||||
randomVoice();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
@ -82,10 +82,9 @@ export default definePlugin({
|
|||
}
|
||||
},
|
||||
{
|
||||
predicate: () => settings.store.showPanel,
|
||||
find: "this.renderEmbeddedActivity()",
|
||||
replacement: {
|
||||
match: /(?<=children.{0,50})"div"(?=.{0,500}this\.renderEmbeddedActivity\(\))/,
|
||||
match: /(?<=render\(\).{0,500}children.{0,50})"div"(?=.{0,500}this\.renderEmbeddedActivity\(\))/,
|
||||
replace: "$self.WrapperComponent"
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +117,7 @@ export default definePlugin({
|
|||
return (
|
||||
<>
|
||||
<div {...props}>{props.children}</div>
|
||||
<div className={classes(cl("spectators_panel"), Margins.top8)} style={{ marginLeft: 8 }}>
|
||||
<div className={classes(cl("spectators_panel"), Margins.top8)}>
|
||||
<Forms.FormTitle tag="h3" style={{ marginTop: 8, marginBottom: 0, textTransform: "uppercase" }}>
|
||||
{getIntlMessage("SPECTATORS", { numViewers: userIds.length })}
|
||||
</Forms.FormTitle>
|
||||
|
|
|
@ -45,9 +45,26 @@ const settings = definePluginSettings({
|
|||
type: OptionType.BOOLEAN,
|
||||
default: false,
|
||||
description: "Use friend names in place of usernames (overrides Display Names option if applicable)"
|
||||
}
|
||||
},
|
||||
memberList: {
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true,
|
||||
description: "Show usernames in member list",
|
||||
},
|
||||
voiceChannelList: {
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true,
|
||||
description: "Show usernames in voice channel list",
|
||||
},
|
||||
});
|
||||
|
||||
function getUsername(user: any): string {
|
||||
const friendName = RelationshipStore.getNickname(user.id);
|
||||
if (settings.store.preferFriend && friendName) return friendName;
|
||||
if (settings.store.displayNames) return user.globalName || user.username;
|
||||
return user.username;
|
||||
}
|
||||
|
||||
export default definePlugin({
|
||||
name: "ShowMeYourName",
|
||||
description: "Display usernames next to nicks, or no nicks at all",
|
||||
|
@ -61,18 +78,31 @@ export default definePlugin({
|
|||
replace: "$self.renderUsername(arguments[0])"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: "._areActivitiesExperimentallyHidden=(",
|
||||
replacement: {
|
||||
match: /(?<=user:(\i),currentUser:\i,nick:)\i/,
|
||||
replace: "$self.getUsername($1)"
|
||||
},
|
||||
predicate: () => settings.store.memberList
|
||||
},
|
||||
{
|
||||
find: ".usernameSpeaking]",
|
||||
predicate: () => settings.store.voiceChannelList,
|
||||
replacement: [
|
||||
{
|
||||
match: /(?<=children:\[null!=\i\?)\i(?=:\i\.\i\.getName\((\i)\))/,
|
||||
replace: "$self.getUsername($1)"
|
||||
},
|
||||
]
|
||||
},
|
||||
],
|
||||
settings,
|
||||
|
||||
getUsername,
|
||||
renderUsername: ErrorBoundary.wrap(({ author, message, isRepliedMessage, withMentionPrefix, userOverride }: UsernameProps) => {
|
||||
try {
|
||||
const user = userOverride ?? message.author;
|
||||
const friendName = RelationshipStore.getNickname(user.id);
|
||||
let { username } = user;
|
||||
if (settings.store.displayNames)
|
||||
username = (user as any).globalName || username;
|
||||
if (settings.store.preferFriend)
|
||||
username = friendName ?? username;
|
||||
const username = getUsername(user);
|
||||
|
||||
const { nick } = author;
|
||||
const prefix = withMentionPrefix ? "@" : "";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue