-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd1c647
commit 4a3dd98
Showing
26 changed files
with
446 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<router-outlet></router-outlet> <app-snackbar /> | ||
<router-outlet></router-outlet> <Snackbar /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
<p>followers works!</p> | ||
@for (user of usersWithFollowStatus$ | async; track $index) { | ||
<OtherUser | ||
[user]="user" | ||
[currentUserId]="this?.uid" | ||
(follow)="followUser($event)" | ||
(unfollow)="unfollowUser($event)" | ||
/> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,45 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, inject } from '@angular/core'; | ||
import { Auth } from '@angular/fire/auth'; | ||
import { UserRelationService } from '../../shared/services/firestore/user-relation.service'; | ||
import { Observable, of } from 'rxjs'; | ||
import { CommonModule } from '@angular/common'; | ||
import { OtherUserComponent } from '../../shared/components/other-user/other-user.component'; | ||
import { User } from '../../shared/types/User'; | ||
|
||
@Component({ | ||
selector: 'app-followers', | ||
standalone: true, | ||
imports: [], | ||
imports: [CommonModule, OtherUserComponent], | ||
templateUrl: './followers.component.html', | ||
styleUrl: './followers.component.scss' | ||
}) | ||
export class FollowersComponent { | ||
|
||
private readonly auth: Auth = inject(Auth); | ||
private readonly userRelations: UserRelationService = inject(UserRelationService); | ||
usersWithFollowStatus$: Observable<any[]> = of([]); | ||
uid: string | undefined; | ||
|
||
ngOnInit() { | ||
this.checkFollowStatus(); | ||
this.uid = this.auth.currentUser?.uid; | ||
} | ||
|
||
checkFollowStatus() { | ||
if (this.auth.currentUser) { | ||
this.usersWithFollowStatus$ = this.userRelations.getFollowersList(this.auth.currentUser.uid) | ||
} | ||
} | ||
|
||
followUser(followingUser: User) { | ||
if (this.auth.currentUser) { | ||
this.userRelations.followUser(this.auth.currentUser.uid, followingUser); | ||
} | ||
} | ||
|
||
unfollowUser(followingUserId: string) { | ||
if (this.auth.currentUser) { | ||
this.userRelations.unfollowUser(this.auth.currentUser.uid, followingUserId); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@for (post of posts; track $index) { | ||
<Posts [post]="post" /> | ||
} |
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
src/app/profile/profile-posts/profile-posts.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ProfilePostsComponent } from './profile-posts.component'; | ||
|
||
describe('ProfilePostsComponent', () => { | ||
let component: ProfilePostsComponent; | ||
let fixture: ComponentFixture<ProfilePostsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ProfilePostsComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ProfilePostsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Component, inject } from '@angular/core'; | ||
import { Auth } from '@angular/fire/auth'; | ||
import { Post } from '../../shared/types/Post'; | ||
import { PostsComponent } from '../../shared/components/posts/posts.component'; | ||
import { UserRelationService } from '../../shared/services/firestore/user-relation.service'; | ||
import { SnackbarService } from '../../shared/components/snackbar/snackbar.service'; | ||
|
||
@Component({ | ||
selector: 'app-profile-posts', | ||
standalone: true, | ||
imports: [PostsComponent], | ||
templateUrl: './profile-posts.component.html', | ||
styleUrl: './profile-posts.component.scss' | ||
}) | ||
export class ProfilePostsComponent { | ||
|
||
private readonly auth: Auth = inject(Auth); | ||
private readonly userRelations: UserRelationService = inject(UserRelationService); | ||
private readonly snack: SnackbarService = inject(SnackbarService) | ||
|
||
posts: Post[] = []; | ||
|
||
|
||
ngOnInit() { | ||
if (this.auth.currentUser) { | ||
this.userRelations.getPostsFromFollowing(this.auth.currentUser.uid) | ||
.subscribe({ | ||
next: (posts) => { | ||
this.posts = posts; | ||
}, | ||
error: (error) => { | ||
this.snack.show(error); | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/app/shared/components/other-user/other-user.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@if(user.uid!==currentUserId) { | ||
<div class="user-item"> | ||
<div class="author-info"> | ||
<div class="author-image"> | ||
<img | ||
[src]="user.photoUrl" | ||
(error)="handleImageError($event)" | ||
alt="{{ user.name }}" | ||
/> | ||
</div> | ||
<div class="author-details"> | ||
<h3>{{ user.name }}</h3> | ||
<p class="user-followers">{{ user.email }}</p> | ||
|
||
<p class="user-followers">Followers: {{ user.followerCount }}</p> | ||
</div> | ||
</div> | ||
<div class="button-container"> | ||
@if (user.isFollowing) { | ||
<button | ||
(click)="unfollowUser()" | ||
class="custom-following-button" | ||
type="submit" | ||
> | ||
Following | ||
</button> | ||
} @else{ | ||
<button class="custom-button" (click)="followUser()" type="submit"> | ||
Follow | ||
</button> | ||
} | ||
</div> | ||
</div> | ||
} |
61 changes: 61 additions & 0 deletions
61
src/app/shared/components/other-user/other-user.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
@import "../../../../partials/buttons"; | ||
@import "../../../../partials/variables"; | ||
|
||
.user-item { | ||
background: #fff; | ||
border-bottom: 0.5px solid rgb(190, 190, 190); | ||
margin-bottom: 20px; | ||
padding: 20px 20px 0 20px; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
|
||
.user-followers { | ||
color: #999; | ||
font-size: 0.9em; | ||
} | ||
|
||
.user-followers { | ||
color: #999; | ||
font-size: 0.9em; | ||
} | ||
|
||
.author-info { | ||
display: flex; | ||
align-items: center; | ||
margin-bottom: 15px; | ||
} | ||
|
||
.author-image { | ||
width: 50px; | ||
height: 50px; | ||
background-color: #ddd; | ||
border-radius: 50%; | ||
margin-right: 10px; | ||
img { | ||
width: 50px; | ||
height: 50px; | ||
background-color: #ddd; | ||
border-radius: 50%; | ||
margin-right: 10px; | ||
} | ||
} | ||
|
||
.author-details { | ||
h3 { | ||
margin: 0; | ||
} | ||
.time-stamp { | ||
color: #999; | ||
font-size: 0.9em; | ||
} | ||
} | ||
|
||
.custom-button { | ||
@include write-button($accent-color); | ||
} | ||
|
||
.custom-following-button { | ||
@include following-button($accent-color); | ||
} |
12 changes: 6 additions & 6 deletions
12
...app/profile/posts/posts.component.spec.ts → ...s/other-user/other-user.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.