commit 15fe4462d67f30804b5c7feae385330ce9643c6b
parent 1199572f012e85370c8975a1eded9348f2203dfd
Author: MTRNord <mtrnord1@gmail.com>
Date: Mon, 26 Mar 2018 19:02:18 +0200
Check if flex now wraps like expected
Diffstat:
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/app/tweet-list/tweet-list.component.html b/src/app/tweet-list/tweet-list.component.html
@@ -1,6 +1,6 @@
<spinner spinner="spinner"></spinner>
-<div *ngFor="let row of data" class="grid">
- <mat-card *ngFor="let item of row" style="max-width: 350px;">
+<div class="grid">
+ <mat-card *ngFor="let item of data" style="max-width: 350px;">
<div class="ribbon ribbon-top-right" *ngIf="item.retweet" style="max-width: 22rem">
<span>
<i class="fa fa-retweet"></i>
diff --git a/src/app/tweet-list/tweet-list.component.ts b/src/app/tweet-list/tweet-list.component.ts
@@ -19,7 +19,7 @@ import {Lightbox} from '../utils/lightbox';
})
export class TweetListComponent implements OnInit {
@Input() uuid;
- data: (TweetsEntity)[][];
+ data: (TweetsEntity)[];
paperData: Paper;
constructor(private apiService: ApiService, private toastr: ToastrService, private lightbox: Lightbox) {
@@ -84,7 +84,7 @@ export class TweetListComponent implements OnInit {
.concat(Observable.throw({error: 'Sorry, there was an error (after 5 retries). This probably means we can\'t reach our API Server :('}));
})
.subscribe(
- data => { this.data = this.chunk(data.tweets, 3); },
+ data => { this.data = this.sort(data.tweet); },
err => {
this.toastr.error(err['error'], 'Error connecting API', {
positionClass: 'toast-top-center',
@@ -96,6 +96,21 @@ export class TweetListComponent implements OnInit {
);
}
+ private sort(arr: (TweetsEntity)[]): (TweetsEntity)[] {
+ 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);
+ return arr
+ }
+
private chunk(arr: (TweetsEntity)[], size: number): (TweetsEntity)[][] {
// Todo sort with a point system
const compare = (a, b): number => {