From b9ed7d0203dac04b946d0d42fb04b74d12c972aa Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Sun, 1 Jun 2025 13:51:05 +0700 Subject: [PATCH] feat(lib/storage): add `Storage.delete` --- lib/storage/src/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/storage/src/index.ts b/lib/storage/src/index.ts index 562960b..b0763ce 100644 --- a/lib/storage/src/index.ts +++ b/lib/storage/src/index.ts @@ -1,7 +1,7 @@ // TODO(storage): Implement using NativeModules interop instead -import { React } from '@revenge-mod/react' import { FileModule } from '@revenge-mod/discord/native' +import { React } from '@revenge-mod/react' import { mergeDeep } from '@revenge-mod/utils/objects' import { useReRender } from '@revenge-mod/utils/react' @@ -52,6 +52,9 @@ export function getStorage(path: string, option exists() { return FileModule.fileExists(fullPath) }, + delete() { + return FileModule.removeFile(directory, path) + }, async get() { if (!(await this.exists())) { this.cache = options?.default ?? {} @@ -119,7 +122,7 @@ export interface Storage { * The cached storage object. Set once `get()` is called, or `options.default` is set, and updated on `set()`. * You should not modify this directly. */ - cache?: AnyObject + cache?: T | AnyObject /** * Use the storage in a React component. The component will re-render when the storage is updated. * @@ -161,6 +164,10 @@ export interface Storage { * Whether the storage is exists. */ exists(): Promise + /** + * Delete the storage. + */ + delete(): Promise } export type StorageDirectory = 'cache' | 'documents'