mirror of
https://github.com/logos-messaging/waku-react.git
synced 2026-01-08 09:03:09 +00:00
fix types
This commit is contained in:
parent
b3e3a44420
commit
e6af793bd6
@ -3,7 +3,7 @@ import type { Waku } from "@waku/interfaces";
|
||||
|
||||
import type {
|
||||
BootstrapNodeOptions,
|
||||
CrateWakuHook,
|
||||
CrateNodeResult,
|
||||
FullNodeOptions,
|
||||
LightNodeOptions,
|
||||
RelayNodeOptions,
|
||||
@ -14,7 +14,7 @@ import {
|
||||
useCreateRelayNode,
|
||||
} from "./useCreateWaku";
|
||||
|
||||
type WakuContextType<T extends Waku> = CrateWakuHook<T>;
|
||||
type WakuContextType<T extends Waku> = CrateNodeResult<T>;
|
||||
|
||||
export const WakuContext = React.createContext<WakuContextType<Waku>>({
|
||||
node: undefined,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import type { IFilter, IDecodedMessage, IDecoder } from "@waku/interfaces";
|
||||
import type { IDecodedMessage, IDecoder, IFilter } from "@waku/interfaces";
|
||||
|
||||
import type { HookState } from "./types";
|
||||
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import React from "react";
|
||||
import type {
|
||||
StoreQueryOptions,
|
||||
IStore,
|
||||
IDecoder,
|
||||
IDecodedMessage,
|
||||
IDecoder,
|
||||
IStore,
|
||||
StoreQueryOptions,
|
||||
} from "@waku/interfaces";
|
||||
|
||||
import type { HookState } from "./types";
|
||||
|
||||
type AbstractStoreNode = {
|
||||
@ -38,29 +39,35 @@ const useStoreMessages = (
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
let cancelled: boolean = false;
|
||||
let cancelled = false;
|
||||
setLoading(true);
|
||||
|
||||
Promise
|
||||
.resolve()
|
||||
.then(async () => {
|
||||
for await (const promises of node.store.queryGenerator([decoder], options)) {
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
Promise.resolve()
|
||||
.then(async () => {
|
||||
for await (const promises of node.store.queryGenerator(
|
||||
[decoder],
|
||||
options,
|
||||
)) {
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const messagesRaw = await Promise.all(promises);
|
||||
const filteredMessages = messagesRaw.filter((v): v is IDecodedMessage => !!v);
|
||||
const messagesRaw = await Promise.all(promises);
|
||||
const filteredMessages = messagesRaw.filter(
|
||||
(v): v is IDecodedMessage => !!v,
|
||||
);
|
||||
|
||||
pushMessage(filteredMessages);
|
||||
}
|
||||
pushMessage(filteredMessages);
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
})
|
||||
setLoading(false);
|
||||
})
|
||||
.catch((err) => {
|
||||
setLoading(false);
|
||||
setError(
|
||||
`Failed to query messages from store: ${err?.message || "no message"}`,
|
||||
`Failed to query messages from store: ${
|
||||
err?.message || "no message"
|
||||
}`,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user