From 60ec125105fda3a62e65b3a0ed88b90772ce9862 Mon Sep 17 00:00:00 2001 From: Wolfie <32025746+Wolfkid200444@users.noreply.github.com> Date: Mon, 11 Mar 2024 00:05:53 -0400 Subject: [PATCH] Add HolyNoteStore and related functions --- src/plugins/holynotes/utils.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/plugins/holynotes/utils.ts b/src/plugins/holynotes/utils.ts index 520fb2f28..ffea89786 100644 --- a/src/plugins/holynotes/utils.ts +++ b/src/plugins/holynotes/utils.ts @@ -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 = {}; 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); +}