X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FNews.vue;h=0e3c3c7ae08d18811849d5ee6d0898d25ebd902e;hp=ec1517df9e81bdaa9913a5279e0f097c6436bb30;hb=0234201fb338fc239d6f613c677fa932c7c3697c;hpb=585d095517ca2aedab8ad125cc7c39b90e13d5cc diff --git a/client/src/views/News.vue b/client/src/views/News.vue index ec1517df..0e3c3c7a 100644 --- a/client/src/views/News.vue +++ b/client/src/views/News.vue @@ -48,8 +48,10 @@ export default { return { devs: [1], //for now the only dev is me st: store.state, - cursor: 0, //ID of last showed news - hasMore: true, //a priori there could be more news to load + // timestamp of oldest showed news: + cursor: Number.MAX_SAFE_INTEGER, + // hasMore == TRUE: a priori there could be more news to load + hasMore: true, curnews: { id: 0, content: "" }, newsList: [], infoMsg: "" @@ -62,9 +64,10 @@ export default { { data: { cursor: this.cursor }, success: (res) => { - this.newsList = res.newsList.sort((n1, n2) => n2.added - n1.added); + // The returned list is sorted from most recent to oldest + this.newsList = res.newsList; const L = res.newsList.length; - if (L > 0) this.cursor = this.newsList[0].id; + if (L > 0) this.cursor = res.newsList[L - 1].added; } } ); @@ -169,7 +172,7 @@ export default { if (res.newsList.length > 0) { this.newsList = this.newsList.concat(res.newsList); const L = res.newsList.length; - if (L > 0) this.cursor = res.newsList[L - 1].id; + if (L > 0) this.cursor = res.newsList[L - 1].added; } else this.hasMore = false; } }