wip: refactor

This commit is contained in:
Ren Amamiya
2023-08-16 11:43:04 +07:00
parent 2d53019c10
commit c05bb54976
33 changed files with 600 additions and 1052 deletions

View File

@@ -3,7 +3,6 @@ import NDK from '@nostr-dev-kit/ndk';
import { useEffect, useState } from 'react';
import TauriAdapter from '@libs/ndk/cache';
import { getExplicitRelayUrls } from '@libs/storage';
import { useStorage } from '@libs/storage/provider';
import { FULL_RELAYS } from '@stores/constants';
@@ -56,7 +55,7 @@ export const NDKInstance = () => {
async function initNDK() {
let explicitRelayUrls: string[];
const explicitRelayUrlsFromDB = await getExplicitRelayUrls();
const explicitRelayUrlsFromDB = await db.getExplicitRelayUrls();
if (explicitRelayUrlsFromDB) {
explicitRelayUrls = await verifyRelays(explicitRelayUrlsFromDB);

View File

@@ -1,5 +1,5 @@
import Database from '@tauri-apps/plugin-sql';
import destr from 'destr';
import { destr } from 'destr';
import { parser } from '@utils/parser';
import { getParentID } from '@utils/transform';

View File

@@ -184,6 +184,12 @@ export class LumeStorage {
);
}
public async removePrivkey() {
return await this.db.execute(
`UPDATE accounts SET privkey = "privkey is stored in secure storage" WHERE id = "${this.account.id}";`
);
}
public async close() {
return this.db.close();
}

View File

@@ -24,10 +24,6 @@ const StorageProvider = ({ children }: PropsWithChildren<object>) => {
useEffect(() => {
if (!db) initLumeStorage();
return () => {
db.close();
};
}, []);
if (db) {