From 37c97b6ba57b51c37274e77e5233068d10964962 Mon Sep 17 00:00:00 2001 From: J M Rossy Date: Sun, 5 Mar 2023 14:11:34 +0100 Subject: [PATCH] Add loading state to message search --- .../{SearchError.tsx => SearchStates.tsx} | 21 ++++++++++++++++++ src/features/debugger/TxDebugger.tsx | 2 +- src/features/messages/MessageSearch.tsx | 22 +++++++++++++------ 3 files changed, 37 insertions(+), 8 deletions(-) rename src/components/search/{SearchError.tsx => SearchStates.tsx} (74%) diff --git a/src/components/search/SearchError.tsx b/src/components/search/SearchStates.tsx similarity index 74% rename from src/components/search/SearchError.tsx rename to src/components/search/SearchStates.tsx index 3e02b7c..efee1e6 100644 --- a/src/components/search/SearchError.tsx +++ b/src/components/search/SearchStates.tsx @@ -5,6 +5,27 @@ import ErrorIcon from '../../images/icons/error-circle.svg'; import SearchOffIcon from '../../images/icons/search-off.svg'; import ShrugIcon from '../../images/icons/shrug.svg'; import { Fade } from '../animation/Fade'; +import { Spinner } from '../animation/Spinner'; + +export function SearchFetching({ show, isPiFetching }: { show: boolean; isPiFetching?: boolean }) { + return ( + // Absolute position for overlaying cross-fade +
+ +
+
+
+ +
+
+ {isPiFetching ? 'Searching custom chains for messages' : 'Searching for messages'} +
+
+
+
+
+ ); +} export function SearchError({ show, diff --git a/src/features/debugger/TxDebugger.tsx b/src/features/debugger/TxDebugger.tsx index da93ebe..5fb0b43 100644 --- a/src/features/debugger/TxDebugger.tsx +++ b/src/features/debugger/TxDebugger.tsx @@ -10,7 +10,7 @@ import { SearchEmptyError, SearchInvalidError, SearchUnknownError, -} from '../../components/search/SearchError'; +} from '../../components/search/SearchStates'; import ShrugIcon from '../../images/icons/shrug.svg'; import { useStore } from '../../store'; import useDebounce from '../../utils/debounce'; diff --git a/src/features/messages/MessageSearch.tsx b/src/features/messages/MessageSearch.tsx index 9409777..d23e8de 100644 --- a/src/features/messages/MessageSearch.tsx +++ b/src/features/messages/MessageSearch.tsx @@ -2,12 +2,13 @@ import { useState } from 'react'; import { Fade } from '../../components/animation/Fade'; import { SearchBar } from '../../components/search/SearchBar'; +import { SearchFilterBar } from '../../components/search/SearchFilterBar'; import { SearchEmptyError, + SearchFetching, SearchInvalidError, SearchUnknownError, -} from '../../components/search/SearchError'; -import { SearchFilterBar } from '../../components/search/SearchFilterBar'; +} from '../../components/search/SearchStates'; import useDebounce from '../../utils/debounce'; import { useQueryParam, useSyncQueryParam } from '../../utils/queryParams'; import { sanitizeString } from '../../utils/string'; @@ -54,6 +55,9 @@ export function MessageSearch() { isMessagesFound || isFetching, ); + // Coalesce GraphQL + PI results + const isAnyFetching = isFetching || isPiFetching; + const isAnyError = isError || isPiError; const isAnyMessageFound = isMessagesFound || piMessageList.length > 0; const messageListResult = isMessagesFound ? messageList : piMessageList; console.log(isPiError, isPiFetching, piMessageList); @@ -66,7 +70,7 @@ export function MessageSearch() {
@@ -85,15 +89,19 @@ export function MessageSearch() { onChangeEndTimestamp={setEndTimeFilter} />
- - + + + - +