fix: use db instead of indexedDb
This commit is contained in:
parent
e08855d9c0
commit
b5f5f33a78
@ -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()
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user