Skip to content
This repository was archived by the owner on May 2, 2025. It is now read-only.

Commit 3a53e81

Browse files
committed
Fix ui gateway location race-condition.
1 parent 154f738 commit 3a53e81

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

docs/changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 0.7.2
4+
5+
**Bugfixes:**
6+
7+
* Fix race-condition between fetching the gateway details and getting the
8+
current location if the gateway location is not yet set (UI).
9+
310
## 0.7.1
411

512
**Features & changes:**

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pages:
1515
- changelog.md
1616

1717
extra:
18-
version: '0.7.1'
18+
version: '0.7.2'
1919
github:
2020
download_release: true
2121

ui/src/components/GatewayForm.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,20 @@ class GatewayForm extends Component {
5454
gateway: this.props.gateway,
5555
});
5656

57-
if (typeof(this.state.gateway.latitude) === "undefined" || typeof(this.state.gateway.longitude) === "undefined" || this.state.gateway.latitude === 0 || this.state.gateway.longitude === 0) {
58-
this.setToCurrentPosition();
59-
}
57+
this.setToCurrentPosition(false);
6058
}
6159

62-
setToCurrentPosition() {
60+
setToCurrentPosition(overwrite) {
6361
if (navigator.geolocation) {
6462
navigator.geolocation.getCurrentPosition((position) => {
65-
let gateway = this.state.gateway;
66-
gateway.latitude = position.coords.latitude;
67-
gateway.longitude = position.coords.longitude;
68-
this.setState({
69-
gateway: gateway,
70-
});
63+
if (overwrite === true || typeof(this.state.gateway.latitude) === "undefined" || typeof(this.state.gateway.longitude) === "undefined" || this.state.gateway.latitude === 0 || this.state.gateway.longitude === 0) {
64+
let gateway = this.state.gateway;
65+
gateway.latitude = position.coords.latitude;
66+
gateway.longitude = position.coords.longitude;
67+
this.setState({
68+
gateway: gateway,
69+
});
70+
}
7171
});
7272
}
7373
}
@@ -85,7 +85,7 @@ class GatewayForm extends Component {
8585

8686
handleSetToCurrentPosition(e) {
8787
e.preventDefault();
88-
this.setToCurrentPosition();
88+
this.setToCurrentPosition(true);
8989
}
9090

9191
render() {

0 commit comments

Comments
 (0)