diff --git a/src/equicordplugins/customAppIcons/AppIconModal.tsx b/src/equicordplugins/customAppIcons/AppIconModal.tsx index 0d610eb5..c219d7ac 100644 --- a/src/equicordplugins/customAppIcons/AppIconModal.tsx +++ b/src/equicordplugins/customAppIcons/AppIconModal.tsx @@ -32,13 +32,13 @@ function AppIconModal(props: ModalProps) { appIcons.push(icon); - findByProps("ICONS", "ICONS_BY_ID").ICONS.push(icon); - findByProps("ICONS", "ICONS_BY_ID").ICONS_BY_ID[icon.id] = icon; + findByProps("UZ", "QA").UZ.push(icon); + findByProps("UZ", "QA").QA[icon.id] = icon; showToast("Added custom app icon!", Toasts.Type.SUCCESS); props.onClose(); const oldIcon = findByProps("getCurrentDesktopIcon").getCurrentDesktopIcon(); - let random_icon = Object.keys(findByProps("ICONS_BY_ID")).filter(icon => icon !== oldIcon) as []; + let random_icon = Object.keys(findByProps("UZ")).filter(icon => icon !== oldIcon) as []; random_icon = random_icon[Math.floor(Math.random() * random_icon.length)]; FluxDispatcher.dispatch({ diff --git a/src/equicordplugins/customAppIcons/index.tsx b/src/equicordplugins/customAppIcons/index.tsx index 7cd19283..17aa52c5 100644 --- a/src/equicordplugins/customAppIcons/index.tsx +++ b/src/equicordplugins/customAppIcons/index.tsx @@ -1,3 +1,9 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + /* * Vencord, a modification for Discord's desktop app * Copyright (c) 2022 Vendicated and contributors @@ -32,8 +38,8 @@ function removeAppIcon() { const index = icons.findIndex(icon => current_icon === icon.id); if (index !== -1) { icons = icons.filter(e => e.id !== current_icon); - delete findByProps("ICONS", "ICONS_BY_ID").ICONS_BY_ID[current_icon]; - delete findByProps("ICONS", "ICONS_BY_ID").ICONS[findByProps("ICONS", "ICONS_BY_ID").ICONS.findIndex((icon => current_icon === icon?.id))]; + delete findByProps("UZ", "QA").QA[current_icon]; + delete findByProps("UZ", "QA").UZ[findByProps("UZ", "QA").UZ.findIndex((icon => current_icon === icon?.id))]; localStorage.setItem("vc_app_icons", JSON.stringify(icons)); showToast("Icon successfully deleted!", Toasts.Type.SUCCESS); FluxDispatcher.dispatch({ @@ -54,7 +60,7 @@ export default definePlugin({ authors: [Devs.HappyEnderman, EquicordDevs.SerStars], patches: [ { - find: ".PremiumUpsellTypes.APP_ICON_UPSELL", + find: /\i\.\i\.APP_ICON_UPSELL/, replacement: [ { match: /\w+\.jsx\)\(\w+,{markAsDismissed:\w+,isCoachmark:\w+}\)/, @@ -71,8 +77,8 @@ export default definePlugin({ console.log("Well hello there!, CustomAppIcons has started :)"); const appIcons = JSON.parse(localStorage.getItem("vc_app_icons") ?? "[]"); for (const icon of appIcons) { - findByProps("ICONS", "ICONS_BY_ID").ICONS.push(icon); - findByProps("ICONS", "ICONS_BY_ID").ICONS_BY_ID[icon.id] = icon; + findByProps("UZ", "QA").UZ.push(icon); + findByProps("UZ", "QA").QA[icon.id] = icon; } }, stop() { @@ -100,12 +106,12 @@ export default definePlugin({ <> How to use? - - Go to { e.preventDefault(); closeAllModals(); FluxDispatcher.dispatch({ type: "USER_SETTINGS_MODAL_SET_SECTION", section: "Appearance" }); }}>Appearance Settings tab. - Scroll down to "In-app Icons" and click on "Preview App Icon". - And upload your own custom icon! - You can only use links when you are uploading your Custom Icon. - + + Go to { e.preventDefault(); closeAllModals(); FluxDispatcher.dispatch({ type: "USER_SETTINGS_MODAL_SET_SECTION", section: "Appearance" }); }}>Appearance Settings tab. + Scroll down to "In-app Icons" and click on "Preview App Icon". + And upload your own custom icon! + You can only use links when you are uploading your Custom Icon. + ); } }); diff --git a/src/equicordplugins/messageLoggerEnhanced/LoggedMessageManager.ts b/src/equicordplugins/messageLoggerEnhanced/LoggedMessageManager.ts index 00c6b240..38a7d093 100644 --- a/src/equicordplugins/messageLoggerEnhanced/LoggedMessageManager.ts +++ b/src/equicordplugins/messageLoggerEnhanced/LoggedMessageManager.ts @@ -211,6 +211,13 @@ export function getOldestMessage(loggedMessageIds: LoggedMessages) { return oldestMessage ?? null; } +export function getMessage(channelId: string, messageId: string) { + const messags = Object.values(savedLoggedMessages) + .filter(m => !Array.isArray(m) && m.message != null) as MessageRecord[]; + + return messags.find(m => m.message.channel_id === channelId && m.message.id === messageId); +} + export async function deleteOldestMessageWithoutSaving(loggedMessages: LoggedMessages) { const oldestMessage = getOldestMessage(loggedMessages); if (!oldestMessage || !oldestMessage.message) { diff --git a/src/equicordplugins/messageLoggerEnhanced/components/LogsModal.tsx b/src/equicordplugins/messageLoggerEnhanced/components/LogsModal.tsx index 8c00630b..c7b76caf 100644 --- a/src/equicordplugins/messageLoggerEnhanced/components/LogsModal.tsx +++ b/src/equicordplugins/messageLoggerEnhanced/components/LogsModal.tsx @@ -21,7 +21,7 @@ import { openUserProfile } from "@utils/discord"; import { copyWithToast } from "@utils/misc"; import { closeAllModals, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; import { LazyComponent, useAwaiter } from "@utils/react"; -import { find, findByCode, findByPropsLazy } from "@webpack"; +import { find, findByCode, findByCodeLazy } from "@webpack"; import { Alerts, Button, ChannelStore, ContextMenuApi, FluxDispatcher, Menu, NavigationRouter, React, TabBar, Text, TextInput, useCallback, useMemo, useRef, useState } from "@webpack/common"; import { User } from "discord-types/general"; @@ -61,7 +61,7 @@ export interface ChildrenAccProops { showClydeAiEmbeds: boolean; } -const ChannelRecords = findByPropsLazy("PrivateChannelRecord"); +const PrivateChannelRecord = findByCodeLazy(".is_message_request_timestamp,"); const MessagePreview = LazyComponent(() => find(m => m?.type?.toString().includes("previewLinkTarget:") && !m?.type?.toString().includes("HAS_THREAD"))); const ChildrenAccessories = LazyComponent(() => findByCode("channelMessageProps:{message:")); @@ -448,7 +448,7 @@ function LMessage({ log, isGroupStart, forceUpdate, }: LMessageProps) { childrenAccessories={ 0) && $&" } }, @@ -747,10 +747,23 @@ export default definePlugin({ }, async start() { + this.oldGetMessage = MessageStore.getMessage; + // we have to do this because the original message logger fetches the message from the store now + MessageStore.getMessage = (channelId: string, messageId: string) => { + const MLMessage = LoggedMessageManager.getMessage(channelId, messageId); + if (MLMessage?.message) return messageJsonToMessageClass(MLMessage); + + return this.oldGetMessage(channelId, messageId); + }; + Native.init(); const { imageCacheDir, logsDir } = await Native.getSettings(); settings.store.imageCacheDir = imageCacheDir; settings.store.logsDir = logsDir; + }, + + stop() { + MessageStore.getMessage = this.oldGetMessage; } }); diff --git a/src/equicordplugins/messageLoggerEnhanced/utils/misc.ts b/src/equicordplugins/messageLoggerEnhanced/utils/misc.ts index 776c96b0..9e7cdd5c 100644 --- a/src/equicordplugins/messageLoggerEnhanced/utils/misc.ts +++ b/src/equicordplugins/messageLoggerEnhanced/utils/misc.ts @@ -18,7 +18,7 @@ import { get, set } from "@api/DataStore"; import { PluginNative } from "@utils/types"; -import { findByPropsLazy, findLazy } from "@webpack"; +import { findByCodeLazy, findLazy } from "@webpack"; import { ChannelStore, moment, UserStore } from "@webpack/common"; import { LOGGED_MESSAGES_KEY, MessageLoggerStore } from "../LoggedMessageManager"; @@ -29,7 +29,7 @@ import { memoize } from "./memoize"; const MessageClass: any = findLazy(m => m?.prototype?.isEdited); const AuthorClass = findLazy(m => m?.prototype?.getAvatarURL); -const embedModule = findByPropsLazy("sanitizeEmbed"); +const sanitizeEmbed = findByCodeLazy('"embed_"),'); export function getGuildIdByChannel(channel_id: string) { return ChannelStore.getChannel(channel_id)?.guild_id; @@ -104,7 +104,7 @@ export const messageJsonToMessageClass = memoize((log: { message: LoggedMessageJ message.author = new AuthorClass(message.author); message.author.nick = message.author.globalName ?? message.author.username; - message.embeds = message.embeds.map(e => embedModule.sanitizeEmbed(message.channel_id, message.id, e)); + message.embeds = message.embeds.map(e => sanitizeEmbed(message.channel_id, message.id, e)); if (message.poll) message.poll.expiry = moment(message.poll.expiry);