Skip to content

Commit

Permalink
nombres unicos en el dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Laubot committed Oct 20, 2023
1 parent 6130d9f commit fad89ce
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@
console.error("Error getting documents: ", e);
}
}

function uniqByKeepLast(a, key) {
return [...new Map(a.map(x => [key(x), x])).values()]
}
</script>

<script>
Expand Down Expand Up @@ -214,32 +218,32 @@
var scoreWeek = getScoreboard(Date.now() - 7*24*60*60*1000);
var scoreDay = getScoreboard(Date.now() - 24*60*60*1000);

scoreAll.then(function(result) {
var json1 = JSON.stringify(result);
scoreAll.then(function(result) {
var json1 = JSON.stringify(uniqByKeepLast(result, it => it.name));
var res1 = "{\"Items\":" + json1 + "}";
MyGameInstance.SendMessage('MainMenu', 'SetAllScores', res1);
}).catch(function(err) {
console.log("err", err);
});

scoreMonth.then(function(result) {
var json2 = JSON.stringify(result);
var json2 = JSON.stringify(uniqByKeepLast(result, it => it.name));
var res2 = "{\"Items\":" + json2 + "}";
MyGameInstance.SendMessage('MainMenu', 'SetMonthScores', res2);
}).catch(function(err) {
console.log("err", err);
});

scoreWeek.then(function(result) {
var json3 = JSON.stringify(result);
var json3 = JSON.stringify(uniqByKeepLast(result, it => it.name));
var res3 = "{\"Items\":" + json3 + "}";
MyGameInstance.SendMessage('MainMenu', 'SetWeekScores', res3);
}).catch(function(err) {
console.log("err", err);
});

scoreDay.then(function(result) {
var json4 = JSON.stringify(result);
var json4 = JSON.stringify(uniqByKeepLast(result, it => it.name));
var res4 = "{\"Items\":" + json4 + "}";
MyGameInstance.SendMessage('MainMenu', 'SetDayScores', res4);
}).catch(function(err) {
Expand Down

0 comments on commit fad89ce

Please sign in to comment.