From 38769a77bc4cd2a15ae45209635b99f23196337c Mon Sep 17 00:00:00 2001 From: J M Rossy Date: Wed, 9 Oct 2024 17:11:52 -0400 Subject: [PATCH] fix: Filter old msgs while DB is backfilling (#116) https://discord.com/channels/935678348330434570/1293671472900083785/1293678199858925599 --- src/features/messages/queries/parse.ts | 4 +++- src/features/messages/queries/useMessageQuery.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/features/messages/queries/parse.ts b/src/features/messages/queries/parse.ts index 487ba5b..25bfac5 100644 --- a/src/features/messages/queries/parse.ts +++ b/src/features/messages/queries/parse.ts @@ -31,7 +31,9 @@ export function parseMessageStubResult( .flat() .map((m) => parseMessageStub(multiProvider, scrapedChains, m)) .filter((m): m is MessageStub => !!m) - .sort((a, b) => b.origin.timestamp - a.origin.timestamp); + .sort((a, b) => b.origin.timestamp - a.origin.timestamp) + .filter((m) => Date.now() - m.origin.timestamp < 1000 * 60 * 60) // filter out messages older than 1 hour + .slice(0, 20); } export function parseMessageQueryResult( diff --git a/src/features/messages/queries/useMessageQuery.ts b/src/features/messages/queries/useMessageQuery.ts index 08e26b7..4760a54 100644 --- a/src/features/messages/queries/useMessageQuery.ts +++ b/src/features/messages/queries/useMessageQuery.ts @@ -18,7 +18,7 @@ import { parseMessageQueryResult, parseMessageStubResult } from './parse'; const SEARCH_AUTO_REFRESH_DELAY = 15_000; // 15s const MSG_AUTO_REFRESH_DELAY = 10_000; // 10s -const LATEST_QUERY_LIMIT = 20; +const LATEST_QUERY_LIMIT = 100; const SEARCH_QUERY_LIMIT = 50; export function isValidSearchQuery(input: string, allowAddress?: boolean) {