Skip to content

Commit 6914432

Browse files
Resul AvanResul Avan
authored andcommitted
followers/following fixes/improvements
1 parent eb0aac7 commit 6914432

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

src/components/profile/header/ProfileFollow.vue

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,29 @@
1515

1616
<div class="control">
1717
<b-taglist attached>
18-
<a class="tag" @click="showFollowers">{{$t('profile.follow.followers')}}</a>
18+
<a class="tag" @click="showFollowers">
19+
<b-icon
20+
class="has-margin-right-5"
21+
icon="account-arrow-left"
22+
size="is-small">
23+
</b-icon>
24+
25+
{{$t('profile.follow.followers')}}
26+
</a>
1927
<a class="tag is-primary" @click="showFollowers">{{followerCount}}</a>
2028
</b-taglist>
2129
</div>
2230

2331
<div class="control">
2432
<b-taglist attached>
25-
<a class="tag" @click="showFollowings">{{$t('profile.follow.following')}}</a>
33+
<a class="tag" @click="showFollowings">
34+
<b-icon
35+
class="has-margin-right-5"
36+
icon="account-arrow-right"
37+
size="is-small">
38+
</b-icon>
39+
{{$t('profile.follow.following')}}
40+
</a>
2641
<a class="tag is-primary" @click="showFollowings">{{followingCount}}</a>
2742
</b-taglist>
2843
</div>
@@ -42,7 +57,7 @@
4257
getFollowingByFollowerAndFollowing,
4358
saveFollowing
4459
} from '~/service/firebase/firestore/following-service';
45-
import { sendDangerNotification, showInfoToaster } from '~/service/notification-service';
60+
import { sendDangerNotification, showErrorToaster, showInfoToaster } from '~/service/notification-service';
4661
import { showProfileModule } from '~/service/rx-service';
4762
4863
@Component({
@@ -83,7 +98,10 @@
8398
this.followingCount = followingCount
8499
85100
})
86-
.catch(() => sendDangerNotification(this.$store.dispatch, this.$t('notification.follow.canNotLoadFollowing')))
101+
.catch((error) => {
102+
console.log(error)
103+
showErrorToaster(this.$t('notification.follow.canNotLoadFollowing'))
104+
})
87105
88106
this.width = window.innerWidth
89107
window.addEventListener('resize', this.handleResize);

src/components/profile/module/ProfileModule.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@
6161
},
6262
{
6363
moduleType: ModuleType.ProfileFollowers,
64-
icon: 'link-variant',
64+
icon: 'account-arrow-left',
6565
module: ProfileFollowers,
6666
private: true
6767
},
6868
{
6969
moduleType: ModuleType.ProfileFollowings,
70-
icon: 'link-variant',
70+
icon: 'account-arrow-right',
7171
module: ProfileFollowings,
7272
private: true
7373
},

src/service/firebase/firestore/following-service.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
CollectionField,
44
FirebaseQueryOperator,
55
Following,
6-
orderByName,
76
PagingResponse,
87
SearchData,
98
User,
@@ -13,7 +12,6 @@ import {
1312
deleteModel,
1413
getCountByWhereClauses,
1514
getModelsByWhereClauses,
16-
getModelsByWhereClausesAndOrderBy,
1715
saveModel
1816
} from '~/service/firebase/firestore/firestore-service'
1917
import { getUser, toSearchDataPagingResponse, userIncludes } from '~/service/firebase/firestore/user-service'
@@ -53,7 +51,7 @@ export const getFollowingByFollowerAndFollowing = async (follower: string, follo
5351
operator: FirebaseQueryOperator.EQ,
5452
value: following
5553
}
56-
const followingList: Following[] = await getModelsByWhereClausesAndOrderBy(collection.FOLLOWING, orderByName, wcFollower, wcFollowing)
54+
const followingList: Following[] = await getModelsByWhereClauses(collection.FOLLOWING, wcFollower, wcFollowing)
5755

5856
return followingList.find((fllwng) => fllwng.following === following && fllwng.follower === follower)
5957
}
@@ -72,9 +70,9 @@ export const getCountOfFollowing = (user: User) => {
7270

7371
export const searchFollowers = async (user: User, query: string, page: number, limit: number): Promise<PagingResponse<SearchData>> => {
7472
const queryLower = query?.toLocaleString()
75-
const whereClause = followingWhereClause(user)
73+
const whereClauseForFollowings = followingWhereClause(user)
7674

77-
const followingList = await getModelsByWhereClauses(collection.FOLLOWING, whereClause) as Following[]
75+
const followingList = await getModelsByWhereClauses(collection.FOLLOWING, whereClauseForFollowings) as Following[]
7876

7977
const users: User[] = [];
8078

@@ -96,9 +94,9 @@ export const searchFollowers = async (user: User, query: string, page: number, l
9694

9795
export const searchFollowings = async (user: User, query: string, page: number, limit: number): Promise<PagingResponse<SearchData>> => {
9896
const queryLower = query?.toLocaleString()
99-
const whereClause = followersWhereClause(user)
97+
const whereClauseForFollowers = followersWhereClause(user)
10098

101-
const followingList = await getModelsByWhereClauses(collection.FOLLOWING, whereClause) as Following[]
99+
const followingList = await getModelsByWhereClauses(collection.FOLLOWING, whereClauseForFollowers) as Following[]
102100

103101
const users: User[] = [];
104102

src/service/firebase/firestore/user-service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ export const searchUsers = async (query: string, page: number, limit: number): P
6969
};
7070

7171
export const userIncludes = (user: User, query: string) => {
72+
if (!query) {
73+
return true
74+
}
7275
return user.username?.toLowerCase().includes(query)
7376
|| user.name?.toLowerCase().includes(query)
7477
|| user.surname?.toLowerCase().includes(query)

0 commit comments

Comments
 (0)