diff --git a/src/components/Screens/WebSectionList.js b/src/components/Screens/WebSectionList.js index 417e8ac..a12b34b 100644 --- a/src/components/Screens/WebSectionList.js +++ b/src/components/Screens/WebSectionList.js @@ -22,6 +22,7 @@ type Props = { onScroll: (event: SyntheticEvent) => void, collapsibleStack: Collapsible, + showError: boolean, itemHeight?: number, updateData?: number, renderSectionHeader?: (data: { [key: string]: any }) => React.Node, @@ -49,6 +50,7 @@ class WebSectionList extends React.PureComponent { static defaultProps = { stickyHeader: false, updateData: 0, + showError: true, }; scrollRef: { current: null | Animated.SectionList }; @@ -202,8 +204,12 @@ class WebSectionList extends React.PureComponent { render() { let dataset = []; - if (this.state.fetchedData != null) - dataset = this.props.createDataset(this.state.fetchedData); + if (this.state.fetchedData != null || (this.state.fetchedData == null && !this.props.showError)) { + if (this.state.fetchedData == null) + dataset = this.props.createDataset({}); + else + dataset = this.props.createDataset(this.state.fetchedData); + } const {containerPaddingTop, scrollIndicatorInsetTop, onScrollWithListener} = this.props.collapsibleStack; return ( diff --git a/src/screens/Home/HomeScreen.js b/src/screens/Home/HomeScreen.js index c354b04..5467919 100644 --- a/src/screens/Home/HomeScreen.js +++ b/src/screens/Home/HomeScreen.js @@ -178,8 +178,12 @@ class HomeScreen extends React.Component { let dashboardData = []; if (fetchedData.news_feed != null) newsData = fetchedData.news_feed.data; + else + newsData = []; if (fetchedData.dashboard != null) dashboardData = this.generateDashboardDataset(fetchedData.dashboard); + else + dashboardData = this.generateDashboardDataset(null); return [ { title: '', @@ -200,7 +204,7 @@ class HomeScreen extends React.Component { * @param dashboardData * @return {Array} */ - generateDashboardDataset(dashboardData: fullDashboard): Array { + generateDashboardDataset(dashboardData: fullDashboard | null): Array { return [ {id: 'actions', content: []}, { @@ -208,49 +212,49 @@ class HomeScreen extends React.Component { content: [ { id: 'washers', - data: dashboardData.available_machines.washers, + data: dashboardData == null ? 0 : dashboardData.available_machines.washers, icon: 'washing-machine', color: this.colors.proxiwashColor, onPress: this.onProxiwashClick, - isAvailable: dashboardData.available_machines.washers > 0 + isAvailable: dashboardData == null ? false : dashboardData.available_machines.washers > 0 }, { id: 'dryers', - data: dashboardData.available_machines.dryers, + data: dashboardData == null ? 0 : dashboardData.available_machines.dryers, icon: 'tumble-dryer', color: this.colors.proxiwashColor, onPress: this.onProxiwashClick, - isAvailable: dashboardData.available_machines.dryers > 0 + isAvailable: dashboardData == null ? false : dashboardData.available_machines.dryers > 0 }, { id: 'available_tutorials', - data: dashboardData.available_tutorials, + data: dashboardData == null ? 0 : dashboardData.available_tutorials, icon: 'school', color: this.colors.tutorinsaColor, onPress: this.onTutorInsaClick, - isAvailable: dashboardData.available_tutorials > 0 + isAvailable: dashboardData == null ? false : dashboardData.available_tutorials > 0 }, { id: 'proximo_articles', - data: dashboardData.proximo_articles, + data: dashboardData == null ? 0 : dashboardData.proximo_articles, icon: 'shopping', color: this.colors.proximoColor, onPress: this.onProximoClick, - isAvailable: dashboardData.proximo_articles > 0 + isAvailable: dashboardData == null ? false : dashboardData.proximo_articles > 0 }, { id: 'today_menu', - data: dashboardData.today_menu, + data: dashboardData == null ? 0 : dashboardData.today_menu, icon: 'silverware-fork-knife', color: this.colors.menuColor, onPress: this.onMenuClick, - isAvailable: dashboardData.today_menu.length > 0 + isAvailable: dashboardData == null ? false : dashboardData.today_menu.length > 0 }, ] }, { id: 'event', - content: dashboardData.today_events + content: dashboardData == null ? [] : dashboardData.today_events }, ]; } @@ -509,6 +513,7 @@ class HomeScreen extends React.Component { renderItem={this.getRenderItem} itemHeight={FEED_ITEM_HEIGHT} onScroll={this.onScroll} + showError={false} />