From 35991f2501ebb3545f462bccc7b608cf57aa298f Mon Sep 17 00:00:00 2001 From: Wolfie <32025746+Wolfkid200444@users.noreply.github.com> Date: Mon, 11 Mar 2024 00:06:39 -0400 Subject: [PATCH] Add Button To Access Notebook --- src/plugins/holynotes/index.tsx | 53 +++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/src/plugins/holynotes/index.tsx b/src/plugins/holynotes/index.tsx index eded1c1a8..f1a5406e2 100644 --- a/src/plugins/holynotes/index.tsx +++ b/src/plugins/holynotes/index.tsx @@ -21,16 +21,21 @@ import "./style.css"; import { NavContextMenuPatchCallback } from "@api/ContextMenu"; import { DataStore } from "@api/index"; import { addButton, removeButton } from "@api/MessagePopover"; +import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; +import { classes } from "@utils/misc"; import { openModal } from "@utils/modal"; import definePlugin from "@utils/types"; +import { findByProps, findExportedComponentLazy } from "@webpack"; import { ChannelStore, Menu } from "@webpack/common"; import { Message } from "discord-types/general"; -import { Popover as NoteButtonPopover } from "./components/icons/NoteButton"; +import { Popover as NoteButtonPopover, Popover } from "./components/icons/NoteButton"; import { NoteModal } from "./components/modals/Notebook"; import noteHandler, { noteHandlerCache } from "./noteHandler"; -import { DataStoreToCache } from "./utils"; +import { DataStoreToCache, HolyNoteStore } from "./utils"; + +const HeaderBarIcon = findExportedComponentLazy("Icon", "Divider"); const messageContextMenuPatch: NavContextMenuPatchCallback = async (children, { message }: { message: Message; }) => { children.push( @@ -46,6 +51,22 @@ const messageContextMenuPatch: NavContextMenuPatchCallback = async (children, { ); }; +function ToolBarHeader() { + const iconClasses = findByProps("iconWrapper", "clickable"); + + return ( + + Popover(e)} + onClick={() => openModal(props => )} + /> + + ); +} + export default definePlugin({ name: "HolyNotes", @@ -53,18 +74,43 @@ export default definePlugin({ authors: [Devs.Wolfie], dependencies: ["MessagePopoverAPI", "ChatInputButtonAPI"], + patches: [ + { + find: "toolbar:function", + replacement: { + match: /(function \i\(\i\){)(.{1,200}toolbar.{1,100}mobileToolbar)/, + replace: "$1$self.toolbarAction(arguments[0]);$2" + } + } + ], toolboxActions: { async "Open Notes"() { openModal(props => ); } }, + contextMenus: { "message": messageContextMenuPatch }, + toolbarAction(e) { + if (Array.isArray(e.toolbar)) + return e.toolbar.push( + + + + ); + + e.toolbar = [ + + + , + e.toolbar, + ]; + }, async start() { - if (await DataStore.keys().then(keys => !keys.includes("Main"))) return noteHandler.newNoteBook("Main"); + if (await DataStore.keys(HolyNoteStore).then(keys => !keys.includes("Main"))) return noteHandler.newNoteBook("Main"); if (!noteHandlerCache.has("Main")) await DataStoreToCache(); addButton("HolyNotes", message => { @@ -74,6 +120,7 @@ export default definePlugin({ message: message, channel: ChannelStore.getChannel(message.channel_id), onClick: () => noteHandler.addNote(message, "Main") + }; }); },