mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-26 17:26:22 +00:00
Not sure why NoteModal needs await
This commit is contained in:
parent
fba84bd081
commit
72a8178501
2 changed files with 52 additions and 48 deletions
|
@ -4,16 +4,17 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, openModal } from "@utils/modal";
|
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, openModal } from "@utils/modal";
|
||||||
import { React, TabBar, Text, TextInput } from "@webpack/common";
|
import { React, TabBar, Text, TextInput } from "@webpack/common";
|
||||||
import noteHandler from "plugins/holynotes/noteHandler";
|
import noteHandler from "plugins/holynotes/noteHandler";
|
||||||
|
|
||||||
import HelpIcon from "../icons/HelpIcon";
|
import HelpIcon from "../icons/HelpIcon";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const NoteModal = async (props) => {
|
export const NoteModal = (props) => {
|
||||||
const [sortType, setSortType] = React.useState(true);
|
const [sortType, setSortType] = React.useState(true);
|
||||||
const [searchInput, setSearch] = React.useState("");
|
const [searchInput, setSearch] = React.useState("");
|
||||||
const [sortDirection, setSortDirection] = React.useState(true);
|
const [sortDirection, setSortDirection] = React.useState(true);
|
||||||
|
@ -25,52 +26,54 @@ export const NoteModal = async (props) => {
|
||||||
if (!notes) return <></>;
|
if (!notes) return <></>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalRoot {...props} className="notebook" size="large" style={{ borderRadius: "8px" }}>
|
<ErrorBoundary>
|
||||||
<Flex className="notebook-flex" style={{ width: "100%" }}>
|
<ModalRoot {...props} className="notebook" size="large" style={{ borderRadius: "8px" }}>
|
||||||
<div className="notebook-topSection">
|
<Flex className="notebook-flex" style={{ width: "100%" }}>
|
||||||
<ModalHeader className="notebook-header-main">
|
<div className="notebook-topSection">
|
||||||
<Text
|
<ModalHeader className="notebook-header-main">
|
||||||
variant="heading-lg/semibold"
|
<Text
|
||||||
style={{ flexGrow: 1 }}
|
variant="heading-lg/semibold"
|
||||||
className="notebook-heading">
|
style={{ flexGrow: 1 }}
|
||||||
NOTEBOOK
|
className="notebook-heading">
|
||||||
</Text>
|
NOTEBOOK
|
||||||
<div className="notebook-flex help-icon" onClick={() => openModal()}>
|
</Text>
|
||||||
<HelpIcon />
|
<div className="notebook-flex help-icon" onClick={() => openModal()}>
|
||||||
|
<HelpIcon />
|
||||||
|
</div>
|
||||||
|
<div style={{ marginBottom: "10px" }} className="notebook-search">
|
||||||
|
<TextInput
|
||||||
|
autoFocus={false}
|
||||||
|
placeholder="Search for a message..."
|
||||||
|
onChange={(e) => setSearch(e)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<ModalCloseButton onClick={props.onClose} />
|
||||||
|
</ModalHeader>
|
||||||
|
<div className="notebook-tabbar-Container">
|
||||||
|
<TabBar
|
||||||
|
type="top"
|
||||||
|
look="brand"
|
||||||
|
className="notebook-tabbar-Bar notebook-tabbar"
|
||||||
|
selectedItem={currentNotebook}
|
||||||
|
onItemSelect={setCurrentNotebook}>
|
||||||
|
{Object.keys(noteHandler.getAllNotes()).map(notebook => (
|
||||||
|
<TabBar.Item key={notebook} id={notebook} className="notebook-tabbar-barItem notebook-tabbar-item">
|
||||||
|
{notebook}
|
||||||
|
</TabBar.Item>
|
||||||
|
))}
|
||||||
|
</TabBar>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ marginBottom: "10px" }} className="notebook-search">
|
|
||||||
<TextInput
|
|
||||||
autoFocus={false}
|
|
||||||
placeholder="Search for a message..."
|
|
||||||
onChange={(e) => setSearch(e)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<ModalCloseButton onClick={props.onClose} />
|
|
||||||
</ModalHeader>
|
|
||||||
<div className="notebook-tabbar-Container">
|
|
||||||
<TabBar
|
|
||||||
type="top"
|
|
||||||
look="brand"
|
|
||||||
className="notebook-tabbar-Bar notebook-tabbar"
|
|
||||||
selectedItem={currentNotebook}
|
|
||||||
onItemSelect={setCurrentNotebook}>
|
|
||||||
{Object.keys(await noteHandler.getAllNotes()).map(notebook => (
|
|
||||||
<TabBar.Item key={notebook} id={notebook} className="notebook-tabbar-barItem notebook-tabbar-item">
|
|
||||||
{notebook}
|
|
||||||
</TabBar.Item>
|
|
||||||
))}
|
|
||||||
</TabBar>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<ModalContent style={{ marginTop: "20px" }}>
|
||||||
<ModalContent style={{ marginTop:"20px" }}>
|
<ErrorBoundary>
|
||||||
<ErrorBoundary>
|
{ }
|
||||||
{}
|
</ErrorBoundary>
|
||||||
</ErrorBoundary>
|
</ModalContent>
|
||||||
</ModalContent>
|
</Flex>
|
||||||
</Flex>
|
<ModalFooter>
|
||||||
<ModalFooter>
|
|
||||||
|
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
</ModalRoot>
|
</ModalRoot>
|
||||||
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,8 +46,9 @@ export default new (class NoteHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getAllNotes(): Promise<HolyNotes.Note[]> {
|
public async getAllNotes(): Promise<HolyNotes.Note[]> {
|
||||||
// Needs fucking fixing for fuck sakes VEN GIVE ME IMAGE PERMS
|
const data = await DataStore.values(HolyNoteStore);
|
||||||
return { ...await DataStore.values(HolyNoteStore) } ;
|
const mainData = data[0];
|
||||||
|
return mainData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public addNote = async (message: Message, notebook: string) => {
|
public addNote = async (message: Message, notebook: string) => {
|
||||||
|
|
Loading…
Reference in a new issue