From aaf7084297142b34eda14b240f2806f822d90866 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Fri, 26 Jun 2020 17:44:15 +0200 Subject: [PATCH] Do not show banner if user has logged in --- src/screens/Amicale/LoginScreen.js | 6 ++++++ src/screens/Home/HomeScreen.js | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/screens/Amicale/LoginScreen.js b/src/screens/Amicale/LoginScreen.js index b965a8c..d6429d5 100644 --- a/src/screens/Amicale/LoginScreen.js +++ b/src/screens/Amicale/LoginScreen.js @@ -10,6 +10,7 @@ import {withCollapsible} from "../../utils/withCollapsible"; import {Collapsible} from "react-navigation-collapsible"; import CustomTabBar from "../../components/Tabbar/CustomTabBar"; import type {CustomTheme} from "../../managers/ThemeManager"; +import AsyncStorageManager from "../../managers/AsyncStorageManager"; type Props = { navigation: Object, @@ -81,6 +82,11 @@ class LoginScreen extends React.Component { hideErrorDialog = () => this.setState({dialogVisible: false}); handleSuccess = () => { + // Do not show the login banner again + AsyncStorageManager.getInstance().savePref( + AsyncStorageManager.getInstance().preferences.homeShowBanner.key, + '0' + ); if (this.nextScreen == null) this.props.navigation.goBack(); else diff --git a/src/screens/Home/HomeScreen.js b/src/screens/Home/HomeScreen.js index 7752fd7..a0492f0 100644 --- a/src/screens/Home/HomeScreen.js +++ b/src/screens/Home/HomeScreen.js @@ -150,7 +150,9 @@ class HomeScreen extends React.Component { } onBannerTimeout = () => { - this.setState({bannerVisible: AsyncStorageManager.getInstance().preferences.homeShowBanner.current === "1"}) + this.setState({ + bannerVisible: AsyncStorageManager.getInstance().preferences.homeShowBanner.current === "1" + }) } onScreenFocus = () => { @@ -160,6 +162,9 @@ class HomeScreen extends React.Component { headerRight: this.getHeaderButton, }); } + if (this.isLoggedIn) { + this.setState({bannerVisible: false}) + } // handle link open when home is not focused or created this.handleNavigationParams(); };