From 6900c60b5b442de5eef65e4cdf7a1632fe764c20 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Fri, 24 Apr 2026 12:35:12 -0400 Subject: [PATCH] HolyNotes: Removed --- src/equicordplugins/holyNotes/NoteHandler.ts | 149 --------------- .../holyNotes/components/modals/Error.tsx | 38 ---- .../holyNotes/components/modals/HelpModal.tsx | 75 -------- .../holyNotes/components/modals/Notebook.tsx | 177 ----------------- .../components/modals/NotebookCreateModal.tsx | 55 ------ .../components/modals/NotebookDeleteModal.tsx | 68 ------- .../components/modals/RenderMessage.tsx | 180 ------------------ src/equicordplugins/holyNotes/index.tsx | 129 ------------- src/equicordplugins/holyNotes/style.css | 120 ------------ src/equicordplugins/holyNotes/types.ts | 38 ---- src/equicordplugins/holyNotes/utils.ts | 91 --------- 11 files changed, 1120 deletions(-) delete mode 100644 src/equicordplugins/holyNotes/NoteHandler.ts delete mode 100644 src/equicordplugins/holyNotes/components/modals/Error.tsx delete mode 100644 src/equicordplugins/holyNotes/components/modals/HelpModal.tsx delete mode 100644 src/equicordplugins/holyNotes/components/modals/Notebook.tsx delete mode 100644 src/equicordplugins/holyNotes/components/modals/NotebookCreateModal.tsx delete mode 100644 src/equicordplugins/holyNotes/components/modals/NotebookDeleteModal.tsx delete mode 100644 src/equicordplugins/holyNotes/components/modals/RenderMessage.tsx delete mode 100644 src/equicordplugins/holyNotes/index.tsx delete mode 100644 src/equicordplugins/holyNotes/style.css delete mode 100644 src/equicordplugins/holyNotes/types.ts delete mode 100644 src/equicordplugins/holyNotes/utils.ts diff --git a/src/equicordplugins/holyNotes/NoteHandler.ts b/src/equicordplugins/holyNotes/NoteHandler.ts deleted file mode 100644 index 0dcc3ab3e..000000000 --- a/src/equicordplugins/holyNotes/NoteHandler.ts +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -import { Channel, Message } from "@vencord/discord-types"; -import { proxyLazyWebpack } from "@webpack"; -import { ChannelStore, Toasts, UserStore } from "@webpack/common"; - -import { AllNotebooks, Note, Notebook } from "./types"; -import { deleteCacheFromDataStore, DeleteEntireStore, saveCacheToDataStore } from "./utils"; - -export const noteHandlerCache = new Map(); - -function showToast(message: string, type: typeof Toasts.Type[keyof typeof Toasts.Type] = Toasts.Type.SUCCESS) { - Toasts.show({ id: Toasts.genId(), message, type }); -} - -function formatNote(channel: Channel, message: Message): Note { - return { - id: message.id, - channel_id: message.channel_id, - guild_id: channel.guild_id, - content: message.content, - author: { - id: message.author.id, - avatar: message.author.avatar, - discriminator: message.author.discriminator, - username: message.author.username, - }, - flags: message.flags, - timestamp: message.timestamp.toString(), - attachments: message.attachments, - embeds: message.embeds, - reactions: message.reactions, - stickerItems: message.stickerItems, - }; -} - -export const noteHandler = proxyLazyWebpack(() => ({ - getNotes(notebook: string): Notebook | undefined { - return noteHandlerCache.get(notebook); - }, - - getAllNotes(): AllNotebooks { - return Object.fromEntries(noteHandlerCache.entries()); - }, - - addNote(message: Message, notebook: string) { - const notes = this.getNotes(notebook) ?? {}; - const channel = ChannelStore.getChannel(message.channel_id); - const newNotes = { [message.id]: formatNote(channel, message), ...notes }; - - noteHandlerCache.set(notebook, newNotes); - saveCacheToDataStore(notebook, newNotes); - showToast(`Added note to ${notebook}`); - }, - - deleteNote(noteId: string, notebook: string) { - const notes = this.getNotes(notebook); - if (!notes) return; - - const { [noteId]: _, ...rest } = notes; - noteHandlerCache.set(notebook, rest); - saveCacheToDataStore(notebook, rest); - showToast(`Deleted note from ${notebook}`); - }, - - moveNote(note: Note, from: string, to: string) { - const fromNotes = this.getNotes(from); - const toNotes = this.getNotes(to); - if (!fromNotes || !toNotes) return; - - const { [note.id]: _, ...restFrom } = fromNotes; - const newTo = { [note.id]: note, ...toNotes }; - - noteHandlerCache.set(from, restFrom); - noteHandlerCache.set(to, newTo); - saveCacheToDataStore(from, restFrom); - saveCacheToDataStore(to, newTo); - showToast(`Moved note from ${from} to ${to}`); - }, - - newNoteBook(name: string, silent?: boolean) { - if (noteHandlerCache.has(name)) { - showToast(`Notebook ${name} already exists`, Toasts.Type.FAILURE); - return; - } - - noteHandlerCache.set(name, {}); - saveCacheToDataStore(name, {}); - if (!silent) showToast(`Created notebook ${name}`); - }, - - deleteNotebook(name: string) { - noteHandlerCache.delete(name); - deleteCacheFromDataStore(name); - showToast(`Deleted notebook ${name}`); - }, - - refreshAvatars() { - const notebooks = this.getAllNotes(); - - for (const notebookName in notebooks) { - const notebook = notebooks[notebookName]; - for (const noteId in notebook) { - const note = notebook[noteId]; - const user = UserStore.getUser(note.author.id); - if (user) { - note.author.avatar = user.avatar; - note.author.discriminator = user.discriminator; - note.author.username = user.username; - } - } - noteHandlerCache.set(notebookName, notebook); - saveCacheToDataStore(notebookName, notebook); - } - - showToast("Refreshed avatars"); - }, - - async deleteEverything() { - noteHandlerCache.clear(); - await DeleteEntireStore(); - showToast("Deleted all notes"); - }, - - exportNotes(): AllNotebooks { - return this.getAllNotes(); - }, - - importNotes(jsonString: string) { - let parsed: AllNotebooks; - try { - parsed = JSON.parse(jsonString); - } catch { - showToast("Invalid JSON", Toasts.Type.FAILURE); - return; - } - - for (const notebook in parsed) { - noteHandlerCache.set(notebook, parsed[notebook]); - saveCacheToDataStore(notebook, parsed[notebook]); - } - - showToast("Imported notes"); - }, -})); diff --git a/src/equicordplugins/holyNotes/components/modals/Error.tsx b/src/equicordplugins/holyNotes/components/modals/Error.tsx deleted file mode 100644 index df7974d71..000000000 --- a/src/equicordplugins/holyNotes/components/modals/Error.tsx +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -import { resultsClasses } from "@equicordplugins/holyNotes"; - -export default function EmptyNotebook({ error }: { error?: Error; } = {}) { - if (error) { - console.error("[HolyNotes] Error:", error); - return ( -
-
-
-
- There was an error parsing your notes. Check the console for details. -
-
-
- ); - } - - const isEasterEgg = Math.random() < 0.1; - - return ( -
-
-
-
- {isEasterEgg - ? "No notes were found. Empathy banana is here for you." - : "No notes were found in this notebook."} -
-
-
- ); -} diff --git a/src/equicordplugins/holyNotes/components/modals/HelpModal.tsx b/src/equicordplugins/holyNotes/components/modals/HelpModal.tsx deleted file mode 100644 index 3efe060c2..000000000 --- a/src/equicordplugins/holyNotes/components/modals/HelpModal.tsx +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -import { BaseText } from "@components/BaseText"; -import { Button } from "@components/Button"; -import { Flex } from "@components/Flex"; -import { cl } from "@equicordplugins/holyNotes"; -import { noteHandler } from "@equicordplugins/holyNotes/NoteHandler"; -import { downloadNotes, uploadNotes } from "@equicordplugins/holyNotes/utils"; -import { CloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal"; - -function HelpSection({ title, children }: { title: string; children: React.ReactNode; }) { - return ( - <> - {title} - {children} -
- - ); -} - -export default function HelpModal({ onClose, transitionState }: ModalProps) { - return ( - - -
- - Help - - - Learn how to use Holy Notes - -
-
- -
-
- -
- - Right-click a message, hover over "Note Message", and select the notebook. - - - Right-click a note and select "Delete Note", or hold DELETE and click a note. - - - Right-click a note, hover over "Move Note", and select the destination notebook. - - - Right-click a note and select "Jump to Message" to go to the original message. - -
-
- - - - - - - - -
- ); -} diff --git a/src/equicordplugins/holyNotes/components/modals/Notebook.tsx b/src/equicordplugins/holyNotes/components/modals/Notebook.tsx deleted file mode 100644 index 704a12f9b..000000000 --- a/src/equicordplugins/holyNotes/components/modals/Notebook.tsx +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -import { BaseText } from "@components/BaseText"; -import { Button } from "@components/Button"; -import ErrorBoundary from "@components/ErrorBoundary"; -import { Flex } from "@components/Flex"; -import { BookmarkIcon } from "@components/Icons"; -import { CircleQuestionIcon, cl } from "@equicordplugins/holyNotes"; -import { noteHandler } from "@equicordplugins/holyNotes/NoteHandler"; -import { Note, Notebook } from "@equicordplugins/holyNotes/types"; -import { CloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; -import { Clickable, React, Select, TextInput, Tooltip, useState } from "@webpack/common"; - -import Errors from "./Error"; -import HelpModal from "./HelpModal"; -import NotebookCreateModal from "./NotebookCreateModal"; -import NotebookDeleteModal from "./NotebookDeleteModal"; -import { RenderMessage } from "./RenderMessage"; - -const enum SortOption { - NewestAdded, - OldestAdded, - NewestMessage, - OldestMessage -} - -function NotebookTabs({ notebooks, selected, onSelect }: { - notebooks: string[]; - selected: string; - onSelect: (tab: string) => void; -}) { - const sorted = [...notebooks].sort((a, b) => - a === "Main" ? -1 : b === "Main" ? 1 : a.localeCompare(b) - ); - - return ( -
- {sorted.map(name => ( - onSelect(name)} - > - {name} - - ))} -
- ); -} - -function sortNotes(notes: Note[], sort: SortOption): Note[] { - const sorted = [...notes]; - switch (sort) { - case SortOption.NewestAdded: - return sorted; - case SortOption.OldestAdded: - return sorted.reverse(); - case SortOption.NewestMessage: - return sorted.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()); - case SortOption.OldestMessage: - return sorted.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()); - } -} - -function filterNotes(notes: Notebook, search: string): Note[] { - const arr = Object.values(notes); - if (!search) return arr; - const q = search.toLowerCase(); - return arr.filter(n => n.content?.toLowerCase().includes(q)); -} - -export function NoteModal({ onClose, transitionState }: ModalProps) { - const [sort, setSort] = useState(SortOption.NewestAdded); - const [search, setSearch] = useState(""); - const [notebook, setNotebook] = useState("Main"); - const [, forceUpdate] = React.useReducer(x => x + 1, 0); - - const notes = noteHandler.getNotes(notebook); - if (!notes) return null; - - const filtered = filterNotes(notes, search); - const sorted = sortNotes(filtered, sort); - const total = Object.keys(notes).length; - const isMain = notebook === "Main"; - - return ( - - -
- - - - Notebook - - - - {search ? `${filtered.length} of ${total}` : total} {total === 1 ? "note" : "notes"} - -
-
- -
-
- -
- -