diff --git a/dev-client/__tests__/snapshot/__snapshots__/SiteTabsScreen-test.tsx.snap b/dev-client/__tests__/snapshot/__snapshots__/SiteTabsScreen-test.tsx.snap index 4c86b9d1a..0727e4884 100644 --- a/dev-client/__tests__/snapshot/__snapshots__/SiteTabsScreen-test.tsx.snap +++ b/dev-client/__tests__/snapshot/__snapshots__/SiteTabsScreen-test.tsx.snap @@ -1991,9 +1991,13 @@ exports[`renders correctly 1`] = ` - Loading… + Not available offline - Loading… + Not available offline { + const isOffline = useIsOffline(); if (status === 'loading') { - return loading; + /* + * Don't show a loading indicator when offline. Other statuses indicate a completed Soil ID API call, + * which are Ok to display to the user even in offline mode. + */ + return isOffline ? offline : loading; } else if (status === 'error') { return error; } else if (status === 'DATA_UNAVAILABLE') { diff --git a/dev-client/src/screens/LocationScreens/components/LocationSoilIdCard.tsx b/dev-client/src/screens/LocationScreens/components/LocationSoilIdCard.tsx index bd49e0fdc..8fd804bf5 100644 --- a/dev-client/src/screens/LocationScreens/components/LocationSoilIdCard.tsx +++ b/dev-client/src/screens/LocationScreens/components/LocationSoilIdCard.tsx @@ -137,6 +137,7 @@ const MatchContent = ({ {t('general.not_available_offine')}} loading={{t('soil.loading')}} error={{t('soil.error')}} noData={{t('soil.no_matches')}} @@ -151,6 +152,7 @@ const MatchContent = ({ {t('soil.ecological_site_name')}: {t('general.not_available_offine')}} loading={{t('soil.loading')}} error={{t('soil.error')}} noData={{t('soil.no_matches')}} diff --git a/dev-client/src/screens/LocationScreens/components/soilId/SoilIdMatchesSection.tsx b/dev-client/src/screens/LocationScreens/components/soilId/SoilIdMatchesSection.tsx index e17efc9c1..ed4bbec5c 100644 --- a/dev-client/src/screens/LocationScreens/components/soilId/SoilIdMatchesSection.tsx +++ b/dev-client/src/screens/LocationScreens/components/soilId/SoilIdMatchesSection.tsx @@ -28,6 +28,7 @@ import { Heading, Row, } from 'terraso-mobile-client/components/NativeBaseAdapters'; +import {RestrictByConnectivity} from 'terraso-mobile-client/components/restrictions/RestrictByConnectivity'; import {InfoSheet} from 'terraso-mobile-client/components/sheets/InfoSheet'; import {SiteRoleContextProvider} from 'terraso-mobile-client/context/SiteRoleContext'; import {useIsOffline} from 'terraso-mobile-client/hooks/connectivityHooks'; @@ -65,26 +66,23 @@ export const SoilIdMatchesSection = ({ - + + + + ); }; -const MatchTilesOrMessage = ({siteId, coords}: SoilIdMatchesSectionProps) => { +const MatchTiles = ({siteId, coords}: SoilIdMatchesSectionProps) => { const isOffline = useIsOffline(); - const {t} = useTranslation(); - const soilIdData = useSoilIdData(coords, siteId); const status = soilIdData.status; const isSite = !!siteId; - if (isOffline) { - return ; - } - switch (status) { case 'loading': - return ; + return isOffline ? <> : ; case 'ready': { if (isSite) { return getSortedDataBasedMatches(soilIdData).map(dataMatch => ( diff --git a/dev-client/src/screens/LocationScreens/components/soilInfo/PropertiesScoreDisplay.tsx b/dev-client/src/screens/LocationScreens/components/soilInfo/PropertiesScoreDisplay.tsx index d74ba28b3..343b17622 100644 --- a/dev-client/src/screens/LocationScreens/components/soilInfo/PropertiesScoreDisplay.tsx +++ b/dev-client/src/screens/LocationScreens/components/soilInfo/PropertiesScoreDisplay.tsx @@ -31,9 +31,9 @@ import { Heading, Row, } from 'terraso-mobile-client/components/NativeBaseAdapters'; +import {RestrictByConnectivity} from 'terraso-mobile-client/components/restrictions/RestrictByConnectivity'; import {rowsFromSoilIdData} from 'terraso-mobile-client/components/tables/soilProperties/SoilPropertiesData'; import {SoilPropertiesDataTable} from 'terraso-mobile-client/components/tables/soilProperties/SoilPropertiesDataTable'; -import {useIsOffline} from 'terraso-mobile-client/hooks/connectivityHooks'; import {OfflineMessageBox} from 'terraso-mobile-client/screens/LocationScreens/components/soilId/messageBoxes/OfflineMessageBox'; import {ScoreTile} from 'terraso-mobile-client/screens/LocationScreens/components/soilInfo/ScoreTile'; import {SoilPropertiesScoreInfoContent} from 'terraso-mobile-client/screens/LocationScreens/components/soilInfo/SoilPropertiesScoreInfoContent'; @@ -53,8 +53,6 @@ export function PropertiesScoreDisplay({ [match.soilInfo.soilData], ); - const isOffline = useIsOffline(); - return ( @@ -72,13 +70,12 @@ export function PropertiesScoreDisplay({ - {isOffline ? ( + - ) : ( - - )} + + ); } diff --git a/dev-client/src/screens/SitesScreen/components/TemporaryLocationCallout.tsx b/dev-client/src/screens/SitesScreen/components/TemporaryLocationCallout.tsx index 91bd429f7..ddc73126b 100644 --- a/dev-client/src/screens/SitesScreen/components/TemporaryLocationCallout.tsx +++ b/dev-client/src/screens/SitesScreen/components/TemporaryLocationCallout.tsx @@ -95,43 +95,29 @@ export const TemporaryLocationCallout = ({ - ) : ( - - ) + } /> - ) : ( - - ) + } /> - ) : ( - - ) - } + value={} /> @@ -157,20 +143,21 @@ export const TemporaryLocationCallout = ({ ); }; -type SoilIdStatusDisplayElevationProps = { +type ElevationDisplayProps = { elevation: ElevationRecord; t: TFunction; }; -const ElevationDisplay = ({ - elevation, - t, -}: SoilIdStatusDisplayElevationProps) => { - if (elevation.fetching) { +const ElevationDisplay = ({elevation, t}: ElevationDisplayProps) => { + const isOffline = useIsOffline(); + + if (isOffline) { + return ; + } else if (elevation.fetching) { return ; + } else { + return {renderElevation(t, elevation.value)}; } - - return {renderElevation(t, elevation.value)}; }; type SoilIdStatusDisplayTopMatchProps = { @@ -187,6 +174,7 @@ const TopSoilMatchDisplay = ({ return ( } loading={} error={ @@ -215,6 +203,7 @@ const EcologicalSiteMatchDisplay = ({ return ( } loading={} error={ diff --git a/dev-client/src/translations/en.json b/dev-client/src/translations/en.json index 0d706cb84..cb4bcd4df 100644 --- a/dev-client/src/translations/en.json +++ b/dev-client/src/translations/en.json @@ -125,8 +125,7 @@ "native_lands_intro": "Soil resources for Native lands:", "native_lands_link": "nativeland.info", "native_lands_url": "https://nativeland.info/", - "offline_title": "You are offline", - "offline_body": "Soil matches will update here when you are online.", + "offline": "Soil matches will update when you are online.", "selector": "This is the correct soil", "selected": "Selected Soil" }, diff --git a/dev-client/src/translations/es.json b/dev-client/src/translations/es.json index a67741033..ff97f2634 100644 --- a/dev-client/src/translations/es.json +++ b/dev-client/src/translations/es.json @@ -153,8 +153,7 @@ "native_lands_intro": "Recursos de suelos para las tierras indígenas:", "native_lands_link": "nativeland.info", "native_lands_url": "https://nativeland.info/", - "offline_title": "Estás fuera de linea", - "offline_body": "Las coincidencias de suelos se actualizarán aquí cuando estás sin conexión.", + "offline": "Las coincidencias de suelos se actualizarán aquí cuando estás sin conexión.", "selector": "This is the correct soil", "selected": "Selected Soil" },