Skip to content

Commit

Permalink
Merge pull request #1115 from geoadmin/pb-1120-layer-error-are-not-em…
Browse files Browse the repository at this point in the history
…ptied

PB-1120: Remove error key when the extent is valid.
  • Loading branch information
ismailsunni authored Nov 11, 2024
2 parents a54bbc0 + e2f6721 commit a20fe74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/api/layers/AbstractLayer.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,13 @@ export default class AbstractLayer {

/** @param {ErrorMessage} errorMessage */
removeErrorMessage(errorMessage) {
this.errorMessages.delete(errorMessage)
// We need to find the error message that equals to remove it
for (let msg of this.errorMessages) {
if (msg.isEquals(errorMessage)) {
this.errorMessages.delete(msg)
break
}
}
this.hasError = !!this.errorMessages.size
}

Expand Down
10 changes: 8 additions & 2 deletions src/store/modules/layers.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,16 +771,22 @@ const actions = {
}
clone.isLoading = false

// Always clean up the error messages before doing the check
const emptyFileErrorMessage = new ErrorMessage('kml_gpx_file_empty')
const outOfBoundsErrorMessage = new ErrorMessage('imported_file_out_of_bounds')
clone.removeErrorMessage(emptyFileErrorMessage)
clone.removeErrorMessage(outOfBoundsErrorMessage)

if (!extent) {
clone.addErrorMessage(new ErrorMessage('kml_gpx_file_empty'))
clone.addErrorMessage(emptyFileErrorMessage)
} else if (
!getExtentIntersectionWithCurrentProjection(
extent,
WGS84,
rootState.position.projection
)
) {
clone.addErrorMessage(new ErrorMessage('imported_file_out_of_bounds'))
clone.addErrorMessage(outOfBoundsErrorMessage)
}
}
if (metadata) {
Expand Down

0 comments on commit a20fe74

Please sign in to comment.