Skip to content
Snippets Groups Projects
Commit 8325736c authored by Taneli Riihimäki's avatar Taneli Riihimäki
Browse files

Minor bugfixes, still need some fixin (if you change a game from the list...

Minor bugfixes, still need some fixin (if you change a game from the list while you are tracking, it will break)
parent dd567ded
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,8 @@ class GameList extends Component { ...@@ -25,7 +25,8 @@ class GameList extends Component {
.then(response => response.json()) .then(response => response.json())
.then(games => { .then(games => {
this.setState({ this.setState({
games games,
selectedGame: games[0]
}); });
}) })
.catch(error => { .catch(error => {
...@@ -39,7 +40,11 @@ class GameList extends Component { ...@@ -39,7 +40,11 @@ class GameList extends Component {
startTracking() { startTracking() {
this.intervalID = setInterval(() => { this.intervalID = setInterval(() => {
console.log("Nyt träkätää nim birusti."); console.log("Valittu peli: " + this.state.selectedGame);
console.log(
"Nyt träkätää nim birusti peliä: " + this.state.selectedGame.name
);
console.log("Tracking: " + this.state.tracking);
}, 3000); }, 3000);
} }
...@@ -65,12 +70,13 @@ class GameList extends Component { ...@@ -65,12 +70,13 @@ class GameList extends Component {
<Picker <Picker
style={styles.picker} style={styles.picker}
selectedValue={this.state.selectedGame} selectedValue={this.state.selectedGame}
onValueChange={(selectedGame, itemIndex) => onValueChange={(selectedGame, itemIndex) => {
this.setState({ selectedGame }) clearInterval(this.intervalID);
} this.setState({ selectedGame, tracking: "false" });
}}
> >
{this.state.games.map(game => ( {this.state.games.map(game => (
<Picker.Item label={game.name} value={game.id} /> <Picker.Item label={game.name} value={game} />
))} ))}
</Picker> </Picker>
<LocationTracker <LocationTracker
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment