Do not show banner if user has logged in

This commit is contained in:
Arnaud Vergnet 2020-06-26 17:44:15 +02:00
parent 06d01e98b0
commit aaf7084297
2 changed files with 12 additions and 1 deletions

View file

@ -10,6 +10,7 @@ import {withCollapsible} from "../../utils/withCollapsible";
import {Collapsible} from "react-navigation-collapsible"; import {Collapsible} from "react-navigation-collapsible";
import CustomTabBar from "../../components/Tabbar/CustomTabBar"; import CustomTabBar from "../../components/Tabbar/CustomTabBar";
import type {CustomTheme} from "../../managers/ThemeManager"; import type {CustomTheme} from "../../managers/ThemeManager";
import AsyncStorageManager from "../../managers/AsyncStorageManager";
type Props = { type Props = {
navigation: Object, navigation: Object,
@ -81,6 +82,11 @@ class LoginScreen extends React.Component<Props, State> {
hideErrorDialog = () => this.setState({dialogVisible: false}); hideErrorDialog = () => this.setState({dialogVisible: false});
handleSuccess = () => { handleSuccess = () => {
// Do not show the login banner again
AsyncStorageManager.getInstance().savePref(
AsyncStorageManager.getInstance().preferences.homeShowBanner.key,
'0'
);
if (this.nextScreen == null) if (this.nextScreen == null)
this.props.navigation.goBack(); this.props.navigation.goBack();
else else

View file

@ -150,7 +150,9 @@ class HomeScreen extends React.Component<Props, State> {
} }
onBannerTimeout = () => { onBannerTimeout = () => {
this.setState({bannerVisible: AsyncStorageManager.getInstance().preferences.homeShowBanner.current === "1"}) this.setState({
bannerVisible: AsyncStorageManager.getInstance().preferences.homeShowBanner.current === "1"
})
} }
onScreenFocus = () => { onScreenFocus = () => {
@ -160,6 +162,9 @@ class HomeScreen extends React.Component<Props, State> {
headerRight: this.getHeaderButton, headerRight: this.getHeaderButton,
}); });
} }
if (this.isLoggedIn) {
this.setState({bannerVisible: false})
}
// handle link open when home is not focused or created // handle link open when home is not focused or created
this.handleNavigationParams(); this.handleNavigationParams();
}; };