Skip to content

Commit 6a49e8e

Browse files
Resul AvanResul Avan
authored andcommitted
following privacy implementation
1 parent 948063c commit 6a49e8e

File tree

7 files changed

+80
-14
lines changed

7 files changed

+80
-14
lines changed

src/components/profile/header/ProfileFollow.vue

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@
1515

1616
<div class="control">
1717
<b-taglist attached>
18-
<a class="tag" @click="showFollowers">
18+
19+
<b-tag v-if="followersLocked">
20+
<b-icon
21+
class="has-margin-right-5"
22+
icon="account-arrow-left"
23+
size="is-small">
24+
</b-icon>
25+
26+
{{$t('profile.follow.followers')}}
27+
</b-tag>
28+
29+
<a v-else class="tag" @click="showFollowers">
1930
<b-icon
2031
class="has-margin-right-5"
2132
icon="account-arrow-left"
@@ -24,21 +35,44 @@
2435

2536
{{$t('profile.follow.followers')}}
2637
</a>
27-
<a class="tag is-primary" @click="showFollowers">{{followerCount}}</a>
38+
<b-tag v-if="followersLocked" class="tag is-primary">
39+
<b-icon
40+
icon="lock"
41+
size="is-small">
42+
</b-icon>
43+
</b-tag>
44+
<a v-else class="tag is-primary" @click="showFollowers">{{followerCount}}</a>
2845
</b-taglist>
2946
</div>
3047

3148
<div class="control">
3249
<b-taglist attached>
33-
<a class="tag" @click="showFollowings">
50+
<b-tag v-if="followingLocked">
51+
<b-icon
52+
class="has-margin-right-5"
53+
icon="account-arrow-right"
54+
size="is-small">
55+
</b-icon>
56+
{{$t('profile.follow.following')}}
57+
</b-tag>
58+
59+
<a v-else class="tag" @click="showFollowings">
3460
<b-icon
3561
class="has-margin-right-5"
3662
icon="account-arrow-right"
3763
size="is-small">
3864
</b-icon>
3965
{{$t('profile.follow.following')}}
4066
</a>
41-
<a class="tag is-primary" @click="showFollowings">{{followingCount}}</a>
67+
<b-tag v-if="followingLocked" class="tag is-primary">
68+
<b-icon
69+
icon="lock"
70+
size="is-small">
71+
</b-icon>
72+
</b-tag>
73+
<a v-else class="tag is-primary" @click="showFollowings">
74+
{{followingCount}}
75+
</a>
4276
</b-taglist>
4377
</div>
4478

@@ -49,7 +83,7 @@
4983

5084
<script lang="ts">
5185
import { Component, Prop, Vue } from 'nuxt-property-decorator';
52-
import { AuthUser, ModuleType, User } from '~/types';
86+
import { AuthUser, ModuleType, PrivacyType, User } from '~/types';
5387
import {
5488
deleteFollowing,
5589
getCountOfFollowers,
@@ -58,7 +92,7 @@
5892
saveFollowing
5993
} from '~/service/firebase/firestore/following-service';
6094
import { sendDangerNotification, showErrorToaster, showInfoToaster } from '~/service/notification-service';
61-
import { showProfileModule } from '~/service/rx-service';
95+
import { reloadFollowing, showProfileModule } from '~/service/rx-service';
6296
6397
@Component({
6498
components: {}
@@ -89,8 +123,8 @@
89123
followerCount,
90124
followingCount
91125
]: [number, number] = await Promise.all([
92-
getCountOfFollowers(this.user),
93-
getCountOfFollowing(this.user)
126+
Promise.resolve(this.followersLocked).then((locked) => locked ? 0 : getCountOfFollowers(this.user)),
127+
Promise.resolve(this.followingLocked).then((locked) => locked ? 0 : getCountOfFollowing(this.user))
94128
])
95129
.finally(() => this.loading = false) as [number, number]
96130
@@ -111,6 +145,14 @@
111145
this.width = window.innerWidth
112146
}
113147
148+
get followersLocked() {
149+
return !this.isMyProfile && this.user.followersPrivacy === PrivacyType.PRIVATE
150+
}
151+
152+
get followingLocked() {
153+
return !this.isMyProfile && this.user.followingPrivacy === PrivacyType.PRIVATE
154+
}
155+
114156
get isMobile() {
115157
return this.width < 768
116158
}
@@ -148,6 +190,7 @@
148190
this.followerCount++
149191
})
150192
})
193+
.then(() => reloadFollowing.next())
151194
.catch(() => sendDangerNotification(this.$store.dispatch, this.$t('notification.systemError')))
152195
}
153196
@@ -166,6 +209,7 @@
166209
this.followerCount--
167210
})
168211
})
212+
.then(() => reloadFollowing.next())
169213
.catch(() => sendDangerNotification(this.$store.dispatch, this.$t('notification.systemError')))
170214
}
171215

src/components/profile/module/ProfileFollowers.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</template>
2424

2525
<script lang="ts">
26-
import { Component } from 'nuxt-property-decorator';
26+
import { Component, Watch } from 'nuxt-property-decorator';
2727
import ProfileCard from '~/components/card/ProfileCard.vue';
2828
import { SearchData, User } from '~/types';
2929
import PageTitle from '~/components/ui/PageTitle.vue';
@@ -32,6 +32,7 @@
3232
import { searchFollowers } from '~/service/firebase/firestore/following-service';
3333
import BaseModule from '~/mixin/BaseModule';
3434
import { showErrorToaster } from '~/service/notification-service';
35+
import { reloadFollowing } from '~/service/rx-service';
3536
3637
@Component({
3738
components: { Paging, SearchField, PageTitle, ProfileCard }
@@ -48,7 +49,15 @@
4849
isFetching = false
4950
searched = false
5051
52+
@Watch('perPage')
53+
onPerPageChanged(value: number) {
54+
this.resetSearch();
55+
}
56+
5157
mounted() {
58+
this.$subscribeTo(reloadFollowing.asObservable(), () => {
59+
this.resetSearch();
60+
})
5261
this.resetSearch()
5362
}
5463

src/components/profile/module/ProfileFollowings.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</template>
2424

2525
<script lang="ts">
26-
import { Component } from 'nuxt-property-decorator';
26+
import { Component, Watch } from 'nuxt-property-decorator';
2727
import ProfileCard from '~/components/card/ProfileCard.vue';
2828
import { SearchData, User } from '~/types';
2929
import PageTitle from '~/components/ui/PageTitle.vue';
@@ -32,6 +32,7 @@
3232
import { searchFollowings } from '~/service/firebase/firestore/following-service';
3333
import BaseModule from '~/mixin/BaseModule';
3434
import { showErrorToaster } from '~/service/notification-service';
35+
import { reloadFollowing } from '~/service/rx-service';
3536
3637
@Component({
3738
components: { Paging, SearchField, PageTitle, ProfileCard }
@@ -48,7 +49,17 @@
4849
isFetching = false
4950
searched = false
5051
52+
@Watch('perPage')
53+
onPerPageChanged(value: number) {
54+
this.resetSearch();
55+
}
56+
5157
mounted() {
58+
this.$subscribeTo(reloadFollowing.asObservable(), () => {
59+
console.log('reloadFollowing called')
60+
this.resetSearch();
61+
})
62+
5263
this.resetSearch()
5364
}
5465

src/components/profile/module/ProfileModule.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<script lang="ts">
2626
import { Component } from 'nuxt-property-decorator';
27-
import { ModuleTabConfig, ModuleType } from '~/types';
27+
import { ModuleTabConfig, ModuleType, PrivacyType } from '~/types';
2828
import BaseModule from '~/mixin/BaseModule';
2929
import ProfileAboutMe from '~/components/profile/module/ProfileAboutMe.vue';
3030
import LinkedAccounts from '~/components/profile/module/LinkedAccounts.vue';
@@ -57,13 +57,13 @@
5757
type: ModuleType.FOLLOWERS,
5858
icon: 'account-arrow-left',
5959
component: ProfileFollowers,
60-
private: true
60+
private: this.user?.privacy === PrivacyType.PRIVATE || this.user.followersPrivacy === PrivacyType.PRIVATE
6161
},
6262
{
6363
type: ModuleType.FOLLOWINGS,
6464
icon: 'account-arrow-right',
6565
component: ProfileFollowings,
66-
private: true
66+
private: this.user?.privacy === PrivacyType.PRIVATE || this.user.followingPrivacy === PrivacyType.PRIVATE
6767
},
6868
{
6969
type: ModuleType.SETTINGS,

src/pages/search.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
@StateNamespace.auth.Getter authUser !: AuthUser;
5252
5353
@Watch('perPage')
54-
onActiveChanged(value: number) {
54+
onPerPageChanged(value: number) {
5555
this.resetSearch();
5656
}
5757

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
FirebaseQueryOperator,
55
Following,
66
PagingResponse,
7+
PrivacyType,
78
SearchData,
89
User,
910
WhereClause

src/service/rx-service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export const reauthenticateObservable = new Subject<void>()
77
export const reloadUserFromDatabase = new Subject<string>()
88
export const loadMoreSearchResult = new Subject<void>()
99
export const showProfileModule = new Subject<ModuleType>()
10+
export const reloadFollowing = new Subject<void>();

0 commit comments

Comments
 (0)