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'