Display favorites count on profile, fixes #126

This commit is contained in:
Alex Gleason 2020-03-10 15:26:34 -05:00
parent 0e17641f12
commit bccb9a6f9c
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 5 additions and 3 deletions

View File

@ -1,7 +1,7 @@
import { defineMessages, injectIntl } from 'react-intl'
import ImmutablePureComponent from 'react-immutable-pure-component'
import ImmutablePropTypes from 'react-immutable-proptypes'
import { me } from '../../initial_state'
import { me, favouritesCount } from '../../initial_state'
import { shortNumberFormat } from '../../utils/numbers'
import PanelLayout from './panel_layout'
import UserStat from '../user_stat'
@ -51,7 +51,7 @@ class ProfileStatsPanel extends ImmutablePureComponent {
account.get('id') === me &&
<UserStat
title={intl.formatMessage(messages.favorites)}
value={shortNumberFormat(account.get('favourite_count'))} /* : todo : */
value={shortNumberFormat(favouritesCount)}
to={`/${account.get('acct')}/favorites`}
/>
}

View File

@ -26,5 +26,6 @@ export const forceSingleColumn = !getMeta('advanced_layout');
export const promotions = initialState && initialState.promotions;
export const unreadCount = getMeta('unread_count');
export const monthlyExpensesComplete = getMeta('monthly_expenses_complete');
export const favouritesCount = getMeta('favourites_count');
export default initialState;

View File

@ -38,6 +38,7 @@ class InitialStateSerializer < ActiveModel::Serializer
store[:is_staff] = object.current_account.user.staff?
store[:unread_count] = unread_count object.current_account
store[:monthly_expenses_complete] = Redis.current.get("monthly_funding_ammount") || 0
store[:favourites_count] = object.current_account.favourites.count.to_s
end
store