|
@ -12,9 +12,7 @@ export default class ScoreRepo { |
|
|
|
|
|
|
|
|
updateScoreCache = (newScore) => { |
|
|
updateScoreCache = (newScore) => { |
|
|
this.scoreCache.push(newScore); |
|
|
this.scoreCache.push(newScore); |
|
|
this.scoreCache.sort((a, b) => { |
|
|
this.scoreCache.sort((a, b) => b.value - a.value); |
|
|
a.value < b.value |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (this.scoreCache.length > 99) { |
|
|
if (this.scoreCache.length > 99) { |
|
|
this.scoreCache = this.scoreCache.slice(99, this.scoreCache.length - 1); |
|
|
this.scoreCache = this.scoreCache.slice(99, this.scoreCache.length - 1); |
|
@ -33,15 +31,7 @@ export default class ScoreRepo { |
|
|
this.updateScoreCache(newScore); |
|
|
this.updateScoreCache(newScore); |
|
|
|
|
|
|
|
|
this.realmDB.write(() => { |
|
|
this.realmDB.write(() => { |
|
|
this.realmDB.create( |
|
|
this.realmDB.create( ScoreEntity.name, newScore, true); |
|
|
ScoreEntity.name, |
|
|
|
|
|
{ |
|
|
|
|
|
id: scoreID, |
|
|
|
|
|
user: user, |
|
|
|
|
|
value: score, |
|
|
|
|
|
}, |
|
|
|
|
|
true, |
|
|
|
|
|
); |
|
|
|
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|