Skip to content
Snippets Groups Projects
Commit 70990035 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

fix(news): issue on news display, tag duplication and page display were broken

parent 4f1b0b5c
No related branches found
No related tags found
2 merge requests!2031.13.0,!201Fix/news hot fix
......@@ -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:
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment