Merge pull request #280 from status-im/timestamp-chat

Demonstrate usage of history time filter in web chat
This commit is contained in:
Franck Royer 2021-08-26 13:01:32 +10:00 committed by GitHub
commit 37b8056a78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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,
}); });