Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Building footprints earth engine layer was showing an error even though there was no error #3144

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/layers/overlays/OverlayCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const OverlayCard = ({
isVisible,
layer: layerType,
isLoaded,
error,
loadError,
} = layer

const canEdit = layerType !== EXTERNAL_LAYER
Expand All @@ -66,11 +66,11 @@ const OverlayCard = ({
const canOpenAs = OPEN_AS_LAYER_TYPES.includes(layerType)

const getCardContent = () => {
if (error) {
if (loadError) {
return (
<div className={styles.noticebox}>
<NoticeBox error title={i18n.t('Failed to load layer')}>
<p>{error.message}</p>
<p>{loadError.message}</p>
</NoticeBox>
</div>
)
Expand Down Expand Up @@ -130,7 +130,7 @@ const OverlayCard = ({
}
: undefined
}
hasError={!!error}
hasError={!!loadError}
>
{getCardContent()}
</LayerCard>
Expand Down
4 changes: 2 additions & 2 deletions src/components/loaders/GeoJsonUrlLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ const GeoJsonUrlLoader = ({ config, onLoad }) => {

useEffect(() => {
geoJsonUrlLoader(config, engine, instanceBaseUrl).then((data) => {
if (data.error) {
if (data.loadError) {
loadFailedAlert.show({
msg: i18n.t(
'Failed to load layer "{{layername}}": {{message}}',
{
layername: data.name,
message: data.error.message || data.error,
message: data.loadError.message || data.loadError,
nsSeparator: '^^',
}
),
Expand Down
8 changes: 4 additions & 4 deletions src/loaders/geoJsonUrlLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ const geoJsonUrlLoader = async (layer, engine, instanceBaseUrl) => {
}

let geoJson
let error
let loadError

try {
geoJson = await fetchData(newConfig.url, engine, instanceBaseUrl)
} catch (err) {
error = err
loadError = err
}

const legend = {
Expand All @@ -99,14 +99,14 @@ const geoJsonUrlLoader = async (layer, engine, instanceBaseUrl) => {
...layer,
name: newConfig.name, // TODO - will be fixed by DHIS2-16088
legend,
data: (!error && buildGeoJsonFeatures(geoJson)) || [],
data: (!loadError && buildGeoJsonFeatures(geoJson)) || [],
config: newConfig,
featureStyle,
isLoaded: true,
isLoading: false,
isExpanded: true,
isVisible: true,
error,
loadError,
}
}

Expand Down
Loading