diff --git a/src/features/messages/queries/parse.ts b/src/features/messages/queries/parse.ts index 25bfac5..487ba5b 100644 --- a/src/features/messages/queries/parse.ts +++ b/src/features/messages/queries/parse.ts @@ -31,9 +31,7 @@ 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) - .filter((m) => Date.now() - m.origin.timestamp < 1000 * 60 * 60) // filter out messages older than 1 hour - .slice(0, 20); + .sort((a, b) => b.origin.timestamp - a.origin.timestamp); } export function parseMessageQueryResult( diff --git a/src/features/messages/queries/useMessageQuery.ts b/src/features/messages/queries/useMessageQuery.ts index 4760a54..cfbe100 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 = 100; +const LATEST_QUERY_LIMIT = 90; const SEARCH_QUERY_LIMIT = 50; export function isValidSearchQuery(input: string, allowAddress?: boolean) { @@ -63,10 +63,26 @@ export function useMessageSearchQuery( // Parse results const multiProvider = useMultiProvider(); - const messageList = useMemo( + const unfilteredMessageList = useMemo( () => parseMessageStubResult(multiProvider, scrapedChains, data), [multiProvider, scrapedChains, data], ); + + // Filter recent messages during DB backfilling period + // TODO remove this once backfilling is complete + const hasFilter = !!( + originChainFilter || + destinationChainFilter || + startTimeFilter || + endTimeFilter + ); + const messageList = useMemo(() => { + if (hasInput || hasFilter) return unfilteredMessageList; + return unfilteredMessageList + .filter((m) => Date.now() - m.origin.timestamp < 1000 * 60 * 60) // filter out messages older than 1 hour + .slice(0, 20); + }, [hasInput, hasFilter, unfilteredMessageList]); + const isMessagesFound = messageList.length > 0; // Setup interval to re-query