From 5c1cda8b2af98554acb3061db1e9502c6e3a9206 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 26 Aug 2021 11:50:20 +1000 Subject: [PATCH] Demonstrate usage of history time filter in web chat --- examples/web-chat/src/App.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/web-chat/src/App.tsx b/examples/web-chat/src/App.tsx index fdc292e938..27fd4a3b08 100644 --- a/examples/web-chat/src/App.tsx +++ b/examples/web-chat/src/App.tsx @@ -61,10 +61,20 @@ async function retrieveStoreMessages( 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 { const res = await waku.store.queryHistory([ChatContentTopic], { pageSize: 5, direction: Direction.FORWARD, + timeFilter: { + startTime, + endTime, + }, callback, });