From 42116be9a698d2584615429861be81109d847b0a Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Thu, 14 May 2026 14:07:37 +0100 Subject: [PATCH] Added segments to separe friends and global --- src/app/components/post/post.component.html | 104 ++++++++++++++------ src/app/components/post/post.component.ts | 16 +-- 2 files changed, 83 insertions(+), 37 deletions(-) diff --git a/src/app/components/post/post.component.html b/src/app/components/post/post.component.html index aa40640..082f9e3 100644 --- a/src/app/components/post/post.component.html +++ b/src/app/components/post/post.component.html @@ -1,32 +1,78 @@ -@for (post of localPosts(); track post.id) { - -
-
-
- {{ post.username.substring(0, 2) }} -
- {{ post.username }} -
+ + + Général + + + Amis + + + + + @for (post of localPosts(); track post.id) { + +
+
+
+ {{ post.username.substring(0, 2) }} +
+ {{ post.username }} +
-
- -
+
+ +
-
-
- - {{ post.likes }} Likes +
+
+ + {{ post.likes }} Likes +
+

{{ post.libelle }}

+
-

{{ post.libelle }}

-
-
-
-} \ No newline at end of file + + } +
+ + @for (post of postsFriends(); track post.id) { + +
+
+
+ {{ post.username.substring(0, 2) }} +
+ {{ post.username }} +
+ +
+ +
+ +
+
+ + {{ post.likes }} Likes +
+

{{ post.libelle }}

+
+
+
+ } +
+
\ No newline at end of file diff --git a/src/app/components/post/post.component.ts b/src/app/components/post/post.component.ts index 3da856e..2e187e9 100644 --- a/src/app/components/post/post.component.ts +++ b/src/app/components/post/post.component.ts @@ -55,21 +55,22 @@ export class PostComponent implements OnInit { } async likePost(postId: number) { - this.localPosts.update(x => x.map(x => x.id != postId ? x :{ + this.localPosts.update(x => x.map(x => x.id != postId ? x : { ...x, likes: x.isLiked ? x.likes - 1 : x.likes + 1, isLiked: !x.isLiked })); - const loading = await this.loadCtrl.create({ - message: 'Chargement...', - spinner: 'lines-sharp-small' - }); - await loading.present(); - try { await firstValueFrom(this.postsService.patchLikeEndpoint(postId)); + this.postsFriends.set(this.localPosts()); } catch { + this.localPosts.update(x => x.map(x => x.id != postId ? x : { + ...x, + likes: x.isLiked ? x.likes + 1 : x.likes - 1, + isLiked: !x.isLiked + })); + const toast = await this.toastCtrl.create({ message: 'Impossible d\'aimer ce contenu', duration: 2000, @@ -77,6 +78,5 @@ export class PostComponent implements OnInit { }); await toast.present(); } - await loading.dismiss(); } }