diff --git a/views/profile.handlebars b/views/profile.handlebars index 8e2b57d..1445712 100644 --- a/views/profile.handlebars +++ b/views/profile.handlebars @@ -146,21 +146,21 @@ function buildLeaderboard(leaders) { var start = '
' - var tHead = '
' + - '
Friend
' + - '
Empathetic
' + - '
Polite
' + - '
Knowledgeable
' + - '
Creative
' + + var tHead = '
' + + '
Friend
' + + '
Empathetic
' + + '
Polite
' + + '
Knowledgeable
' + + '
Creative
' + '
'; var cols = ''; leaders.forEach(friend => { var friendStats = ('
' + - '
' + friend.name + '
' + - '
' + countBadges('empathetic' , friend) + '
' + + '
' + friend.name + '
' + + '
' + countBadges('empathetic' , friend) + '
' + '
' + countBadges('polite' , friend) + '
' + - '
' + countBadges('knowledgeable', friend) + '
' + - '
' + countBadges('creative' , friend) + '
' + + '
' + countBadges('knowledgeable', friend) + '
' + + '
' + countBadges('creative' , friend) + '
' + '
'); cols += friendStats; }); @@ -226,6 +226,19 @@ $("#convo-count").text(res.length); } + // Sort the results by recency + res.sort((a, b) => { + a_info = extraInfoFromChat(a); + b_info = extraInfoFromChat(b); + + if (a_info === undefined || b_info === undefined + || a_info === null || b_info === null) { + return 0 + } + + return a_info.connectedDate - b_info.connectedDate; + }).reverse() + // Populate history form res.forEach(row => { @@ -335,7 +348,7 @@ $("#convo-button").on("click", (e) => { // This is a hack, see questions code for this onclick function. // Needed to do this so we could use function internal to questions.handlebars' script. - $('#call')[0].onclick(); + $('#call')[0].onclick(); }); getHistory();