From 5ada347d12c24339a1fa1ee4d2da2a30eeb5c4bf Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Fri, 21 Jan 2022 15:11:13 +0100
Subject: [PATCH] fix(news): clean code and remove unecesary api call for
 'a-la-une' tag

---
 .../post-card/post-card.component.html          |  2 +-
 .../post-card/post-card.component.scss          |  1 -
 .../post-details/post-details.component.scss    |  3 +--
 .../components/post-list/post-list.component.ts | 17 +++--------------
 4 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/src/app/post/components/post-card/post-card.component.html b/src/app/post/components/post-card/post-card.component.html
index c6b32c5a1..22ebc401e 100644
--- a/src/app/post/components/post-card/post-card.component.html
+++ b/src/app/post/components/post-card/post-card.component.html
@@ -30,7 +30,7 @@
     <div fxLayout="column" class="informations">
       <div>{{ post.author }}</div>
       <div>
-        {{ post.updated_at | date: 'dd MMM y' }}
+        {{ post.updated_at | date: 'd MMM y' }}
       </div>
     </div>
   </div>
diff --git a/src/app/post/components/post-card/post-card.component.scss b/src/app/post/components/post-card/post-card.component.scss
index 394089ce2..68ff9e687 100644
--- a/src/app/post/components/post-card/post-card.component.scss
+++ b/src/app/post/components/post-card/post-card.component.scss
@@ -44,7 +44,6 @@
   .informations {
     @include cn-regular-16;
     div:nth-child(2n) {
-      text-transform: uppercase;
       color: $grey-3;
     }
   }
diff --git a/src/app/post/components/post-details/post-details.component.scss b/src/app/post/components/post-details/post-details.component.scss
index c06de925a..59262dbe3 100644
--- a/src/app/post/components/post-details/post-details.component.scss
+++ b/src/app/post/components/post-details/post-details.component.scss
@@ -34,7 +34,6 @@ $margin-post: 20px;
 .informations {
   @include cn-regular-16;
   div:nth-child(2n) {
-    text-transform: uppercase;
     color: $grey-3;
   }
 }
@@ -201,7 +200,7 @@ $margin-post: 20px;
 .gh-canvas .article-image {
   grid-column: wide-start/wide-end;
   width: 100%;
-  margin: 6vmin 0 0;
+  margin: 4vmin 0 0;
   img {
     display: block;
     margin-left: auto;
diff --git a/src/app/post/components/post-list/post-list.component.ts b/src/app/post/components/post-list/post-list.component.ts
index f1b0ffb90..77a3b17da 100644
--- a/src/app/post/components/post-list/post-list.component.ts
+++ b/src/app/post/components/post-list/post-list.component.ts
@@ -21,9 +21,6 @@ export class PostListComponent implements OnInit {
   public selectedPublicTagsSlug = [];
   public filters: Tag[];
   public allPosts: Post[] = [];
-  public leftColumnPosts: Post[] = [];
-  public rightColumnPosts: Post[] = [];
-  public bigNews: Post;
   public pagination: Pagination;
   public isLoading = false;
   public isPublishMode = false;
@@ -46,11 +43,6 @@ export class PostListComponent implements OnInit {
   ngOnInit(): void {
     this.isLoading = true;
     // Init APP news list
-    this.postService.getPosts(1, [TagEnum.aLaUne]).subscribe((news) => {
-      if (news.posts[0]) {
-        this.bigNews = this.addAuthorToPost(news.posts[0]);
-      }
-    });
     this.route.queryParams.subscribe((queryParams) => {
       this.isPublishMode = false;
       // If main tag is in route, set it
@@ -70,7 +62,8 @@ export class PostListComponent implements OnInit {
         // Init default news list
         this.postService.getPosts(1).subscribe((news) => {
           this.setNews(news);
-          this.allPosts.unshift(this.bigNews);
+          const headLineTag = this.allPosts.find((post: Post) => post.tags.some((tag) => tag.slug === TagEnum.aLaUne));
+          this.allPosts.unshift(headLineTag);
         });
       }
     });
@@ -113,14 +106,10 @@ export class PostListComponent implements OnInit {
   }
 
   public resetPosts(): void {
-    this.leftColumnPosts = [];
-    this.rightColumnPosts = [];
     this.allPosts = [];
   }
 
-  public publishNews(): void {}
-
-  //Transform excerpt post to have a custom author.
+  // Transform excerpt post to have a custom author.
   private addAuthorToPost(post: Post): Post {
     post.author = post.excerpt;
     post.excerpt = post.html.replace(/<[^>]*>/g, '');
-- 
GitLab