From 4cd4e443788f0e097e5f5032af5f78fe6997d5b8 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Wed, 18 Jun 2025 11:53:57 -0400 Subject: [PATCH] Fix HolyNotes --- src/components/PluginSettings/PluginModal.tsx | 2 +- src/equicordplugins/holyNotes/NoteHandler.ts | 4 ++-- .../holyNotes/components/modals/RenderMessage.tsx | 10 ++++++---- src/equicordplugins/holyNotes/index.tsx | 5 +---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/components/PluginSettings/PluginModal.tsx b/src/components/PluginSettings/PluginModal.tsx index 39c1f18c..bb3528f1 100644 --- a/src/components/PluginSettings/PluginModal.tsx +++ b/src/components/PluginSettings/PluginModal.tsx @@ -60,7 +60,7 @@ interface PluginModalProps extends ModalProps { onRestartNeeded(): void; } -function makeDummyUser(user: { username: string; id?: string; avatar?: string; }) { +export function makeDummyUser(user: { username: string; id?: string; avatar?: string; }) { const newUser = new UserRecord({ username: user.username, id: user.id ?? generateId(), diff --git a/src/equicordplugins/holyNotes/NoteHandler.ts b/src/equicordplugins/holyNotes/NoteHandler.ts index 2235528e..654186db 100644 --- a/src/equicordplugins/holyNotes/NoteHandler.ts +++ b/src/equicordplugins/holyNotes/NoteHandler.ts @@ -4,10 +4,10 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +import { makeDummyUser } from "@components/PluginSettings/PluginModal"; import { ChannelStore, lodash, Toasts, UserStore } from "@webpack/common"; import { Channel, Message } from "discord-types/general"; -import { User } from "."; import { Discord, HolyNotes } from "./types"; import { deleteCacheFromDataStore, DeleteEntireStore, saveCacheToDataStore } from "./utils"; @@ -145,7 +145,7 @@ export default new (class NoteHandler { for (const notebook in notebooks) for (const noteId in notebooks[notebook]) { const note = notebooks[notebook][noteId]; - const user = UserStore.getUser(note.author.id) ?? new User({ ...note.author }); + const user = UserStore.getUser(note.author.id) ?? makeDummyUser(note.author); Object.assign(notebooks[notebook][noteId].author, { avatar: user.avatar, diff --git a/src/equicordplugins/holyNotes/components/modals/RenderMessage.tsx b/src/equicordplugins/holyNotes/components/modals/RenderMessage.tsx index feb8fe9e..d27e2372 100644 --- a/src/equicordplugins/holyNotes/components/modals/RenderMessage.tsx +++ b/src/equicordplugins/holyNotes/components/modals/RenderMessage.tsx @@ -4,17 +4,17 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { Channel, cozyMessage, groupStart, message, MessageType, User } from "@equicordplugins/holyNotes"; +import { makeDummyUser } from "@components/PluginSettings/PluginModal"; +import { MessageType } from "@equicordplugins/holyNotes"; import { copyToClipboard } from "@utils/clipboard"; import { classes } from "@utils/misc"; import { ModalProps } from "@utils/modal"; -import { findComponentByCodeLazy } from "@webpack"; +import { findByCodeLazy, findByProps, findComponentByCodeLazy } from "@webpack"; import { ContextMenuApi, FluxDispatcher, Menu, NavigationRouter, React } from "@webpack/common"; import noteHandler from "../../NoteHandler"; import { HolyNotes } from "../../types"; - export const RenderMessage = ({ note, notebook, @@ -28,6 +28,8 @@ export const RenderMessage = ({ fromDeleteModal: boolean; closeModal?: () => void; }) => { + const { message, groupStart, cozyMessage } = findByProps("cozyMessage"); + const Channel = findByCodeLazy("computeLurkerPermissionsAllowList(){"); const ChannelMessage = findComponentByCodeLazy("Message must not be a thread"); const [isHoldingDelete, setHoldingDelete] = React.useState(false); @@ -91,7 +93,7 @@ export const RenderMessage = ({ Object.assign( { ...note }, { - author: new User({ ...note?.author }), + author: makeDummyUser(note?.author), timestamp: new Date(note?.timestamp), // @ts-ignore embeds: note?.embeds?.map((embed: { timestamp: string | number | Date; }) => diff --git a/src/equicordplugins/holyNotes/index.tsx b/src/equicordplugins/holyNotes/index.tsx index d01ba040..71f9ed69 100644 --- a/src/equicordplugins/holyNotes/index.tsx +++ b/src/equicordplugins/holyNotes/index.tsx @@ -26,7 +26,7 @@ import { EquicordDevs } from "@utils/constants"; import { classes } from "@utils/misc"; import { openModal } from "@utils/modal"; import definePlugin from "@utils/types"; -import { findByCodeLazy, findByProps, findByPropsLazy, findComponentByCodeLazy } from "@webpack"; +import { findByCodeLazy, findByProps, findComponentByCodeLazy } from "@webpack"; import { ChannelStore, Menu } from "@webpack/common"; import { Message } from "discord-types/general"; @@ -35,10 +35,7 @@ import { NoteModal } from "./components/modals/Notebook"; import noteHandler, { noteHandlerCache } from "./NoteHandler"; import { DataStoreToCache, HolyNoteStore } from "./utils"; -export const User = findByCodeLazy("isSystemUser(){"); -export const { message, groupStart, cozyMessage } = findByPropsLazy("cozyMessage"); export const MessageType = findByCodeLazy("isEdited(){"); -export const Channel = findByCodeLazy("computeLurkerPermissionsAllowList(){"); const HeaderBarIcon = findComponentByCodeLazy(".HEADER_BAR_BADGE_TOP:", '.iconBadge,"top"');