Skip to content

Commit 7b673c1

Browse files
committed
move isFollowedByMe from UserStats to User
1 parent e611184 commit 7b673c1

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

src/app/core/domains.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface User {
1212
name?:string;
1313
userStats?:UserStats;
1414
isMyself?:boolean;
15+
isFollowedByMe?:boolean;
1516
avatarHash?:string;
1617
}
1718

@@ -23,6 +24,5 @@ export interface UserStats {
2324
micropostCnt:number;
2425
followingCnt:number;
2526
followerCnt:number;
26-
followedByMe:boolean;
2727
}
2828

src/app/shared/follow-btn/follow-btn.component.spec.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ describe('FollowBtnComponent', () => {
3030
id: 1,
3131
email: "test@test.com",
3232
isMyself: null,
33-
userStats: {
34-
followedByMe: false,
35-
}
33+
isFollowedByMe: false,
3634
})
3735
}));
3836

@@ -52,9 +50,7 @@ describe('FollowBtnComponent', () => {
5250
id: 1,
5351
email: "test@test.com",
5452
isMyself: false,
55-
userStats: {
56-
followedByMe: true,
57-
}
53+
isFollowedByMe: true,
5854
})
5955
}));
6056

@@ -63,9 +59,7 @@ describe('FollowBtnComponent', () => {
6359
id: 1,
6460
email: "test@test.com",
6561
isMyself: false,
66-
userStats: {
67-
followedByMe: false,
68-
}
62+
isFollowedByMe: false,
6963
})
7064
}));
7165

src/app/shared/follow-btn/follow-btn.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ export class FollowBtnComponent implements OnChanges {
7373
private _canShowFollowBtn(user: User): boolean {
7474
if (user.isMyself === null) return false; // not signed in
7575
if (user.isMyself === true) return false; // myself
76-
if (user.userStats.followedByMe === true) return false; // already followed
76+
if (user.isFollowedByMe === true) return false; // already followed
7777
return true;
7878
}
7979

8080
private _canShowUnfollowBtn(user: User): boolean {
8181
if (user.isMyself === null) return false; // not signed in
8282
if (user.isMyself === true) return false; // myself
83-
if (user.userStats.followedByMe === false) return false; // not followed yet
83+
if (user.isFollowedByMe === false) return false; // not followed yet
8484
return true;
8585
}
8686
}

0 commit comments

Comments
 (0)