From c7a20769f9f4b6ac6f4f298abbbf68076f8b8119 Mon Sep 17 00:00:00 2001 From: rini Date: Wed, 25 Oct 2023 15:29:32 -0300 Subject: [PATCH] fix things using lodash (#1882) --- src/components/PluginSettings/index.tsx | 4 ++-- src/plugins/fakeNitro/index.ts | 4 ++-- src/plugins/voiceMessages/index.tsx | 4 ++-- src/webpack/common/utils.ts | 2 ++ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index 22657e73..0c44fef5 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -34,7 +34,7 @@ import { openModalLazy } from "@utils/modal"; import { useAwaiter } from "@utils/react"; import { Plugin } from "@utils/types"; import { findByPropsLazy } from "@webpack"; -import { Alerts, Button, Card, Forms, Parser, React, Select, Text, TextInput, Toasts, Tooltip } from "@webpack/common"; +import { Alerts, Button, Card, Forms, Parser, React, Select, Text, TextInput, Toasts, Tooltip, lodash } from "@webpack/common"; import Plugins from "~plugins"; @@ -251,7 +251,7 @@ export default function PluginSettings() { } DataStore.set("Vencord_existingPlugins", existingTimestamps); - return window._.isEqual(newPlugins, sortedPluginNames) ? [] : newPlugins; + return lodash.isEqual(newPlugins, sortedPluginNames) ? [] : newPlugins; })); type P = JSX.Element | JSX.Element[]; diff --git a/src/plugins/fakeNitro/index.ts b/src/plugins/fakeNitro/index.ts index 677286e7..1ae8dfe3 100644 --- a/src/plugins/fakeNitro/index.ts +++ b/src/plugins/fakeNitro/index.ts @@ -25,7 +25,7 @@ import { proxyLazy } from "@utils/lazy"; import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy, findByPropsLazy, findLazy, findStoreLazy } from "@webpack"; -import { ChannelStore, EmojiStore, FluxDispatcher, Parser, PermissionStore, UserStore } from "@webpack/common"; +import { ChannelStore, EmojiStore, FluxDispatcher, lodash, Parser, PermissionStore, UserStore } from "@webpack/common"; import type { Message } from "discord-types/general"; import { applyPalette, GIFEncoder, quantize } from "gifenc"; import type { ReactElement, ReactNode } from "react"; @@ -532,7 +532,7 @@ export default definePlugin({ }; try { - return modifyChildren(window._.cloneDeep(content)); + return modifyChildren(lodash.cloneDeep(content)); } catch (err) { new Logger("FakeNitro").error(err); return content; diff --git a/src/plugins/voiceMessages/index.tsx b/src/plugins/voiceMessages/index.tsx index a5271c2a..1b8d7a4e 100644 --- a/src/plugins/voiceMessages/index.tsx +++ b/src/plugins/voiceMessages/index.tsx @@ -26,7 +26,7 @@ import { useAwaiter } from "@utils/react"; import definePlugin from "@utils/types"; import { chooseFile } from "@utils/web"; import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack"; -import { Button, FluxDispatcher, Forms, Menu, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common"; +import { Button, FluxDispatcher, Forms, lodash, Menu, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common"; import { ComponentType } from "react"; import { VoiceRecorderDesktop } from "./DesktopRecorder"; @@ -138,7 +138,7 @@ function Modal({ modalProps }: { modalProps: ModalProps; }) { const channelData = audioBuffer.getChannelData(0); // average the samples into much lower resolution bins, maximum of 256 total bins - const bins = new Uint8Array(window._.clamp(Math.floor(audioBuffer.duration * 10), Math.min(32, channelData.length), 256)); + const bins = new Uint8Array(lodash.clamp(Math.floor(audioBuffer.duration * 10), Math.min(32, channelData.length), 256)); const samplesPerBin = Math.floor(channelData.length / bins.length); // Get root mean square of each bin diff --git a/src/webpack/common/utils.ts b/src/webpack/common/utils.ts index a1dcadc6..487a4bc7 100644 --- a/src/webpack/common/utils.ts +++ b/src/webpack/common/utils.ts @@ -33,6 +33,8 @@ export const moment: typeof import("moment") = findByPropsLazy("parseTwoDigitYea export const hljs: typeof import("highlight.js") = findByPropsLazy("highlight"); +export const lodash: typeof import("lodash") = findByPropsLazy("debounce", "cloneDeep"); + export const i18n: t.i18n = findLazy(m => m.Messages?.["en-US"]); export let SnowflakeUtils: t.SnowflakeUtils;