From 351ae2df25e6f12fdfa7d00d15779b6d2c57e6a9 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 16 Jun 2021 14:20:57 -0500 Subject: [PATCH] Support hidden stats --- .../features/account/components/header.js | 15 +++++++------- app/soapbox/features/edit_profile/index.js | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/app/soapbox/features/account/components/header.js b/app/soapbox/features/account/components/header.js index 7db81e2fc..e535959ee 100644 --- a/app/soapbox/features/account/components/header.js +++ b/app/soapbox/features/account/components/header.js @@ -255,6 +255,7 @@ class Header extends ImmutablePureComponent { ); } + const self = account.get('id') === me; const info = this.makeInfo(); const menu = this.makeMenu(); @@ -286,18 +287,18 @@ class Header extends ImmutablePureComponent { - - {shortNumberFormat(account.get('following_count'))} + {(self || !account.getIn(['pleroma', 'hide_follows'], false)) && + {account.getIn(['pleroma', 'hide_follows_count'], false) ? : {shortNumberFormat(account.get('following_count'))}} - + } - - {shortNumberFormat(account.get('followers_count'))} + {(self || !account.getIn(['pleroma', 'hide_followers'], false)) && + {account.getIn(['pleroma', 'hide_followers_count'], false) ? : {shortNumberFormat(account.get('followers_count'))}} - + } { - account.get('id') === me && + self &&
{ + const pleroma = account.get('pleroma'); + if (!pleroma) return false; + + const { hide_followers, hide_follows, hide_followers_count, hide_follows_count } = pleroma.toJS(); + return hide_followers && hide_follows && hide_followers_count && hide_follows_count; +}; + const messages = defineMessages({ heading: { id: 'column.edit_profile', defaultMessage: 'Edit profile' }, metaFieldLabel: { id: 'edit_profile.fields.meta_fields.label_placeholder', defaultMessage: 'Label' }, @@ -87,6 +95,7 @@ class EditProfile extends ImmutablePureComponent { map.set('fields', normalizeFields(map.get('fields'), props.maxFields)); map.set('stranger_notifications', strangerNotifications); map.set('accepts_email_list', acceptsEmailList); + map.set('hide_network', hidesNetwork(account)); unescapeParams(map, ['display_name', 'bio']); }); this.state = initialState.toObject(); @@ -122,6 +131,10 @@ class EditProfile extends ImmutablePureComponent { header: state.header_file, locked: state.locked, accepts_email_list: state.accepts_email_list, + hide_followers: state.hide_network, + hide_follows: state.hide_network, + hide_followers_count: state.hide_network, + hide_follows_count: state.hide_network, }, this.getFieldParams().toJS()); } @@ -237,6 +250,13 @@ class EditProfile extends ImmutablePureComponent { checked={this.state.locked} onChange={this.handleCheckboxChange} /> + } + hint={} + name='hide_network' + checked={this.state.hide_network} + onChange={this.handleCheckboxChange} + /> } hint={}