From ad8904832066adcb0157e1493fe357418548f33f Mon Sep 17 00:00:00 2001 From: Tim Glasgow Date: Tue, 9 Aug 2022 09:27:49 -0500 Subject: [PATCH] score cache sorting --- squarenotsquare/src/realm/repos/ScoreRepo.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/squarenotsquare/src/realm/repos/ScoreRepo.js b/squarenotsquare/src/realm/repos/ScoreRepo.js index 5063065..9138270 100644 --- a/squarenotsquare/src/realm/repos/ScoreRepo.js +++ b/squarenotsquare/src/realm/repos/ScoreRepo.js @@ -12,9 +12,7 @@ export default class ScoreRepo { updateScoreCache = (newScore) => { this.scoreCache.push(newScore); - this.scoreCache.sort((a, b) => { - a.value < b.value - }); + this.scoreCache.sort((a, b) => b.value - a.value); if (this.scoreCache.length > 99) { this.scoreCache = this.scoreCache.slice(99, this.scoreCache.length - 1); @@ -33,15 +31,7 @@ export default class ScoreRepo { this.updateScoreCache(newScore); this.realmDB.write(() => { - this.realmDB.create( - ScoreEntity.name, - { - id: scoreID, - user: user, - value: score, - }, - true, - ); + this.realmDB.create( ScoreEntity.name, newScore, true); }); }