fix: use db instead of indexedDb

This commit is contained in:
Alejandro Gomez 2023-01-23 13:47:08 +01:00
parent e08855d9c0
commit b5f5f33a78
No known key found for this signature in database
GPG Key ID: 4DF39E566658C817
2 changed files with 5 additions and 5 deletions

View File

@ -125,7 +125,7 @@ class ReduxUsersDb implements UsersDb {
}
export const indexedDb = new IndexedDb()
const indexedDb = new IndexedDb()
export const inMemoryDb = new ReduxUsersDb()
const isIndexedDbAvailable = indexedDb.isAvailable()

View File

@ -1,11 +1,11 @@
import { useLiveQuery } from "dexie-react-hooks";
import { MetadataCache } from "State/Users";
import { indexedDb, inMemoryDb } from "State/Users/Db";
import db, { inMemoryDb } from "State/Users/Db";
import { HexKey } from "Nostr";
export function useQuery(query: string, limit: number = 5) {
const allUsers = useLiveQuery(
() => indexedDb.query(query)
() => db.query(query)
.catch((err) => {
console.error(err)
}).then(() => {
@ -21,7 +21,7 @@ export function useKey(pubKey: HexKey) {
const user = useLiveQuery(async () => {
if (pubKey) {
try {
return await indexedDb.find(pubKey);
return await db.find(pubKey);
} catch (error) {
console.error(error)
return await inMemoryDb.find(pubKey)
@ -36,7 +36,7 @@ export function useKeys(pubKeys: HexKey[]): Map<HexKey, MetadataCache> {
const dbUsers = useLiveQuery(async () => {
if (pubKeys) {
try {
const ret = await indexedDb.bulkGet(pubKeys);
const ret = await db.bulkGet(pubKeys);
return new Map(ret.map(a => [a.pubkey, a]))
} catch (error) {
console.error(error)