forked from vergnet/application-amicale
Allow navigating to amicale services section without being logged in
This commit is contained in:
parent
88b2120c8a
commit
217e918ce8
1 changed files with 11 additions and 33 deletions
|
@ -6,10 +6,7 @@ import CustomTabBar from "../../components/Tabbar/CustomTabBar";
|
||||||
import {withCollapsible} from "../../utils/withCollapsible";
|
import {withCollapsible} from "../../utils/withCollapsible";
|
||||||
import {Collapsible} from "react-navigation-collapsible";
|
import {Collapsible} from "react-navigation-collapsible";
|
||||||
import {CommonActions} from "@react-navigation/native";
|
import {CommonActions} from "@react-navigation/native";
|
||||||
import ConnectionManager from "../../managers/ConnectionManager";
|
|
||||||
import type {listItem} from "./ServicesScreen";
|
import type {listItem} from "./ServicesScreen";
|
||||||
import ErrorView from "../../components/Screens/ErrorView";
|
|
||||||
import {ERROR_TYPE} from "../../utils/WebData";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
navigation: Object,
|
navigation: Object,
|
||||||
|
@ -17,29 +14,13 @@ type Props = {
|
||||||
collapsibleStack: Collapsible,
|
collapsibleStack: Collapsible,
|
||||||
}
|
}
|
||||||
|
|
||||||
type State = {
|
class ServicesSectionScreen extends React.Component<Props> {
|
||||||
isLoggedIn: boolean,
|
|
||||||
}
|
|
||||||
|
|
||||||
class ServicesSectionScreen extends React.Component<Props, State> {
|
|
||||||
|
|
||||||
finalDataset: listItem;
|
finalDataset: listItem;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.handleNavigationParams();
|
this.handleNavigationParams();
|
||||||
this.state = {
|
|
||||||
isLoggedIn: ConnectionManager.getInstance().isLoggedIn(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.props.navigation.addListener('focus', this.onFocus);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
onFocus = () => {
|
|
||||||
this.setState({isLoggedIn: ConnectionManager.getInstance().isLoggedIn()})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleNavigationParams() {
|
handleNavigationParams() {
|
||||||
|
@ -57,9 +38,6 @@ class ServicesSectionScreen extends React.Component<Props, State> {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {containerPaddingTop, scrollIndicatorInsetTop, onScroll} = this.props.collapsibleStack;
|
const {containerPaddingTop, scrollIndicatorInsetTop, onScroll} = this.props.collapsibleStack;
|
||||||
if (!this.state.isLoggedIn && this.finalDataset.shouldLogin)
|
|
||||||
return <ErrorView {...this.props} errorCode={ERROR_TYPE.BAD_TOKEN}/>;
|
|
||||||
else
|
|
||||||
return <CardList
|
return <CardList
|
||||||
dataset={this.finalDataset.content}
|
dataset={this.finalDataset.content}
|
||||||
isHorizontal={false}
|
isHorizontal={false}
|
||||||
|
|
Loading…
Reference in a new issue