socialnetworknews-web

A open-source Paper.li clone
git clone git://archive.git.mtrnord.blog/SocialNetworkNews/socialnetworknews-web.git
Log | Files | Refs | README | LICENSE

commit 2b4c1a272468fe2cecfca074f92e730b572e6677
parent 3c41016d5dbea9a5006c2e077958b6beca530280
Author: MTRNord <mtrnord1@gmail.com>
Date:   Mon, 26 Mar 2018 18:17:00 +0200

Try to sort the items first

Diffstat:
Msrc/app/tweet-list/tweet-list.component.ts | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/app/tweet-list/tweet-list.component.ts b/src/app/tweet-list/tweet-list.component.ts @@ -97,6 +97,18 @@ export class TweetListComponent implements OnInit { } private chunk(arr: (TweetsEntity)[], size: number): (TweetsEntity)[][] { + // Todo sort with a point system + const compare = (a, b): number => { + if ((a.image_urls && a.image_urls[0]) && !(b.image_urls && b.image_urls[0])) { + return -1; + } + if (!(a.image_urls && a.image_urls[0]) && (b.image_urls && b.image_urls[0])) { + return 1; + } + return 0; + }; + + arr.sort(compare); const newArr = []; for (let i = 0; i < arr.length; i += size) { newArr.push(arr.slice(i, i + size));