Skip to content

Commit d49a854

Browse files
Resul AvanResul Avan
authored andcommitted
hide the profile photo and name for private users in followers/following page
1 parent 6a49e8e commit d49a854

File tree

5 files changed

+35
-16
lines changed

5 files changed

+35
-16
lines changed

src/components/card/ProfileCard.vue

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
<div class="card has-cursor-pointer has-margin-bottom-25"
33
@click="gotoProfile(username)">
44

5-
<BackgroundImage v-if="!!coverPhoto" :image-url="coverPhoto.src" :height="coverPhotoHeight"/>
5+
<BackgroundImage v-if="!!coverPhoto" :image-url="coverImageUrl" :height="coverPhotoHeight"/>
66

77
<div class="card-content">
88
<div class="media">
99
<div class="media-left">
10-
<BackgroundSquareImage :image-url="profilePhoto.src" :size="profilePhotoSize" rounded="true"
10+
<BackgroundSquareImage :image-url="profileImageUrl" :size="profilePhotoSize" rounded="true"
1111
border-inside="true"
1212
border="3"/>
1313
</div>
1414
<div class="media-content">
15-
<p class="title is-4">{{name}}</p>
15+
<p class="title is-4">{{fullName}}</p>
1616
<p class="subtitle is-6">@{{username}}</p>
1717
</div>
1818
</div>
@@ -22,7 +22,7 @@
2222

2323
<script lang="ts">
2424
import { Component, Prop, Vue } from 'nuxt-property-decorator';
25-
import { Image, Routes } from '../../types';
25+
import { DefaultCoverPhoto, DefaultProfilePhoto, Image, PrivacyType, Routes } from '../../types';
2626
import { getUserRoute } from '~/service/global-service';
2727
import BackgroundSquareImage from '../image/BackgroundSquareImage.vue';
2828
import BackgroundImage from '~/components/image/BackgroundImage.vue';
@@ -34,12 +34,32 @@
3434
3535
@Prop({ type: String, required: true }) name !: string
3636
@Prop({ type: String, required: true }) username !: string
37+
@Prop({ type: String, required: true }) privacyType !: PrivacyType
3738
@Prop({ type: Object, required: true }) profilePhoto !: Image
3839
@Prop({ type: Object, required: false }) coverPhoto !: Image
3940
@Prop({ type: Number, required: false, default: 250 }) coverPhotoHeight !: number
4041
@Prop({ type: Number, required: false, default: 64 }) profilePhotoSize !: number
4142
43+
get isPrivate() {
44+
return this.privacyType === PrivacyType.PRIVATE
45+
}
46+
47+
get coverImageUrl() {
48+
return this.isPrivate ? DefaultCoverPhoto.src : this.coverPhoto?.src
49+
}
50+
51+
get profileImageUrl() {
52+
return this.isPrivate ? DefaultProfilePhoto.src : this.profilePhoto?.src
53+
}
54+
55+
get fullName() {
56+
return this.isPrivate ? 'private account' : this.name
57+
}
58+
4259
async gotoProfile(username: string) {
60+
if (this.isPrivate) {
61+
return
62+
}
4363
await this.$router.push(getUserRoute(Routes.PROFILE_DYNAMIC, username))
4464
}
4565

src/components/profile/module/ProfileFollowers.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<template slot="searchResult">
99

1010
<ProfileCard v-for="(user, index) in list" :key="index" :name="user.name" :username="user.username"
11-
:profile-photo="user.profilePhoto"/>
11+
:profile-photo="user.profilePhoto" :privacy-type="user.privacy"/>
1212

1313
</template>
1414
</Paging>

src/components/profile/module/ProfileFollowings.vue

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
<Paging v-if="hasResult" :total="total" :per-page.sync="perPage" :current.sync="current" :is-fetching="isFetching"
77
:on-page-change="onPageChange">
88
<template slot="searchResult">
9-
109
<ProfileCard v-for="(user, index) in list" :key="index" :name="user.name" :username="user.username"
11-
:profile-photo="user.profilePhoto"/>
12-
10+
:profile-photo="user.profilePhoto" :privacy-type="user.privacy" />
1311
</template>
1412
</Paging>
1513

@@ -24,15 +22,15 @@
2422

2523
<script lang="ts">
2624
import { Component, Watch } from 'nuxt-property-decorator';
27-
import ProfileCard from '~/components/card/ProfileCard.vue';
2825
import { SearchData, User } from '~/types';
29-
import PageTitle from '~/components/ui/PageTitle.vue';
30-
import SearchField from '~/components/search/SearchField.vue';
31-
import Paging from '~/components/ui/paging/Paging.vue';
3226
import { searchFollowings } from '~/service/firebase/firestore/following-service';
33-
import BaseModule from '~/mixin/BaseModule';
3427
import { showErrorToaster } from '~/service/notification-service';
3528
import { reloadFollowing } from '~/service/rx-service';
29+
import BaseModule from '~/mixin/BaseModule';
30+
import PageTitle from '~/components/ui/PageTitle.vue';
31+
import SearchField from '~/components/search/SearchField.vue';
32+
import Paging from '~/components/ui/paging/Paging.vue';
33+
import ProfileCard from '~/components/card/ProfileCard.vue';
3634
3735
@Component({
3836
components: { Paging, SearchField, PageTitle, ProfileCard }
@@ -59,7 +57,6 @@
5957
console.log('reloadFollowing called')
6058
this.resetSearch();
6159
})
62-
6360
this.resetSearch()
6461
}
6562

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const toSearchData = (user: User): SearchData => {
9494
name: user.name as string,
9595
username: user.username as string,
9696
profilePhoto: user.profilePhoto as Image,
97-
coverPhoto: user.coverPhoto as Image
97+
coverPhoto: user.coverPhoto as Image,
98+
privacy: user.privacy as PrivacyType,
9899
}
99100
}

src/types/firebase-types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ export interface SearchData {
150150
name: string,
151151
username: string,
152152
profilePhoto: Image,
153-
coverPhoto: Image
153+
coverPhoto: Image,
154+
privacy: PrivacyType
154155
}
155156

156157
export interface PagingResponse<T> {

0 commit comments

Comments
 (0)