mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-25 16:56:23 +00:00
Add HolyNoteStore and related functions
This commit is contained in:
parent
14fc2d9b25
commit
60ec125105
1 changed files with 10 additions and 5 deletions
|
@ -4,23 +4,24 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { createStore } from "@api/DataStore";
|
||||||
import { DataStore } from "@api/index";
|
import { DataStore } from "@api/index";
|
||||||
|
|
||||||
import { noteHandlerCache } from "./noteHandler";
|
import { noteHandlerCache } from "./noteHandler";
|
||||||
import { HolyNotes } from "./types";
|
import { HolyNotes } from "./types";
|
||||||
|
|
||||||
|
export const HolyNoteStore = createStore("HolyNoteData", "HolyNoteStore");
|
||||||
|
|
||||||
export async function saveCacheToDataStore(key: string, value?: HolyNotes.Note[]) {
|
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) {
|
export async function deleteCacheFromDataStore(key: string) {
|
||||||
await DataStore.del(key);
|
await DataStore.del(key, HolyNoteStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getFormatedEntries() {
|
export async function getFormatedEntries() {
|
||||||
const data = await DataStore.entries();
|
const data = await DataStore.entries(HolyNoteStore);
|
||||||
const notebooks: Record<string, HolyNotes.Note> = {};
|
const notebooks: Record<string, HolyNotes.Note> = {};
|
||||||
|
|
||||||
data.forEach(function (note) {
|
data.forEach(function (note) {
|
||||||
|
@ -31,9 +32,13 @@ export async function getFormatedEntries() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function DataStoreToCache() {
|
export async function DataStoreToCache() {
|
||||||
const data = await DataStore.entries();
|
const data = await DataStore.entries(HolyNoteStore);
|
||||||
|
|
||||||
data.forEach(function (note) {
|
data.forEach(function (note) {
|
||||||
noteHandlerCache.set(note[0], note[1]);
|
noteHandlerCache.set(note[0], note[1]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function DeleteEntireStore() {
|
||||||
|
await DataStore.clear(HolyNoteStore);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue