1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-11 02:16:23 +00:00

Add HolyNoteStore and related functions

This commit is contained in:
Wolfie 2024-03-11 00:05:53 -04:00
parent 14fc2d9b25
commit 60ec125105
No known key found for this signature in database
GPG key ID: DE384EE9BF2D909A

View file

@ -4,23 +4,24 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { createStore } from "@api/DataStore";
import { DataStore } from "@api/index";
import { noteHandlerCache } from "./noteHandler";
import { HolyNotes } from "./types";
export const HolyNoteStore = createStore("HolyNoteData", "HolyNoteStore");
export async function saveCacheToDataStore(key: string, value?: HolyNotes.Note[]) {
await DataStore.set(key, value);
await DataStore.set(key, value, HolyNoteStore);
}
export async function deleteCacheFromDataStore(key: string) {
await DataStore.del(key);
await DataStore.del(key, HolyNoteStore);
}
export async function getFormatedEntries() {
const data = await DataStore.entries();
const data = await DataStore.entries(HolyNoteStore);
const notebooks: Record<string, HolyNotes.Note> = {};
data.forEach(function (note) {
@ -31,9 +32,13 @@ export async function getFormatedEntries() {
}
export async function DataStoreToCache() {
const data = await DataStore.entries();
const data = await DataStore.entries(HolyNoteStore);
data.forEach(function (note) {
noteHandlerCache.set(note[0], note[1]);
});
}
export async function DeleteEntireStore() {
await DataStore.clear(HolyNoteStore);
}