mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 18:06:22 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
9538ae4995
10 changed files with 64 additions and 66 deletions
|
@ -247,7 +247,7 @@ function FullPatchInput({ setFind, setParsedFind, setMatch, setReplacement }: Fu
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const parsed = (0, eval)(`(${fullPatch})`) as Patch;
|
const parsed = (0, eval)(`([${fullPatch}][0])`) as Patch;
|
||||||
|
|
||||||
if (!parsed.find) throw new Error("No 'find' field");
|
if (!parsed.find) throw new Error("No 'find' field");
|
||||||
if (!parsed.replacement) throw new Error("No 'replacement' field");
|
if (!parsed.replacement) throw new Error("No 'replacement' field");
|
||||||
|
|
|
@ -59,15 +59,7 @@ export default definePlugin({
|
||||||
replace: "$&return;"
|
replace: "$&return;"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
{
|
|
||||||
find: ".installedLogHooks)",
|
|
||||||
replacement: {
|
|
||||||
// if getDebugLogging() returns false, the hooks don't get installed.
|
|
||||||
match: "getDebugLogging(){",
|
|
||||||
replace: "getDebugLogging(){return false;"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
|
|
||||||
startAt: StartAt.Init,
|
startAt: StartAt.Init,
|
||||||
|
|
|
@ -275,16 +275,16 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
makeGuildsBarGuildListFilter(isBetterFolders: boolean) {
|
makeGuildsBarGuildListFilter(isBetterFolders: boolean) {
|
||||||
try {
|
|
||||||
return child => {
|
return child => {
|
||||||
if (isBetterFolders) {
|
if (isBetterFolders) {
|
||||||
return child?.props?.["aria-label"] === getIntlMessage("SERVERS");
|
try {
|
||||||
|
return child?.props?.["aria-label"] === getIntlMessage("SERVERS");
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
} catch {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
makeGuildsBarTreeFilter(isBetterFolders: boolean) {
|
makeGuildsBarTreeFilter(isBetterFolders: boolean) {
|
||||||
|
|
|
@ -147,5 +147,5 @@ export default definePlugin({
|
||||||
replace: "$self.NoopLogger()"
|
replace: "$self.NoopLogger()"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,7 +28,7 @@ import { getIntlMessage } from "@utils/discord";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { ChannelStore, FluxDispatcher, Menu, MessageStore, Parser, SelectedChannelStore, Timestamp, UserStore, useStateFromStores } from "@webpack/common";
|
import { ChannelStore, FluxDispatcher, Menu, MessageStore, Parser, SelectedChannelStore, Timestamp, UserStore, useStateFromStores } from "@webpack/common";
|
||||||
import { Message } from "discord-types/general";
|
import { Message } from "discord-types/general";
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ interface MLMessage extends Message {
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = findByPropsLazy("edited", "communicationDisabled", "isSystemMessage");
|
const styles = findByPropsLazy("edited", "communicationDisabled", "isSystemMessage");
|
||||||
const getMessage = findByCodeLazy('replace(/^\\n+|\\n+$/g,"")');
|
|
||||||
|
|
||||||
function addDeleteStyle() {
|
function addDeleteStyle() {
|
||||||
if (Settings.plugins.MessageLogger.deleteStyle === "text") {
|
if (Settings.plugins.MessageLogger.deleteStyle === "text") {
|
||||||
|
@ -312,35 +311,33 @@ export default definePlugin({
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
Messages: {
|
// DELETED_MESSAGE_COUNT: getMessage("{count, plural, =0 {No deleted messages} one {{count} deleted message} other {{count} deleted messages}}")
|
||||||
// DELETED_MESSAGE_COUNT: getMessage("{count, plural, =0 {No deleted messages} one {{count} deleted message} other {{count} deleted messages}}")
|
// TODO: Find a better way to generate intl messages
|
||||||
// TODO: find a better way to generate intl messages
|
DELETED_MESSAGE_COUNT: () => ({
|
||||||
DELETED_MESSAGE_COUNT: () => ({
|
ast: [[
|
||||||
ast: [[
|
6,
|
||||||
6,
|
"count",
|
||||||
"count",
|
{
|
||||||
{
|
"=0": ["No deleted messages"],
|
||||||
"=0": ["No deleted messages"],
|
one: [
|
||||||
one: [
|
[
|
||||||
[
|
1,
|
||||||
1,
|
"count"
|
||||||
"count"
|
|
||||||
],
|
|
||||||
" deleted message"
|
|
||||||
],
|
],
|
||||||
other: [
|
" deleted message"
|
||||||
[
|
],
|
||||||
1,
|
other: [
|
||||||
"count"
|
[
|
||||||
],
|
1,
|
||||||
" deleted messages"
|
"count"
|
||||||
]
|
],
|
||||||
},
|
" deleted messages"
|
||||||
0,
|
]
|
||||||
"cardinal"
|
},
|
||||||
]]
|
0,
|
||||||
})
|
"cardinal"
|
||||||
},
|
]]
|
||||||
|
}),
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
|
@ -531,7 +528,7 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /(\i).type===\i\.\i\.MESSAGE_GROUP_BLOCKED\?.*?:/,
|
match: /(\i).type===\i\.\i\.MESSAGE_GROUP_BLOCKED\?.*?:/,
|
||||||
replace: '$&$1.type==="MESSAGE_GROUP_DELETED"?$self.Messages.DELETED_MESSAGE_COUNT:',
|
replace: '$&$1.type==="MESSAGE_GROUP_DELETED"?$self.DELETED_MESSAGE_COUNT:',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
predicate: () => Settings.plugins.MessageLogger.collapseDeleted
|
predicate: () => Settings.plugins.MessageLogger.collapseDeleted
|
||||||
|
|
|
@ -28,8 +28,8 @@ import { Message } from "discord-types/general";
|
||||||
const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");
|
const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");
|
||||||
|
|
||||||
interface MessageDeleteProps {
|
interface MessageDeleteProps {
|
||||||
// i18n message i18n.t["+FcYMz"] if deleted, with args
|
// Internal intl message for BLOCKED_MESSAGE_COUNT
|
||||||
collapsedReason: () => any
|
collapsedReason: () => any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
|
|
|
@ -50,6 +50,8 @@ async function runMigrations() {
|
||||||
|
|
||||||
export async function syncAndRunChecks() {
|
export async function syncAndRunChecks() {
|
||||||
await runMigrations();
|
await runMigrations();
|
||||||
|
if (UserStore.getCurrentUser() == null) return;
|
||||||
|
|
||||||
const [oldGuilds, oldGroups, oldFriends] = await DataStore.getMany([
|
const [oldGuilds, oldGroups, oldFriends] = await DataStore.getMany([
|
||||||
guildsKey(),
|
guildsKey(),
|
||||||
groupsKey(),
|
groupsKey(),
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { Devs } from "@utils/constants";
|
||||||
import { getIntlMessage } from "@utils/discord";
|
import { getIntlMessage } from "@utils/discord";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findComponentByCodeLazy, findExportedComponentLazy, findStoreLazy } from "@webpack";
|
import { findComponentByCodeLazy, findExportedComponentLazy, findStoreLazy } from "@webpack";
|
||||||
import { ChannelStore, GuildMemberStore, RelationshipStore, SelectedChannelStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common";
|
import { GuildMemberStore, RelationshipStore, SelectedChannelStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common";
|
||||||
|
|
||||||
import { buildSeveralUsers } from "../typingTweaks";
|
import { buildSeveralUsers } from "../typingTweaks";
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ function getDisplayName(guildId: string, userId: string) {
|
||||||
return GuildMemberStore.getNick(guildId, userId) ?? (user as any).globalName ?? user.username;
|
return GuildMemberStore.getNick(guildId, userId) ?? (user as any).globalName ?? user.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
function TypingIndicator({ channelId }: { channelId: string; }) {
|
function TypingIndicator({ channelId, guildId }: { channelId: string; guildId: string; }) {
|
||||||
const typingUsers: Record<string, number> = useStateFromStores(
|
const typingUsers: Record<string, number> = useStateFromStores(
|
||||||
[TypingStore],
|
[TypingStore],
|
||||||
() => ({ ...TypingStore.getTypingUsers(channelId) as Record<string, number> }),
|
() => ({ ...TypingStore.getTypingUsers(channelId) as Record<string, number> }),
|
||||||
|
@ -57,7 +57,6 @@ function TypingIndicator({ channelId }: { channelId: string; }) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const currentChannelId: string = useStateFromStores([SelectedChannelStore], () => SelectedChannelStore.getChannelId());
|
const currentChannelId: string = useStateFromStores([SelectedChannelStore], () => SelectedChannelStore.getChannelId());
|
||||||
const guildId = ChannelStore.getChannel(channelId).guild_id;
|
|
||||||
|
|
||||||
if (!settings.store.includeMutedChannels) {
|
if (!settings.store.includeMutedChannels) {
|
||||||
const isChannelMuted = UserGuildSettingsStore.isChannelMuted(guildId, channelId);
|
const isChannelMuted = UserGuildSettingsStore.isChannelMuted(guildId, channelId);
|
||||||
|
@ -165,7 +164,7 @@ export default definePlugin({
|
||||||
find: "UNREAD_IMPORTANT:",
|
find: "UNREAD_IMPORTANT:",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\.name\),.{0,120}\.children.+?:null(?<=,channel:(\i).+?)/,
|
match: /\.name\),.{0,120}\.children.+?:null(?<=,channel:(\i).+?)/,
|
||||||
replace: "$&,$self.TypingIndicator($1.id)"
|
replace: "$&,$self.TypingIndicator($1.id,$1.getGuildId())"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Theads
|
// Theads
|
||||||
|
@ -174,14 +173,14 @@ export default definePlugin({
|
||||||
find: "M11 9H4C2.89543 9 2 8.10457 2 7V1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1V7C0 9.20914 1.79086 11 4 11H11C11.5523 11 12 10.5523 12 10C12 9.44771 11.5523 9 11 9Z",
|
find: "M11 9H4C2.89543 9 2 8.10457 2 7V1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1V7C0 9.20914 1.79086 11 4 11H11C11.5523 11 12 10.5523 12 10C12 9.44771 11.5523 9 11 9Z",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /mentionsCount:\i.+?null(?<=channel:(\i).+?)/,
|
match: /mentionsCount:\i.+?null(?<=channel:(\i).+?)/,
|
||||||
replace: "$&,$self.TypingIndicator($1.id)"
|
replace: "$&,$self.TypingIndicator($1.id,$1.getGuildId())"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
TypingIndicator: (channelId: string) => (
|
TypingIndicator: (channelId: string, guildId: string) => (
|
||||||
<ErrorBoundary noop>
|
<ErrorBoundary noop>
|
||||||
<TypingIndicator channelId={channelId} />
|
<TypingIndicator channelId={channelId} guildId={guildId} />
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
|
@ -129,14 +129,22 @@ export default definePlugin({
|
||||||
buildSeveralUsers,
|
buildSeveralUsers,
|
||||||
|
|
||||||
mutateChildren(props: any, users: User[], children: any) {
|
mutateChildren(props: any, users: User[], children: any) {
|
||||||
if (!Array.isArray(children)) return children;
|
try {
|
||||||
|
if (!Array.isArray(children)) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
let element = 0;
|
let element = 0;
|
||||||
|
|
||||||
return children.map(c =>
|
return children.map(c =>
|
||||||
c.type === "strong"
|
c.type === "strong" || (typeof c !== "string" && !React.isValidElement(c))
|
||||||
? <TypingUser {...props} user={users[element++]} />
|
? <TypingUser {...props} user={users[element++]} />
|
||||||
: c
|
: c
|
||||||
);
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return children;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,8 +21,8 @@ import { Patch, PatchReplacement, ReplaceFn } from "./types";
|
||||||
|
|
||||||
export function canonicalizeMatch<T extends RegExp | string>(match: T): T {
|
export function canonicalizeMatch<T extends RegExp | string>(match: T): T {
|
||||||
let partialCanon = typeof match === "string" ? match : match.source;
|
let partialCanon = typeof match === "string" ? match : match.source;
|
||||||
partialCanon = partialCanon.replaceAll(/#{intl::([A-Za-z_$][\w$]*)}/g, (_, key) => {
|
partialCanon = partialCanon.replaceAll(/#{intl::([\w$+/]*)(?:::(\w+))?}/g, (_, key, modifier) => {
|
||||||
const hashed = runtimeHashMessageKey(key);
|
const hashed = modifier === "raw" ? key : runtimeHashMessageKey(key);
|
||||||
|
|
||||||
const isString = typeof match === "string";
|
const isString = typeof match === "string";
|
||||||
const hasSpecialChars = !Number.isNaN(Number(hashed[0])) || hashed.includes("+") || hashed.includes("/");
|
const hasSpecialChars = !Number.isNaN(Number(hashed[0])) || hashed.includes("+") || hashed.includes("/");
|
||||||
|
@ -40,7 +40,7 @@ export function canonicalizeMatch<T extends RegExp | string>(match: T): T {
|
||||||
return partialCanon as T;
|
return partialCanon as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
const canonSource = partialCanon.replaceAll(String.raw`\i`, String.raw`(?:[A-Za-z_$][\w$]*)`);
|
const canonSource = partialCanon.replaceAll("\\i", String.raw`(?:[A-Za-z_$][\w$]*)`);
|
||||||
return new RegExp(canonSource, match.flags) as T;
|
return new RegExp(canonSource, match.flags) as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue