chore(store-reactjs-chat): bump js-waku to 0.28.0

This commit is contained in:
fryorcraken.eth 2022-09-16 12:21:19 +10:00
parent 439e6cb708
commit a3fc334f97
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
3 changed files with 36 additions and 28 deletions

View File

@ -7,7 +7,7 @@
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.2.0",
"@testing-library/user-event": "^14.1.1",
"js-waku": "0.27.0",
"js-waku": "0.28.0",
"protobufjs": "^7.1.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",

View File

@ -5,7 +5,7 @@ specifiers:
'@testing-library/jest-dom': ^5.16.4
'@testing-library/react': ^13.2.0
'@testing-library/user-event': ^14.1.1
js-waku: 0.27.0
js-waku: 0.28.0
protobufjs: ^7.1.0
react: ^18.1.0
react-dom: ^18.1.0
@ -17,7 +17,7 @@ dependencies:
'@testing-library/jest-dom': 5.16.5
'@testing-library/react': 13.3.0_biqbaboplfbrettd7655fr4n2y
'@testing-library/user-event': 14.4.2_znfriv3ismgf3ybh2woqwlpfea
js-waku: 0.27.0
js-waku: 0.28.0
protobufjs: 7.1.0
react: 18.2.0
react-dom: 18.2.0_react@18.2.0
@ -7375,8 +7375,8 @@ packages:
/js-tokens/4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
/js-waku/0.27.0:
resolution: {integrity: sha512-uIh1h2Gu+aEyrGb4qmyk2Sc91in3fMfOil0kdtrps9HnA7ESbC5c6d148LeJaxqH5rfOkrfXXIhw1zwA3hlauw==}
/js-waku/0.28.0:
resolution: {integrity: sha512-MEIFugvio2IaQMQT+g+bn24BvlJ5S4PdSKD0AGVZlR7q1BhECwlpRoytyz0A/hC1+EJWhrZB8cpIAmxwtYWTBw==}
engines: {node: '>=16'}
dependencies:
'@chainsafe/libp2p-gossipsub': 4.1.1

View File

@ -55,32 +55,40 @@ function App() {
React.useEffect(() => {
if (wakuStatus !== "Connected") return;
const processMessages = (retrievedMessages) => {
const messages = retrievedMessages.map(decodeMessage).filter(Boolean);
(async () => {
const startTime = new Date();
// 7 days/week, 24 hours/day, 60min/hour, 60secs/min, 100ms/sec
startTime.setTime(startTime.getTime() - 7 * 24 * 60 * 60 * 1000);
setMessages((currentMessages) => {
return currentMessages.concat(messages.reverse());
});
};
// TODO: Remove this timeout once https://github.com/status-im/js-waku/issues/913 is done
await new Promise((resolve) => setTimeout(resolve, 200));
const startTime = new Date();
// 7 days/week, 24 hours/day, 60min/hour, 60secs/min, 100ms/sec
startTime.setTime(startTime.getTime() - 7 * 24 * 60 * 60 * 1000);
// TODO: Remove this timeout once https://github.com/status-im/js-waku/issues/913 is done
setTimeout(
() =>
waku.store
.queryHistory([ContentTopic], {
callback: processMessages,
try {
for await (const messagesPromises of waku.store.queryGenerator(
[ContentTopic],
{
timeFilter: { startTime, endTime: new Date() },
})
.catch((e) => {
console.log("Failed to retrieve messages", e);
setWakuStatus("Error Encountered");
}),
200
);
pageDirection: "forward",
}
)) {
const messages = await Promise.all(
messagesPromises
.map(async (p) => {
const msg = await p;
return decodeMessage(msg);
})
.filter(Boolean)
);
setMessages((currentMessages) => {
return currentMessages.concat(messages.reverse());
});
}
} catch (e) {
console.log("Failed to retrieve messages", e);
setWakuStatus("Error Encountered");
}
})();
}, [waku, wakuStatus]);
return (