mirror of https://github.com/waku-org/js-waku.git
Log more around usage of waku store
This commit is contained in:
parent
39a0d38c9e
commit
775a288a5c
|
@ -64,22 +64,27 @@ export default function App() {
|
|||
{ peerId, protocols }: { peerId: PeerId; protocols: string[] }
|
||||
) => {
|
||||
if (protocols.includes(StoreCodec)) {
|
||||
console.log(
|
||||
`Retrieving archived messages from ${peerId.toB58String()}`
|
||||
);
|
||||
const response = await waku.store.queryHistory(peerId, [
|
||||
ChatContentTopic,
|
||||
]);
|
||||
|
||||
if (response) {
|
||||
const messages = response
|
||||
.map((wakuMsg) => wakuMsg.payload)
|
||||
.filter((payload) => !!payload)
|
||||
.map((payload) => WakuChatMessage.decode(payload as Uint8Array))
|
||||
.map((wakuChatMessage) =>
|
||||
ChatMessage.fromWakuChatMessage(wakuChatMessage)
|
||||
);
|
||||
setArchivedMessages(messages);
|
||||
console.log(`${peerId.toB58String()}: retrieving archived messages}`);
|
||||
try {
|
||||
const response = await waku.store.queryHistory(peerId, [
|
||||
ChatContentTopic,
|
||||
]);
|
||||
console.log(`${peerId.toB58String()}: messages retrieved:`, response);
|
||||
if (response) {
|
||||
const messages = response
|
||||
.map((wakuMsg) => wakuMsg.payload)
|
||||
.filter((payload) => !!payload)
|
||||
.map((payload) => WakuChatMessage.decode(payload as Uint8Array))
|
||||
.map((wakuChatMessage) =>
|
||||
ChatMessage.fromWakuChatMessage(wakuChatMessage)
|
||||
);
|
||||
setArchivedMessages(messages);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(
|
||||
`${peerId.toB58String()}: error encountered when retrieving archived messages`,
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -61,6 +61,7 @@ export class WakuStore {
|
|||
|
||||
if (!response.messages || !response.messages.length) {
|
||||
// No messages left (or stored)
|
||||
console.log('No messages present in HistoryRPC response');
|
||||
return messages;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue