mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 04:41:43 +03:00
Merge pull request #2309 from ecency/nt/leaderboad-improve
Nt/leaderboad improve
This commit is contained in:
commit
7c1661f5f5
@ -8,7 +8,7 @@ import { connect } from 'react-redux';
|
||||
import { getLeaderboard } from '../../../providers/ecency/ecency';
|
||||
|
||||
// Constants
|
||||
import ROUTES from '../../../constants/routeNames';
|
||||
import FILTER_OPTIONS, { VALUE } from '../../../constants/options/leaderboard';
|
||||
|
||||
// Component
|
||||
import LeaderboardView from '../view/leaderboardView';
|
||||
@ -50,6 +50,7 @@ class LeaderboardContainer extends PureComponent {
|
||||
|
||||
if (index === undefined) {
|
||||
index = selectedIndex;
|
||||
selectedFilter = FILTER_OPTIONS[selectedIndex];
|
||||
}
|
||||
let users;
|
||||
|
||||
|
@ -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,9 +395,15 @@ 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)
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user