|
|
|
@ -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
|
|
|
|
|