diff --git a/src/components/leaderboard/view/leaderboardView.js b/src/components/leaderboard/view/leaderboardView.js index 4df05006a..3380193e0 100644 --- a/src/components/leaderboard/view/leaderboardView.js +++ b/src/components/leaderboard/view/leaderboardView.js @@ -9,6 +9,7 @@ import { FilterBar } from '../../filterBar'; import FILTER_OPTIONS, { VALUE } from '../../../constants/options/leaderboard'; // Styles import styles from './leaderboardStyles'; +import EmptyScreenView from '../../basicUIElements/view/emptyScreen/emptyScreenView'; class LeaderboardView extends PureComponent { /* Props @@ -40,6 +41,11 @@ class LeaderboardView extends PureComponent { ); }; + _renderEmptyView = () => { + const { refreshing } = this.props; + return <>{refreshing ? : }; + }; + render() { const { users, intl, fetchLeaderBoard, refreshing, selectedIndex } = this.props; return ( @@ -70,7 +76,7 @@ class LeaderboardView extends PureComponent { refreshing={refreshing} keyExtractor={(item) => get(item, '_id', Math.random()).toString()} removeClippedSubviews={false} - ListEmptyComponent={} + ListEmptyComponent={this._renderEmptyView} onRefresh={() => fetchLeaderBoard()} renderItem={this._renderItem} contentContainerStyle={styles.listContentContainer} diff --git a/src/providers/ecency/ecency.ts b/src/providers/ecency/ecency.ts index e2607cd3e..b02296270 100644 --- a/src/providers/ecency/ecency.ts +++ b/src/providers/ecency/ecency.ts @@ -8,6 +8,7 @@ import { parsePost } from '../../utils/postParser'; import { extractMetadata, makeJsonMetadata } from '../../utils/editor'; import { CommentHistoryItem, LatestMarketPrices, ReceivedVestingShare, Referral, ReferralStat } from './ecency.types'; import { convertCommentHistory, convertLatestQuotes, convertReferral, convertReferralStat } from './converters'; +import { isArray } from 'lodash'; @@ -394,7 +395,12 @@ export const getFragments = async () => { export const getLeaderboard = async (duration:'day'|'week'|'month') => { try{ const response = await ecencyApi.get(`private-api/leaderboard/${duration}`) - return response.data; + + const rawData = response.data; + if(!rawData || !isArray(rawData)){ + throw new Error('Invalid response returned'); + } + return rawData; } catch(error) { bugsnagInstance.notify(error) }