diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 83fc5a0b6c3e5f44dcc865c2b7c8aea63e6cb21c..4fce8137e2c5d0f363eda55e1963035a8f52a375 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,16 @@ stages: - build - deploy +build_branch: + image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:18.09 + services: + - docker:18.09-dind + stage: build + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" --build-arg conf=prod . + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + build: image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:18.09 services: 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 77a3b17dae26ccf3d7035ecfeeefcfa2836215d4..e0e7f0e46066abf99f8aade78cd5ad8cf5553245 100644 --- a/src/app/post/components/post-list/post-list.component.ts +++ b/src/app/post/components/post-list/post-list.component.ts @@ -60,15 +60,24 @@ export class PostListComponent implements OnInit { this.getPosts(this.filters); } else { // Init default news list + this.allPosts = []; this.postService.getPosts(1).subscribe((news) => { - this.setNews(news); - const headLineTag = this.allPosts.find((post: Post) => post.tags.some((tag) => tag.slug === TagEnum.aLaUne)); - this.allPosts.unshift(headLineTag); + this.fillArticles(news); }); } }); } + public fillArticles(news: PostWithMeta): void { + this.setNews(news); + const headLineTag = this.allPosts.filter((post: Post) => post.tags.some((tag) => tag.slug === TagEnum.aLaUne)); + + const headIndex = this.allPosts.findIndex((post) => post.id === headLineTag[0].id); + this.allPosts.splice(headIndex, 1); + + this.allPosts = [...headLineTag, ...this.allPosts]; + } + public getPosts(filters?: Tag[]): void { // Parse filter let parsedFilters = null; @@ -87,7 +96,7 @@ export class PostListComponent implements OnInit { this.isLoading = true; this.postService.getPosts(1, parsedFilters).subscribe((news) => { - this.setNews(news); + this.fillArticles(news); }); } @@ -121,7 +130,7 @@ export class PostListComponent implements OnInit { if (this.pagination && this.pagination.page < this.pagination.pages) { this.isLoading = true; this.postService.getPosts(this.pagination.next).subscribe((news) => { - this.setNews(news); + this.fillArticles(news); }); } } @@ -130,11 +139,12 @@ export class PostListComponent implements OnInit { private setNews(news: PostWithMeta): void { this.pagination = news.meta.pagination; const customIndex = this.allPosts.length; // For scroll loading, start with previous index. - this.allPosts = news.posts.map((val, index) => { + const newPosts = news.posts.map((val, index) => { val = this.addAuthorToPost(val); index += customIndex; return val; }); + this.allPosts = [...this.allPosts, ...newPosts]; this.isLoading = false; }