Skip to content

Commit

Permalink
refactor: downloadImage now requires id instead of User or PostItem o…
Browse files Browse the repository at this point in the history
…bject
  • Loading branch information
gutche committed Apr 30, 2023
1 parent aa4ded3 commit af11f10
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions front/src/app/post/components/post/post.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="post mt-3 mb-3">
<div class="postInfo border bg-white d-flex gap-3 py-3">
<img [src]="fetchImage(post.author)" alt="Profile picture" width="75" height="75"
<img [src]="fetchImage(post.author.id!)" alt="Profile picture" width="75" height="75"
class="profileImg rounded-circle flex-shrink-0">
<div class="d-flex gap-2 w-100 justify-content-between">
<div>
Expand Down Expand Up @@ -28,7 +28,7 @@ <h1 class="topName">{{post.title}}</h1>
<li class="ms-0 me-auto">
{{item.description}}
</li>
<img [src]="fetchImage(item)" alt="image" width="45" height="45"
<img [src]="fetchImage(item.id!)" alt="image" width="45" height="45"
class="itemImage rounded-circle ms-auto me-2 mt-auto mb-auto">
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions front/src/app/post/components/post/post.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export class PostComponent implements OnInit {
if (downvotes !== undefined) this.post.numDownvotes = downvotes;
}

fetchImage(src: PostItem | User) {
return this.postsService.downloadImage(src);
fetchImage(id: number) {
return this.postsService.downloadImage(id);
}

//TODO: UPVOTES AND DOWNVOTES
Expand Down
4 changes: 2 additions & 2 deletions front/src/app/post/services/posts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class PostsService {
return this.filter.asObservable();
}

downloadImage(src: PostItem | User): String {
return BASE_URL + '/images/' + src.id;
downloadImage(id: number): String {
return BASE_URL + '/images/' + id;
}
}
6 changes: 3 additions & 3 deletions front/src/app/profile/pages/follow/follow.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ export class FollowComponent implements OnInit {
return profileUserFollow;
}

fetchImage(user: User) {
return this.postService.downloadImage(user);
fetchImage(id: number) {
return this.postService.downloadImage(id);
}

fetchImageString(username: string) {
return this.userService.getUser(username).pipe(
map((user: User) => {
return this.postService.downloadImage(user);
return this.postService.downloadImage(user.id!);
}));
}
}
4 changes: 2 additions & 2 deletions front/src/app/profile/pages/profile/profile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ export class ProfileComponent implements OnInit {
}
}

fetchImage(src: User) {
return this.postService.downloadImage(src);
fetchImage(id: number) {
return this.postService.downloadImage(id);
}

logout() {
Expand Down

0 comments on commit af11f10

Please sign in to comment.