From dcb7e1ecf479a72c904dd882c05f1c446dbe2fe4 Mon Sep 17 00:00:00 2001 From: scarlett <nia@netbsd.org> Date: Tue, 4 Sep 2018 00:32:25 +0100 Subject: [PATCH] Add option for disabling counts (followers, statuses) in user profiles. --- src/components/settings/settings.js | 4 ++++ src/components/settings/settings.vue | 4 ++++ src/components/user_card_content/user_card_content.js | 5 +++++ src/components/user_card_content/user_card_content.vue | 10 +++++----- src/i18n/messages.js | 1 + src/main.js | 1 + src/modules/config.js | 1 + 7 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index de12894b..088e19d3 100644 --- a/src/components/settings/settings.js +++ b/src/components/settings/settings.js @@ -10,6 +10,7 @@ const settings = { hideAttachmentsLocal: this.$store.state.config.hideAttachments, hideAttachmentsInConvLocal: this.$store.state.config.hideAttachmentsInConv, hideNsfwLocal: this.$store.state.config.hideNsfw, + hideUserStatsLocal: this.$store.state.config.hideUserStats, notificationVisibilityLocal: this.$store.state.config.notificationVisibility, replyVisibilityLocal: this.$store.state.config.replyVisibility, loopVideoLocal: this.$store.state.config.loopVideo, @@ -47,6 +48,9 @@ const settings = { hideAttachmentsInConvLocal (value) { this.$store.dispatch('setOption', { name: 'hideAttachmentsInConv', value }) }, + hideUserStatsLocal (value) { + this.$store.dispatch('setOption', { name: 'hideUserStats', value }) + }, hideNsfwLocal (value) { this.$store.dispatch('setOption', { name: 'hideNsfw', value }) }, diff --git a/src/components/settings/settings.vue b/src/components/settings/settings.vue index c106b79c..2cf62200 100644 --- a/src/components/settings/settings.vue +++ b/src/components/settings/settings.vue @@ -122,6 +122,10 @@ <i class="icon-down-open"/> </label> </div> + <div> + <input type="checkbox" id="hideUserStats" v-model="hideUserStatsLocal"> + <label for="hideUserStats">{{$t('settings.hide_user_stats')}}</label> + </div> </div> <div class="setting-item"> <p>{{$t('settings.filtering_explanation')}}</p> diff --git a/src/components/user_card_content/user_card_content.js b/src/components/user_card_content/user_card_content.js index 76a5577e..eefa65f3 100644 --- a/src/components/user_card_content/user_card_content.js +++ b/src/components/user_card_content/user_card_content.js @@ -3,6 +3,11 @@ import { hex2rgb } from '../../services/color_convert/color_convert.js' export default { props: [ 'user', 'switcher', 'selected', 'hideBio' ], + data () { + return { + hideUserStatsLocal: this.$store.state.config.hideUserStats + } + }, computed: { headingStyle () { const color = this.$store.state.config.colors.bg diff --git a/src/components/user_card_content/user_card_content.vue b/src/components/user_card_content/user_card_content.vue index 59358040..65fd26eb 100644 --- a/src/components/user_card_content/user_card_content.vue +++ b/src/components/user_card_content/user_card_content.vue @@ -17,7 +17,7 @@ <div :title="user.name" class='user-name' v-else>{{user.name}}</div> <router-link class='user-screen-name':to="{ name: 'user-profile', params: { id: user.id } }"> <span>@{{user.screen_name}}</span><span v-if="user.locked"><i class="icon icon-lock"></i></span> - <span class="dailyAvg">{{dailyAvg}} {{ $t('user_card.per_day') }}</span> + <span v-if="!hideUserStatsLocal" class="dailyAvg">{{dailyAvg}} {{ $t('user_card.per_day') }}</span> </router-link> </div> </div> @@ -90,19 +90,19 @@ </div> </div> </div> - <div class="panel-body profile-panel-body"> + <div v-if="!hideUserStatsLocal || switcher" class="panel-body profile-panel-body"> <div class="user-counts" :class="{clickable: switcher}"> <div class="user-count" v-on:click.prevent="setProfileView('statuses')" :class="{selected: selected === 'statuses'}"> <h5>{{ $t('user_card.statuses') }}</h5> - <span>{{user.statuses_count}} <br></span> + <span v-if="!hideUserStatsLocal">{{user.statuses_count}} <br></span> </div> <div class="user-count" v-on:click.prevent="setProfileView('friends')" :class="{selected: selected === 'friends'}"> <h5>{{ $t('user_card.followees') }}</h5> - <span>{{user.friends_count}}</span> + <span v-if="!hideUserStatsLocal">{{user.friends_count}}</span> </div> <div class="user-count" v-on:click.prevent="setProfileView('followers')" :class="{selected: selected === 'followers'}"> <h5>{{ $t('user_card.followers') }}</h5> - <span>{{user.followers_count}}</span> + <span v-if="!hideUserStatsLocal">{{user.followers_count}}</span> </div> </div> <p v-if="!hideBio && user.description_html" class="profile-bio" v-html="user.description_html"></p> diff --git a/src/i18n/messages.js b/src/i18n/messages.js index 42e7e9d4..42b1dd40 100644 --- a/src/i18n/messages.js +++ b/src/i18n/messages.js @@ -328,6 +328,7 @@ const en = { loop_video_silent_only: 'Loop only videos without sound (i.e. Mastodon\'s "gifs")', reply_link_preview: 'Enable reply-link preview on mouse hover', replies_in_timeline: 'Replies in timeline', + hide_user_stats: 'Hide user statistics (e.g. status and follower counts)', reply_visibility_all: 'Show all replies', reply_visibility_following: 'Only show replies directed at me or users I\'m following', reply_visibility_self: 'Only show replies directed at me', diff --git a/src/main.js b/src/main.js index debd8703..d05ecba8 100644 --- a/src/main.js +++ b/src/main.js @@ -48,6 +48,7 @@ const persistedStateOptions = { 'config.collapseMessageWithSubject', 'config.hideAttachments', 'config.hideAttachmentsInConv', + 'config.hideUserStats', 'config.hideNsfw', 'config.replyVisibility', 'config.notificationVisibility', diff --git a/src/modules/config.js b/src/modules/config.js index 60a34bc1..24665e95 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -9,6 +9,7 @@ const defaultState = { collapseMessageWithSubject: false, hideAttachments: false, hideAttachmentsInConv: false, + hideUserStats: false, hideNsfw: true, loopVideo: true, loopVideoSilentOnly: true,