mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-17 02:17:03 -04:00
Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
f3ec0d86eb
13 changed files with 111 additions and 59 deletions
|
@ -22,7 +22,7 @@ import { Devs } from "@utils/constants";
|
|||
import { Margins } from "@utils/margins";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByCodeLazy, findLazy } from "@webpack";
|
||||
import { Card, ChannelStore, Forms, GuildStore, PermissionsBits, Switch, TextInput, Tooltip, useState } from "@webpack/common";
|
||||
import { Card, ChannelStore, Forms, GuildStore, PermissionsBits, Switch, TextInput, Tooltip } from "@webpack/common";
|
||||
import type { Permissions, RC } from "@webpack/types";
|
||||
import type { Channel, Guild, Message, User } from "discord-types/general";
|
||||
|
||||
|
@ -107,14 +107,8 @@ const defaultSettings = Object.fromEntries(
|
|||
tags.map(({ name, displayName }) => [name, { text: displayName, showInChat: true, showInNotChat: true }])
|
||||
) as TagSettings;
|
||||
|
||||
function SettingsComponent(props: { setValue(v: any): void; }) {
|
||||
settings.store.tagSettings ??= defaultSettings;
|
||||
|
||||
const [tagSettings, setTagSettings] = useState(settings.store.tagSettings as TagSettings);
|
||||
const setValue = (v: TagSettings) => {
|
||||
setTagSettings(v);
|
||||
props.setValue(v);
|
||||
};
|
||||
function SettingsComponent() {
|
||||
const tagSettings = settings.store.tagSettings ??= defaultSettings;
|
||||
|
||||
return (
|
||||
<Flex flexDirection="column">
|
||||
|
@ -137,19 +131,13 @@ function SettingsComponent(props: { setValue(v: any): void; }) {
|
|||
type="text"
|
||||
value={tagSettings[t.name]?.text ?? t.displayName}
|
||||
placeholder={`Text on tag (default: ${t.displayName})`}
|
||||
onChange={v => {
|
||||
tagSettings[t.name].text = v;
|
||||
setValue(tagSettings);
|
||||
}}
|
||||
onChange={v => tagSettings[t.name].text = v}
|
||||
className={Margins.bottom16}
|
||||
/>
|
||||
|
||||
<Switch
|
||||
value={tagSettings[t.name]?.showInChat ?? true}
|
||||
onChange={v => {
|
||||
tagSettings[t.name].showInChat = v;
|
||||
setValue(tagSettings);
|
||||
}}
|
||||
onChange={v => tagSettings[t.name].showInChat = v}
|
||||
hideBorder
|
||||
>
|
||||
Show in messages
|
||||
|
@ -157,10 +145,7 @@ function SettingsComponent(props: { setValue(v: any): void; }) {
|
|||
|
||||
<Switch
|
||||
value={tagSettings[t.name]?.showInNotChat ?? true}
|
||||
onChange={v => {
|
||||
tagSettings[t.name].showInNotChat = v;
|
||||
setValue(tagSettings);
|
||||
}}
|
||||
onChange={v => tagSettings[t.name].showInNotChat = v}
|
||||
hideBorder
|
||||
>
|
||||
Show in member list and profiles
|
||||
|
@ -183,7 +168,7 @@ const settings = definePluginSettings({
|
|||
tagSettings: {
|
||||
type: OptionType.COMPONENT,
|
||||
component: SettingsComponent,
|
||||
description: "fill me",
|
||||
description: "fill me"
|
||||
}
|
||||
});
|
||||
|
||||
|
|
3
src/plugins/noMaskedUrlPaste/README.md
Normal file
3
src/plugins/noMaskedUrlPaste/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# NoMaskedUrlPaste
|
||||
|
||||
Pasting a link while you have text selected will NOT paste your link as a masked link.
|
23
src/plugins/noMaskedUrlPaste/index.ts
Normal file
23
src/plugins/noMaskedUrlPaste/index.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { Devs } from "@utils/constants.js";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
export default definePlugin({
|
||||
name: "NoMaskedUrlPaste",
|
||||
authors: [Devs.CatNoir],
|
||||
description: "Pasting a link while having text selected will not paste as masked URL",
|
||||
patches: [
|
||||
{
|
||||
find: ".selection,preventEmojiSurrogates:",
|
||||
replacement: {
|
||||
match: /if\(null!=\i.selection&&\i.\i.isExpanded\(\i.selection\)\)/,
|
||||
replace: "if(false)"
|
||||
}
|
||||
}
|
||||
],
|
||||
});
|
|
@ -19,7 +19,6 @@
|
|||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { UserStore } from "@webpack/common";
|
||||
import virtualMerge from "virtual-merge";
|
||||
|
||||
export default definePlugin({
|
||||
name: "NoProfileThemes",
|
||||
|
@ -33,21 +32,7 @@ export default definePlugin({
|
|||
replace: "$&$self.isCurrentUser(this.userId)&&"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: "UserProfileStore",
|
||||
replacement: {
|
||||
match: /(?<=getUserProfile\(\i\){return )(.+?)(?=})/,
|
||||
replace: "$self.removeProfileThemes($1)"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
isCurrentUser: (userId: string) => userId === UserStore.getCurrentUser()?.id,
|
||||
removeProfileThemes: (displayProfile: any) => {
|
||||
if (displayProfile == null) return displayProfile;
|
||||
|
||||
return displayProfile.userId === UserStore.getCurrentUser()?.id
|
||||
? displayProfile
|
||||
: virtualMerge(displayProfile, { banner: undefined, profileEffectId: undefined });
|
||||
}
|
||||
});
|
||||
|
|
|
@ -26,11 +26,6 @@ import { CompactPronounsChatComponentWrapper, PronounsChatComponentWrapper } fro
|
|||
import { useProfilePronouns } from "./pronoundbUtils";
|
||||
import { settings } from "./settings";
|
||||
|
||||
const PRONOUN_TOOLTIP_PATCH = {
|
||||
match: /text:(.{0,10}.Messages\.USER_PROFILE_PRONOUNS)(?=,)/,
|
||||
replace: '$& + (typeof vcPronounSource !== "undefined" ? ` (${vcPronounSource})` : "")'
|
||||
};
|
||||
|
||||
export default definePlugin({
|
||||
name: "PronounDB",
|
||||
authors: [Devs.Tyman, Devs.TheKodeToad, Devs.Ven, Devs.Elvyra],
|
||||
|
@ -53,7 +48,24 @@ export default definePlugin({
|
|||
]
|
||||
},
|
||||
|
||||
// @TODO Patch discord pronoun hook in user profiles (useProfilePronouns)
|
||||
{
|
||||
find: ".Messages.USER_PROFILE_PRONOUNS",
|
||||
group: true,
|
||||
replacement: [
|
||||
{
|
||||
match: /\.PANEL},/,
|
||||
replace: "$&[vcPronoun,vcPronounSource,vcHasPendingPronouns]=$self.useProfilePronouns(arguments[0].user?.id),"
|
||||
},
|
||||
{
|
||||
match: /text:\i\.\i.Messages.USER_PROFILE_PRONOUNS/,
|
||||
replace: '$&+vcHasPendingPronouns?"":` (${vcPronounSource})`'
|
||||
},
|
||||
{
|
||||
match: /(\.pronounsText.+?children:)(\i)/,
|
||||
replace: "$1vcHasPendingPronouns?$2:vcPronoun"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
settings,
|
||||
|
|
|
@ -21,13 +21,16 @@ import { debounce } from "@shared/debounce";
|
|||
import { VENCORD_USER_AGENT } from "@shared/vencordUserAgent";
|
||||
import { getCurrentChannel } from "@utils/discord";
|
||||
import { useAwaiter } from "@utils/react";
|
||||
import { findStoreLazy } from "@webpack";
|
||||
import { UserProfileStore, UserStore } from "@webpack/common";
|
||||
|
||||
import { settings } from "./settings";
|
||||
import { CachePronouns, PronounCode, PronounMapping, PronounsResponse } from "./types";
|
||||
|
||||
type PronounsWithSource = [string | null, string];
|
||||
const EmptyPronouns: PronounsWithSource = [null, ""];
|
||||
const UserSettingsAccountStore = findStoreLazy("UserSettingsAccountStore");
|
||||
|
||||
type PronounsWithSource = [pronouns: string | null, source: string, hasPendingPronouns: boolean];
|
||||
const EmptyPronouns: PronounsWithSource = [null, "", false];
|
||||
|
||||
export const enum PronounsFormat {
|
||||
Lowercase = "LOWERCASE",
|
||||
|
@ -75,13 +78,15 @@ export function useFormattedPronouns(id: string, useGlobalProfile: boolean = fal
|
|||
onError: e => console.error("Fetching pronouns failed: ", e)
|
||||
});
|
||||
|
||||
const hasPendingPronouns = UserSettingsAccountStore.getPendingPronouns() != null;
|
||||
|
||||
if (settings.store.pronounSource === PronounSource.PreferDiscord && discordPronouns)
|
||||
return [discordPronouns, "Discord"];
|
||||
return [discordPronouns, "Discord", hasPendingPronouns];
|
||||
|
||||
if (result && result !== PronounMapping.unspecified)
|
||||
return [result, "PronounDB"];
|
||||
return [result, "PronounDB", hasPendingPronouns];
|
||||
|
||||
return [discordPronouns, "Discord"];
|
||||
return [discordPronouns, "Discord", hasPendingPronouns];
|
||||
}
|
||||
|
||||
export function useProfilePronouns(id: string, useGlobalProfile: boolean = false): PronounsWithSource {
|
||||
|
@ -148,7 +153,7 @@ async function bulkFetchPronouns(ids: string[]): Promise<PronounsResponse> {
|
|||
}
|
||||
}
|
||||
|
||||
export function extractPronouns(pronounSet?: { [locale: string]: PronounCode[] }): string {
|
||||
export function extractPronouns(pronounSet?: { [locale: string]: PronounCode[]; }): string {
|
||||
if (!pronounSet || !pronounSet.en) return PronounMapping.unspecified;
|
||||
// PronounDB returns an empty set instead of {sets: {en: ["unspecified"]}}.
|
||||
const pronouns = pronounSet.en;
|
||||
|
|
|
@ -96,10 +96,24 @@ export default definePlugin({
|
|||
{
|
||||
find: ".BITE_SIZE,user:",
|
||||
replacement: {
|
||||
match: /(?<=\.BITE_SIZE,children:\[)\(0,\i\.jsx\)\(\i\.\i,\{user:(\i),/,
|
||||
replace: "$self.BiteSizeReviewsButton({user:$1}),$&"
|
||||
match: /{profileType:\i\.\i\.BITE_SIZE,children:\[/,
|
||||
replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user}),"
|
||||
},
|
||||
predicate: () => settings.store.preferButtonOverDropdown
|
||||
},
|
||||
{
|
||||
find: ".FULL_SIZE,user:",
|
||||
replacement: {
|
||||
match: /{profileType:\i\.\i\.FULL_SIZE,children:\[/,
|
||||
replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user}),"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: ".PANEL,isInteractionSource:",
|
||||
replacement: {
|
||||
match: /{profileType:\i\.\i\.PANEL,children:\[/,
|
||||
replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user}),"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ export default definePlugin({
|
|||
|
||||
patches: [
|
||||
{
|
||||
find: '"BiteSizeProfileBody"',
|
||||
find: ".hasAvatarForGuild(null==",
|
||||
replacement: {
|
||||
match: /currentUser:\i,guild:\i}\)(?<=user:(\i),bio:null==(\i)\?.+?)/,
|
||||
replace: "$&,$self.profilePopoutComponent({ user: $1, displayProfile: $2 })"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue