-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Labels
Description
Render user's time top, average and median score
There should be dropdown to allow the user to see top, average and median from a time range:
- Last 24 hours
- Last month
- All time
User sessions are stored in
Lines 187 to 218 in 1f8c297
| async saveScore() { | |
| try { | |
| const { user } = this.props; | |
| if (!user.uid) return this.setState({ authError: true }); | |
| this.setState({ authError: false, error: '' }); | |
| const { score } = this.state; | |
| // a string in the format 2018-10-26 | |
| const sessionId = (new Date()).toISOString().slice(0,10); | |
| // store record in Firebase | |
| await firebase | |
| .database() | |
| .ref('user-score') | |
| .child(user.uid) | |
| .child(sessionId) | |
| .push({ | |
| score, | |
| timestamp: firebase.database.ServerValue.TIMESTAMP | |
| }); | |
| this.updateScoreboard(user, score) | |
| } catch (err) { | |
| console.error(err); | |
| this.setState({ | |
| error: | |
| 'Something went wrong while saving score, please contact support!' | |
| }); | |
| } | |
| } |
Reactions are currently unavailable