Demonstrate usage of history time filter in web chat

This commit is contained in:
Franck Royer 2021-08-26 11:50:20 +10:00
parent 93afc969d3
commit 5c1cda8b2a
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 10 additions and 0 deletions

View File

@ -61,10 +61,20 @@ async function retrieveStoreMessages(
setArchivedMessages(messages); setArchivedMessages(messages);
}; };
const startTime = new Date();
// Only retrieve a week of history
startTime.setTime(Date.now() - 1000 * 60 * 60 * 24 * 7);
const endTime = new Date();
try { try {
const res = await waku.store.queryHistory([ChatContentTopic], { const res = await waku.store.queryHistory([ChatContentTopic], {
pageSize: 5, pageSize: 5,
direction: Direction.FORWARD, direction: Direction.FORWARD,
timeFilter: {
startTime,
endTime,
},
callback, callback,
}); });