mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-19 11:21:41 +03:00
better handling leaderboard api failure
This commit is contained in:
parent
00d55dfb46
commit
c8d6ecd5b3
@ -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 ? <ListPlaceHolder /> : <EmptyScreenView />}</>;
|
||||
};
|
||||
|
||||
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={<ListPlaceHolder />}
|
||||
ListEmptyComponent={this._renderEmptyView}
|
||||
onRefresh={() => fetchLeaderBoard()}
|
||||
renderItem={this._renderItem}
|
||||
contentContainerStyle={styles.listContentContainer}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user