Skip to content

Commit

Permalink
Merge branch 'Davilarek:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
SashaXser authored Nov 15, 2024
2 parents acb9d52 + 2462fa6 commit c94eb40
Show file tree
Hide file tree
Showing 17 changed files with 143 additions and 92 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vencord",
"private": "true",
"version": "1.10.6",
"version": "1.10.7",
"description": "The cutest Discord client mod",
"homepage": "https://github.com/Vendicated/Vencord#readme",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/generateReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ page.on("console", async e => {
plugin,
type,
id,
match: regex.replace(/\[A-Za-z_\$\]\[\\w\$\]\*/g, "\\i"),
match: regex.replace(/\(\?:\[A-Za-z_\$\]\[\\w\$\]\*\)/g, "\\i"),
error: await maybeGetError(e.args()[3])
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/VencordSettings/PatchHelperTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function FullPatchInput({ setFind, setParsedFind, setMatch, setReplacement }: Fu
}

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.replacement) throw new Error("No 'replacement' field");
Expand Down
10 changes: 1 addition & 9 deletions src/plugins/_core/noTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,7 @@ export default definePlugin({
replace: "$&return;"
}
]
},
{
find: ".installedLogHooks)",
replacement: {
// if getDebugLogging() returns false, the hooks don't get installed.
match: "getDebugLogging(){",
replace: "getDebugLogging(){return false;"
}
},
}
],

startAt: StartAt.Init,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/_core/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default definePlugin({
replace: (_, sectionTypes, commaOrSemi, elements, element) => `${commaOrSemi} $self.addSettings(${elements}, ${element}, ${sectionTypes}) ${commaOrSemi}`
},
{
match: /({(?=.+?function (\i).{0,120}(\i)=\i\.useMemo.{0,60}return \i\.useMemo\(\(\)=>\i\(\3).+?function\(\){return )\2(?=})/,
match: /({(?=.+?function (\i).{0,160}(\i)=\i\.useMemo.{0,140}return \i\.useMemo\(\(\)=>\i\(\3).+?function\(\){return )\2(?=})/,
replace: (_, rest, settingsHook) => `${rest}$self.wrapSettingsHook(${settingsHook})`
}
]
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/bdCompatLayer/fakeBdApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ export const WebpackHolder = {
first: false,
});
},
get getAllByKeys() {
return this.getAllByProps;
},
getByProps(...props) {
return this.getModule(this.Filters.byProps(...props), {});
},
Expand Down Expand Up @@ -283,6 +286,9 @@ class DataWrapper {
}

export const UIHolder = {
alert(title: string, content: any) {
return this.showConfirmationModal(title, content, { cancelText: null });
},
helper() {
console.info("hi");
},
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/betterFolders/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,16 @@ export default definePlugin({
},

makeGuildsBarGuildListFilter(isBetterFolders: boolean) {
try {
return child => {
if (isBetterFolders) {
return child?.props?.["aria-label"] === getIntlMessage("SERVERS");
try {
return child?.props?.["aria-label"] === getIntlMessage("SERVERS");
} catch (e) {
console.error(e);
}
}
return true;
};
} catch {
return true;
}
},

makeGuildsBarTreeFilter(isBetterFolders: boolean) {
Expand Down
30 changes: 29 additions & 1 deletion src/plugins/consoleJanitor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,34 @@ export default definePlugin({
replace: ""
}
},
// Zustand section
{
find: "[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.",
replacement: [
{
match: /&&console\.warn\("\[DEPRECATED\] Passing a vanilla store will be unsupported in a future version\. Instead use `import { useStore } from 'zustand'`\."\)/,
replace: ""
},
{
match: /console\.warn\("\[DEPRECATED\] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`\. They can be imported from 'zustand\/traditional'\. https:\/\/github\.com\/pmndrs\/zustand\/discussions\/1937"\),/,
replace: ""
}
]
},
{
find: "[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead.",
replacement: {
match: /console\.warn\("\[DEPRECATED\] `getStorage`, `serialize` and `deserialize` options are deprecated\. Use `storage` option instead\."\),/,
replace: ""
}
},
{
find: "[DEPRECATED] `context` will be removed in a future version. Instead use `import { createStore, useStore } from 'zustand'`. See: https://github.com/pmndrs/zustand/discussions/1180.",
replacement: {
match: /console\.warn\("\[DEPRECATED\] `context` will be removed in a future version\. Instead use `import { createStore, useStore } from 'zustand'`\. See: https:\/\/github\.com\/pmndrs\/zustand\/discussions\/1180\."\);/,
replace: ""
}
},
// Patches discords generic logger function
{
find: "Σ:",
Expand All @@ -147,5 +175,5 @@ export default definePlugin({
replace: "$self.NoopLogger()"
}
}
],
]
});
2 changes: 1 addition & 1 deletion src/plugins/decor/lib/stores/AuthorizationStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const useAuthorizationStore = proxyLazy(() => zustandCreate(
} as AuthorizationState),
{
name: "decor-auth",
getStorage: () => indexedDBStorage,
storage: indexedDBStorage,
partialize: state => ({ tokens: state.tokens }),
onRehydrateStorage: () => state => state?.init()
}
Expand Down
53 changes: 34 additions & 19 deletions src/plugins/decor/lib/stores/UsersDecorationsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,39 @@ export const useUsersDecorationsStore = proxyLazy(() => zustandCreate((set: any,
} as UsersDecorationsState)));

export function useUserDecorAvatarDecoration(user?: User): AvatarDecoration | null | undefined {
const [decorAvatarDecoration, setDecorAvatarDecoration] = useState<string | null>(user ? useUsersDecorationsStore.getState().getAsset(user.id) ?? null : null);

useEffect(() => {
const destructor = useUsersDecorationsStore.subscribe(
state => {
if (!user) return;
const newDecorAvatarDecoration = state.getAsset(user.id);
if (!newDecorAvatarDecoration) return;
if (decorAvatarDecoration !== newDecorAvatarDecoration) setDecorAvatarDecoration(newDecorAvatarDecoration);
}
);

if (user) {
const { fetch: fetchUserDecorAvatarDecoration } = useUsersDecorationsStore.getState();
fetchUserDecorAvatarDecoration(user.id);
}
return destructor;
}, []);
try {
const [decorAvatarDecoration, setDecorAvatarDecoration] = useState<string | null>(user ? useUsersDecorationsStore.getState().getAsset(user.id) ?? null : null);

useEffect(() => {
const destructor = (() => {
try {
return useUsersDecorationsStore.subscribe(
state => {
if (!user) return;
const newDecorAvatarDecoration = state.getAsset(user.id);
if (!newDecorAvatarDecoration) return;
if (decorAvatarDecoration !== newDecorAvatarDecoration) setDecorAvatarDecoration(newDecorAvatarDecoration);
}
);
} catch {
return () => { };
}
})();

try {
if (user) {
const { fetch: fetchUserDecorAvatarDecoration } = useUsersDecorationsStore.getState();
fetchUserDecorAvatarDecoration(user.id);
}
} catch { }

return destructor;
}, []);

return decorAvatarDecoration ? { asset: decorAvatarDecoration, skuId: SKU_ID } : null;
} catch (e) {
console.error(e);
}

return decorAvatarDecoration ? { asset: decorAvatarDecoration, skuId: SKU_ID } : null;
return null;
}
59 changes: 28 additions & 31 deletions src/plugins/messageLogger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { getIntlMessage } from "@utils/discord";
import { Logger } from "@utils/Logger";
import { classes } from "@utils/misc";
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 { Message } from "discord-types/general";

Expand All @@ -43,7 +43,6 @@ interface MLMessage extends Message {
}

const styles = findByPropsLazy("edited", "communicationDisabled", "isSystemMessage");
const getMessage = findByCodeLazy('replace(/^\\n+|\\n+$/g,"")');

function addDeleteStyle() {
if (Settings.plugins.MessageLogger.deleteStyle === "text") {
Expand Down Expand Up @@ -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}}")
// TODO: find a better way to generate intl messages
DELETED_MESSAGE_COUNT: () => ({
ast: [[
6,
"count",
{
"=0": ["No deleted messages"],
one: [
[
1,
"count"
],
" deleted message"
// 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
DELETED_MESSAGE_COUNT: () => ({
ast: [[
6,
"count",
{
"=0": ["No deleted messages"],
one: [
[
1,
"count"
],
other: [
[
1,
"count"
],
" deleted messages"
]
},
0,
"cardinal"
]]
})
},
" deleted message"
],
other: [
[
1,
"count"
],
" deleted messages"
]
},
0,
"cardinal"
]]
}),

patches: [
{
Expand Down Expand Up @@ -531,7 +528,7 @@ export default definePlugin({
},
{
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
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/noBlockedMessages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import { Message } from "discord-types/general";
const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");

interface MessageDeleteProps {
// i18n message i18n.t["+FcYMz"] if deleted, with args
collapsedReason: () => any
// Internal intl message for BLOCKED_MESSAGE_COUNT
collapsedReason: () => any;
}

export default definePlugin({
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/relationshipNotifier/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ async function runMigrations() {

export async function syncAndRunChecks() {
await runMigrations();
if (UserStore.getCurrentUser() == null) return;

const [oldGuilds, oldGroups, oldFriends] = await DataStore.getMany([
guildsKey(),
groupsKey(),
Expand Down
13 changes: 6 additions & 7 deletions src/plugins/typingIndicator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Devs } from "@utils/constants";
import { getIntlMessage } from "@utils/discord";
import definePlugin, { OptionType } from "@utils/types";
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";

Expand All @@ -44,7 +44,7 @@ function getDisplayName(guildId: string, userId: string) {
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(
[TypingStore],
() => ({ ...TypingStore.getTypingUsers(channelId) as Record<string, number> }),
Expand All @@ -57,7 +57,6 @@ function TypingIndicator({ channelId }: { channelId: string; }) {
}
);
const currentChannelId: string = useStateFromStores([SelectedChannelStore], () => SelectedChannelStore.getChannelId());
const guildId = ChannelStore.getChannel(channelId).guild_id;

if (!settings.store.includeMutedChannels) {
const isChannelMuted = UserGuildSettingsStore.isChannelMuted(guildId, channelId);
Expand Down Expand Up @@ -165,7 +164,7 @@ export default definePlugin({
find: "UNREAD_IMPORTANT:",
replacement: {
match: /\.name\),.{0,120}\.children.+?:null(?<=,channel:(\i).+?)/,
replace: "$&,$self.TypingIndicator($1.id)"
replace: "$&,$self.TypingIndicator($1.id,$1.getGuildId())"
}
},
// Theads
Expand All @@ -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",
replacement: {
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>
<TypingIndicator channelId={channelId} />
<TypingIndicator channelId={channelId} guildId={guildId} />
</ErrorBoundary>
),
});
22 changes: 15 additions & 7 deletions src/plugins/typingTweaks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,22 @@ export default definePlugin({
buildSeveralUsers,

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 =>
c.type === "strong" || (typeof c !== "string" && !React.isValidElement(c))
? <TypingUser {...props} user={users[element++]} />
: c
);
} catch (e) {
console.error(e);
}

return children.map(c =>
c.type === "strong"
? <TypingUser {...props} user={users[element++]} />
: c
);
return children;
}
});
Loading

0 comments on commit c94eb40

Please sign in to comment.