From e2b7ae060ccee18a8cc8331f3cf0c99a68638f81 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 17 Jun 2022 18:10:13 +0500 Subject: [PATCH 01/43] lazy loading feed tabs --- src/screens/feed/screen/feedScreen.tsx | 44 +++++++++++++++++--------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/screens/feed/screen/feedScreen.tsx b/src/screens/feed/screen/feedScreen.tsx index c408a0d42..88fead999 100644 --- a/src/screens/feed/screen/feedScreen.tsx +++ b/src/screens/feed/screen/feedScreen.tsx @@ -1,10 +1,9 @@ -import React, { Fragment, useEffect } from 'react'; -import { SafeAreaView } from 'react-native'; -import { useSelector } from 'react-redux'; +import React, { Fragment, useState, useEffect } from 'react'; +import { ActivityIndicator, SafeAreaView } from 'react-native'; import get from 'lodash/get'; // Components -import { Posts, Header, TabbedPosts } from '../../../components'; +import { Header, TabbedPosts } from '../../../components'; // Container import { AccountContainer } from '../../../containers'; @@ -23,22 +22,37 @@ const FeedScreen = () => { const mainTabs = useAppSelector((state) => state.customTabs.mainTabs || getDefaultFilters('main')); const filterOptions = mainTabs.map((key) => getFilterMap('main')[key]); + const [lazyLoad, setLazyLoad] = useState(false); + + const _lazyLoadContent = () => { + if(!lazyLoad){ + setTimeout(() => { + setLazyLoad(true); + }, 100) + } + } + return ( {({ currentAccount }) => (
- - + + + {lazyLoad && ( + + + )} + )} From 4d1586d4b12b7a08241fc11af58a0e4dfe400bcb Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 17 Jun 2022 18:12:31 +0500 Subject: [PATCH 02/43] showing launch screen animation in welcome screen --- .../{welcomeScreen.js => welcomeScreen.tsx} | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) rename src/screens/application/screen/{welcomeScreen.js => welcomeScreen.tsx} (84%) diff --git a/src/screens/application/screen/welcomeScreen.js b/src/screens/application/screen/welcomeScreen.tsx similarity index 84% rename from src/screens/application/screen/welcomeScreen.js rename to src/screens/application/screen/welcomeScreen.tsx index 6d44ef96b..9e2a40445 100644 --- a/src/screens/application/screen/welcomeScreen.js +++ b/src/screens/application/screen/welcomeScreen.tsx @@ -1,15 +1,27 @@ -import React from 'react'; +import React, {useState, useEffect} from 'react'; import { useIntl } from 'react-intl'; import { Text, Image, View, SafeAreaView, TouchableOpacity } from 'react-native'; import EStyleSheet from 'react-native-extended-stylesheet'; import { Icon, MainButton } from '../../../components'; +import LaunchScreen from '../../launch'; import styles from './welcomeStyles'; const WelcomeScreen = ({ handleButtonPress }) => { const intl = useIntl(); + + const [showAnimation, setShowAnimation] = useState(process.env.NODE_ENV !== 'development'); + + useEffect(() => { + if (showAnimation) { + setTimeout(() => { + setShowAnimation(false); + }, 3550); + } + }, [showAnimation]); + const _renderInfo = (iconName, headingIntlId, bodyIntlId) => ( @@ -53,6 +65,7 @@ const WelcomeScreen = ({ handleButtonPress }) => { /> + {showAnimation && } ); }; From 1bedeea96968a3d88df4526dd748093803d08c93 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 17 Jun 2022 18:20:16 +0500 Subject: [PATCH 03/43] fixed welcome screen not showing animation --- src/screens/application/screen/welcomeScreen.tsx | 2 +- src/screens/launch/screen/launchScreen.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/screens/application/screen/welcomeScreen.tsx b/src/screens/application/screen/welcomeScreen.tsx index 9e2a40445..aace0a2d3 100644 --- a/src/screens/application/screen/welcomeScreen.tsx +++ b/src/screens/application/screen/welcomeScreen.tsx @@ -12,7 +12,7 @@ import styles from './welcomeStyles'; const WelcomeScreen = ({ handleButtonPress }) => { const intl = useIntl(); - const [showAnimation, setShowAnimation] = useState(process.env.NODE_ENV !== 'development'); + const [showAnimation, setShowAnimation] = useState(true); useEffect(() => { if (showAnimation) { diff --git a/src/screens/launch/screen/launchScreen.js b/src/screens/launch/screen/launchScreen.js index 975db650d..5a40f7399 100644 --- a/src/screens/launch/screen/launchScreen.js +++ b/src/screens/launch/screen/launchScreen.js @@ -1,10 +1,11 @@ import React from 'react'; -import { View, Appearance } from 'react-native'; +import { View } from 'react-native'; import LottieView from 'lottie-react-native'; import styles from './launchStyles'; +import { useAppSelector } from '../../../hooks'; const LaunchScreen = () => { - const isDarkMode = Appearance.getColorScheme() === 'dark'; + const isDarkMode = useAppSelector((state) => state.application.isDarkTheme); return ( Date: Fri, 17 Jun 2022 18:29:02 +0500 Subject: [PATCH 04/43] cleaned up index of application container --- .../application/{index.js => index.tsx} | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) rename src/screens/application/{index.js => index.tsx} (79%) diff --git a/src/screens/application/index.js b/src/screens/application/index.tsx similarity index 79% rename from src/screens/application/index.js rename to src/screens/application/index.tsx index 438f04fd9..fb65c5c9a 100644 --- a/src/screens/application/index.js +++ b/src/screens/application/index.tsx @@ -1,13 +1,11 @@ -import React, { Fragment, useEffect, useState } from 'react'; -import { Dimensions } from 'react-native'; +import React, { useEffect } from 'react'; import SplashScreen from 'react-native-splash-screen'; -import { OrientationLocker, PORTRAIT, LANDSCAPE } from 'react-native-orientation-locker'; +import { OrientationLocker, PORTRAIT } from 'react-native-orientation-locker'; import { useDispatch } from 'react-redux'; import ApplicationContainer from './container/applicationContainer'; import WelcomeScreen from './screen/welcomeScreen'; import ApplicationScreen from './screen/applicationScreen'; -import LaunchScreen from '../launch'; import { Modal } from '../../components'; import { PinCode } from '../pinCode'; import ErrorBoundary from './screen/errorBoundary'; @@ -15,16 +13,10 @@ import { setDeviceOrientation } from '../../redux/actions/uiAction'; const Application = () => { const dispatch = useDispatch(); - const [showAnimation, setShowAnimation] = useState(process.env.NODE_ENV !== 'development'); useEffect(() => { SplashScreen.hide(); - if (showAnimation) { - setTimeout(() => { - setShowAnimation(false); - }, 3550); - } - }, [showAnimation]); + }, []); const _handleDeviceOrientationChange = (orientation) => { console.log('device orientation changed at index : ', orientation); @@ -39,7 +31,6 @@ const Application = () => { isPinCodeRequire, isReady, isRenderRequire, - isThemeReady, locale, rcOffer, toastNotification, @@ -47,7 +38,7 @@ const Application = () => { handleWelcomeModalButtonPress, foregroundNotificationData, }) => { - const _isAppReady = !showAnimation && isReady && isRenderRequire && isThemeReady; + const _isAppReady = isReady && isRenderRequire; return ( @@ -76,7 +67,7 @@ const Application = () => { - {isThemeReady && isRenderRequire && ( + {isRenderRequire && ( { foregroundNotificationData={foregroundNotificationData} /> )} - {!_isAppReady && } ); }} From 7b87d111eb06ea2a713d951c316ef6fb99c3cad1 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 17 Jun 2022 18:29:25 +0500 Subject: [PATCH 05/43] cleaned up application screen class --- .../application/screen/applicationScreen.js | 45 ++----------------- 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/src/screens/application/screen/applicationScreen.js b/src/screens/application/screen/applicationScreen.js index d60672014..3d5fdd9fb 100644 --- a/src/screens/application/screen/applicationScreen.js +++ b/src/screens/application/screen/applicationScreen.js @@ -1,10 +1,9 @@ import React, { Component, Fragment } from 'react'; -import { StatusBar, Platform, View, Alert, Text, Modal, TouchableHighlight } from 'react-native'; +import { StatusBar, Platform, View, Alert } from 'react-native'; import EStyleSheet from 'react-native-extended-stylesheet'; import { connect } from 'react-redux'; import { createAppContainer } from 'react-navigation'; import { injectIntl } from 'react-intl'; -import VersionNumber from 'react-native-version-number'; import AppNavitation from '../../../navigation/routes'; import { setTopLevelNavigator, navigate } from '../../../navigation/service'; @@ -14,7 +13,6 @@ import { toastNotification as toastNotificationAction, setRcOffer, } from '../../../redux/actions/uiAction'; -import { getVersionForWelcomeModal } from '../../../realm/realm'; import ROUTES from '../../../constants/routeNames'; @@ -32,7 +30,6 @@ import { // Themes (Styles) import darkTheme from '../../../themes/darkTheme'; import lightTheme from '../../../themes/lightTheme'; -import parseVersionNumber from '../../../utils/parseVersionNumber'; const Navigation = createAppContainer(AppNavitation); @@ -41,20 +38,9 @@ class ApplicationScreen extends Component { super(props); this.state = { isShowToastNotification: false, - showWelcomeModal: false, }; } - componentDidMount() { - const { appVersion } = VersionNumber; - - getVersionForWelcomeModal().then((version) => { - if (version < parseVersionNumber(appVersion)) { - this.setState({ showWelcomeModal: true }); - } - }); - } - componentDidUpdate(prevProps) { const { rcOffer, dispatch, intl } = this.props; const { rcOffer: rcOfferPrev } = prevProps; @@ -117,7 +103,7 @@ class ApplicationScreen extends Component { foregroundNotificationData, navigation, } = this.props; - const { isShowToastNotification, showWelcomeModal } = this.state; + const { isShowToastNotification } = this.state; const barStyle = isDarkTheme ? 'light-content' : 'dark-content'; const barColor = isDarkTheme ? '#1e2835' : '#fff'; @@ -128,6 +114,7 @@ class ApplicationScreen extends Component { ) : ( )} + {!isConnected && } - { - Alert.alert('Modal has been closed.'); - }} - > - - Hello World! - { - this.setState({ showWelcomeModal: !showWelcomeModal }); - }} - > - Hide Modal - - - {isShowToastNotification && ( From 2b8f0fcc500c1970e2d02600f5846e880f7ac268 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 17 Jun 2022 18:31:11 +0500 Subject: [PATCH 06/43] removed unnecessary isThemeReady state --- .../container/applicationContainer.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/screens/application/container/applicationContainer.js b/src/screens/application/container/applicationContainer.js index 6b0f376e2..86aa60695 100644 --- a/src/screens/application/container/applicationContainer.js +++ b/src/screens/application/container/applicationContainer.js @@ -105,7 +105,7 @@ import darkTheme from '../../../themes/darkTheme'; import lightTheme from '../../../themes/lightTheme'; import persistAccountGenerator from '../../../utils/persistAccountGenerator'; import parseVersionNumber from '../../../utils/parseVersionNumber'; -import { getTimeFromNow, setMomentLocale } from '../../../utils/time'; +import { setMomentLocale } from '../../../utils/time'; import parseAuthUrl from '../../../utils/parseAuthUrl'; import { purgeExpiredCache } from '../../../redux/actions/cacheActions'; import { fetchSubscribedCommunities } from '../../../redux/actions/communitiesAction'; @@ -132,7 +132,6 @@ class ApplicationContainer extends Component { isRenderRequire: true, isReady: false, isIos: Platform.OS !== 'android', - isThemeReady: false, appState: AppState.currentState, showWelcomeModal: false, foregroundNotificationData: null, @@ -795,6 +794,7 @@ class ApplicationContainer extends Component { } }; + //TODO keep settings in redux and get rid of getSettings _getSettings = async () => { const { dispatch, otherAccounts } = this.props; @@ -810,9 +810,6 @@ class ApplicationContainer extends Component { if (settings) { const isDarkMode = Appearance.getColorScheme() === 'dark'; dispatch(isDarkTheme(settings.isDarkTheme !== null ? settings.isDarkTheme : isDarkMode)); - this.setState({ - isThemeReady: true, - }); if (settings.isPinCodeOpen !== '') await dispatch(isPinCodeOpen(settings.isPinCodeOpen)); if (settings.language !== '') dispatch(setLanguage(settings.language)); if (settings.server !== '') dispatch(setApi(settings.server)); @@ -1037,13 +1034,7 @@ class ApplicationContainer extends Component { isPinCodeRequire, rcOffer, } = this.props; - const { - isRenderRequire, - isReady, - isThemeReady, - showWelcomeModal, - foregroundNotificationData, - } = this.state; + const { isRenderRequire, isReady, showWelcomeModal, foregroundNotificationData } = this.state; return ( children && @@ -1053,7 +1044,6 @@ class ApplicationContainer extends Component { isPinCodeRequire, isReady, isRenderRequire, - isThemeReady, locale: selectedLanguage, rcOffer, toastNotification, From 79e15141adea00d51998ceeb13af7996c2d22b72 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 17 Jun 2022 18:32:43 +0500 Subject: [PATCH 07/43] remove application store from blacklist --- src/redux/store/store.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/redux/store/store.ts b/src/redux/store/store.ts index 1eee95a19..f59286f13 100644 --- a/src/redux/store/store.ts +++ b/src/redux/store/store.ts @@ -5,7 +5,6 @@ import AsyncStorage from '@react-native-community/async-storage'; import Reactotron from '../../../reactotron-config'; import reducer from '../reducers'; -import autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2'; const transformCacheVoteMap = createTransform( (inboundState:any) => ({ @@ -38,7 +37,7 @@ const persistConfig = { // Storage Method (React Native) storage: AsyncStorage, // Blacklist (Don't Save Specific Reducers) - blacklist: ['nav', 'application', 'communities', 'user'], + blacklist: ['nav', 'communities', 'user'], timeout: 0, transforms:[ transformCacheVoteMap, From dd320e3d11236e08ecc7cc38b835368905eba09a Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 17 Jun 2022 19:51:14 +0500 Subject: [PATCH 08/43] initialising settings on application mount --- src/screens/application/container/applicationContainer.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/screens/application/container/applicationContainer.js b/src/screens/application/container/applicationContainer.js index 86aa60695..f334767cd 100644 --- a/src/screens/application/container/applicationContainer.js +++ b/src/screens/application/container/applicationContainer.js @@ -178,6 +178,7 @@ class ApplicationContainer extends Component { }); setMomentLocale(); + this._fetchApp(); ReceiveSharingIntent.getReceivedFiles( () => { @@ -816,10 +817,11 @@ class ApplicationContainer extends Component { if (settings.upvotePercent !== '') { dispatch(setUpvotePercent(Number(settings.upvotePercent))); } - if (settings.isDefaultFooter !== '') dispatch(isDefaultFooter(settings.isDefaultFooter)); + if (settings.isDefaultFooter !== '') dispatch(isDefaultFooter(settings.isDefaultFooter)); //TODO: remove as not being used if (settings.notification !== '') { console.log('Notification Settings', settings.notification, otherAccounts); + //TODO: no need to set nottification settings here. dispatch( changeNotificationSettings({ type: 'notification', @@ -1062,7 +1064,7 @@ export default connect( selectedLanguage: state.application.language, isPinCodeOpen: state.application.isPinCodeOpen, isLogingOut: state.application.isLogingOut, - isLoggedIn: state.application.isLoggedIn, + isLoggedIn: state.application.isLoggedIn, //TODO: remove as is not being used in this class isConnected: state.application.isConnected, nav: state.nav.routes, isPinCodeRequire: state.application.isPinCodeRequire, From e2c77a1dbb2cb7f06f4d63c9c0230876da5059ca Mon Sep 17 00:00:00 2001 From: noumantahir Date: Mon, 20 Jun 2022 16:33:03 +0500 Subject: [PATCH 09/43] added todo tags for application container optimising --- src/redux/reducers/applicationReducer.ts | 2 +- src/screens/application/container/applicationContainer.js | 2 +- src/screens/settings/container/settingsContainer.js | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/redux/reducers/applicationReducer.ts b/src/redux/reducers/applicationReducer.ts index 16271a630..e8032bd03 100644 --- a/src/redux/reducers/applicationReducer.ts +++ b/src/redux/reducers/applicationReducer.ts @@ -38,7 +38,7 @@ const initialState = { isActive: false, isConnected: null, // internet connectivity isDarkTheme: false, - isDefaultFooter: true, + isDefaultFooter: true, //TODO: remove present of isDefaultFooter as it's no longer in use isLoggedIn: false, // Has any logged in user. isAnalytics: false, isLoginDone: false, diff --git a/src/screens/application/container/applicationContainer.js b/src/screens/application/container/applicationContainer.js index f334767cd..d7a3911e0 100644 --- a/src/screens/application/container/applicationContainer.js +++ b/src/screens/application/container/applicationContainer.js @@ -235,7 +235,7 @@ class ApplicationContainer extends Component { if (!isIos) BackHandler.removeEventListener('hardwareBackPress', this._onBackPress); - // NetInfo.isConnected.removeEventListener('connectionChange', this._handleConntectionChange); + //TOOD: listen for back press and cancel all pending api requests; Linking.removeEventListener('url', this._handleOpenURL); diff --git a/src/screens/settings/container/settingsContainer.js b/src/screens/settings/container/settingsContainer.js index e3a964da5..ec99731bf 100644 --- a/src/screens/settings/container/settingsContainer.js +++ b/src/screens/settings/container/settingsContainer.js @@ -269,6 +269,7 @@ class SettingsContainer extends Component { type: actionType, }), ); + //TODO: remove setting notification settings setNotificationSettings({ action, type: actionType, From 163e6b03bef78c759a98fae6aa8c9af372767366 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Wed, 29 Jun 2022 21:15:07 +0500 Subject: [PATCH 10/43] improved timing of showing welcome modal --- .../application/container/applicationContainer.js | 12 +----------- src/screens/application/index.tsx | 3 +-- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/screens/application/container/applicationContainer.js b/src/screens/application/container/applicationContainer.js index 89a2b9d53..f810ee09e 100644 --- a/src/screens/application/container/applicationContainer.js +++ b/src/screens/application/container/applicationContainer.js @@ -123,7 +123,6 @@ export const setPreviousAppState = () => { let firebaseOnNotificationOpenedAppListener = null; let firebaseOnMessageListener = null; let removeAppearanceListener = null; -let scAccounts = []; class ApplicationContainer extends Component { constructor(props) { @@ -164,16 +163,7 @@ class ApplicationContainer extends Component { getVersionForWelcomeModal().then((version) => { if (version < parseVersionNumber(appVersion)) { - getUserData().then((accounts) => { - this.setState({ showWelcomeModal: true }); - if (accounts && accounts.length > 0) { - accounts.forEach((account) => { - if (get(account, 'authType', '') === AUTH_TYPE.STEEM_CONNECT) { - scAccounts.push(account); - } - }); - } - }); + this.setState({ showWelcomeModal: true }); } }); diff --git a/src/screens/application/index.tsx b/src/screens/application/index.tsx index fb65c5c9a..07beab188 100644 --- a/src/screens/application/index.tsx +++ b/src/screens/application/index.tsx @@ -38,7 +38,6 @@ const Application = () => { handleWelcomeModalButtonPress, foregroundNotificationData, }) => { - const _isAppReady = isReady && isRenderRequire; return ( @@ -48,7 +47,7 @@ const Application = () => { onDeviceChange={_handleDeviceOrientationChange} /> Date: Wed, 29 Jun 2022 21:30:14 +0500 Subject: [PATCH 11/43] cleaned getSettings method --- .../container/applicationContainer.js | 59 +++++++++++-------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/src/screens/application/container/applicationContainer.js b/src/screens/application/container/applicationContainer.js index f810ee09e..f415bd1c4 100644 --- a/src/screens/application/container/applicationContainer.js +++ b/src/screens/application/container/applicationContainer.js @@ -787,8 +787,9 @@ class ApplicationContainer extends Component { //TODO keep settings in redux and get rid of getSettings _getSettings = async () => { - const { dispatch, otherAccounts } = this.props; + const { dispatch } = this.props; + //TOOD: no need for resetting modal here afer adding them to non persist store. //reset certain properties dispatch(hideActionModal()); dispatch(hideProfileModal()); @@ -810,30 +811,7 @@ class ApplicationContainer extends Component { if (settings.isDefaultFooter !== '') dispatch(isDefaultFooter(settings.isDefaultFooter)); //TODO: remove as not being used if (settings.notification !== '') { - console.log('Notification Settings', settings.notification, otherAccounts); - //TODO: no need to set nottification settings here. - dispatch( - changeNotificationSettings({ - type: 'notification', - action: settings.notification, - }), - ); - dispatch(changeAllNotificationSettings(settings)); - - //updateing fcm token with settings; - otherAccounts.forEach((account) => { - //since there can be more than one accounts, process access tokens separate - const encAccessToken = account.local.accessToken; - //decrypt access token - let accessToken = null; - if (encAccessToken) { - //NOTE: default pin decryption works also for custom pin as other account - //keys are not yet being affected by changed pin, which I think we should dig more - accessToken = decryptKey(encAccessToken, Config.DEFAULT_PIN); - } - - this._enableNotification(account.name, settings.notification, settings, accessToken); - }); + this._initNotificationSettings(settings); } if (settings.nsfw !== '') dispatch(setNsfw(settings.nsfw)); @@ -841,6 +819,37 @@ class ApplicationContainer extends Component { } }; + + //update notification settings and update push token for each signed accoutn useing access tokens + _initNotificationSettings = (settings) => { + const { dispatch, otherAccounts } = this.props; + + console.log('Notification Settings', settings.notification, otherAccounts); + //TODO: no need to set nottification settings here. + dispatch( + changeNotificationSettings({ + type: 'notification', + action: settings.notification, + }), + ); + + dispatch(changeAllNotificationSettings(settings)); + //updateing fcm token with settings; + otherAccounts.forEach((account) => { + //since there can be more than one accounts, process access tokens separate + const encAccessToken = account.local.accessToken; + //decrypt access token + let accessToken = null; + if (encAccessToken) { + //NOTE: default pin decryption works also for custom pin as other account + //keys are not yet being affected by changed pin, which I think we should dig more + accessToken = decryptKey(encAccessToken, Config.DEFAULT_PIN); + } + + this._enableNotification(account.name, settings.notification, settings, accessToken); + }); + } + _connectNotificationServer = (username) => { /* eslint no-undef: "warn" */ const ws = new WebSocket(`${Config.ACTIVITY_WEBSOCKET_URL}?user=${username}`); From f735e8d7a3825bec157caa5670d081dd9a35d962 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Wed, 29 Jun 2022 21:30:30 +0500 Subject: [PATCH 12/43] removed isReady prop as it's no longer needed --- .../application/container/applicationContainer.js | 10 ++-------- src/screens/application/index.tsx | 2 -- src/screens/application/screen/applicationScreen.js | 11 ++--------- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/screens/application/container/applicationContainer.js b/src/screens/application/container/applicationContainer.js index f415bd1c4..3cbf962c2 100644 --- a/src/screens/application/container/applicationContainer.js +++ b/src/screens/application/container/applicationContainer.js @@ -129,7 +129,6 @@ class ApplicationContainer extends Component { super(props); this.state = { isRenderRequire: true, - isReady: false, isIos: Platform.OS !== 'android', appState: AppState.currentState, showWelcomeModal: false, @@ -466,9 +465,6 @@ class ApplicationContainer extends Component { _fetchApp = async () => { await this._getSettings(); - this.setState({ - isReady: true, - }); this._refreshGlobalProps(); await this._getUserDataFromRealm(); this._compareAndPromptForUpdate(); @@ -819,7 +815,6 @@ class ApplicationContainer extends Component { } }; - //update notification settings and update push token for each signed accoutn useing access tokens _initNotificationSettings = (settings) => { const { dispatch, otherAccounts } = this.props; @@ -848,7 +843,7 @@ class ApplicationContainer extends Component { this._enableNotification(account.name, settings.notification, settings, accessToken); }); - } + }; _connectNotificationServer = (username) => { /* eslint no-undef: "warn" */ @@ -1048,7 +1043,7 @@ class ApplicationContainer extends Component { isPinCodeRequire, rcOffer, } = this.props; - const { isRenderRequire, isReady, showWelcomeModal, foregroundNotificationData } = this.state; + const { isRenderRequire, showWelcomeModal, foregroundNotificationData } = this.state; return ( children && @@ -1056,7 +1051,6 @@ class ApplicationContainer extends Component { isConnected, isDarkTheme: _isDarkTheme, isPinCodeRequire, - isReady, isRenderRequire, locale: selectedLanguage, rcOffer, diff --git a/src/screens/application/index.tsx b/src/screens/application/index.tsx index 07beab188..161345070 100644 --- a/src/screens/application/index.tsx +++ b/src/screens/application/index.tsx @@ -29,7 +29,6 @@ const Application = () => { isConnected, isDarkTheme, isPinCodeRequire, - isReady, isRenderRequire, locale, rcOffer, @@ -71,7 +70,6 @@ const Application = () => { isConnected={isConnected} locale={locale} toastNotification={toastNotification} - isReady={isReady} isDarkTheme={isDarkTheme} rcOffer={rcOffer} foregroundNotificationData={foregroundNotificationData} diff --git a/src/screens/application/screen/applicationScreen.js b/src/screens/application/screen/applicationScreen.js index 3d5fdd9fb..98cbf2263 100644 --- a/src/screens/application/screen/applicationScreen.js +++ b/src/screens/application/screen/applicationScreen.js @@ -95,20 +95,13 @@ class ApplicationScreen extends Component { } render() { - const { - isConnected, - isDarkTheme, - toastNotification, - isReady, - foregroundNotificationData, - navigation, - } = this.props; + const { isConnected, isDarkTheme, toastNotification, foregroundNotificationData } = this.props; const { isShowToastNotification } = this.state; const barStyle = isDarkTheme ? 'light-content' : 'dark-content'; const barColor = isDarkTheme ? '#1e2835' : '#fff'; return ( - + {Platform.os === 'ios' ? ( ) : ( From 70425000ac70b98f966d50fab0a3e810cdcf3d3f Mon Sep 17 00:00:00 2001 From: noumantahir Date: Wed, 29 Jun 2022 21:40:35 +0500 Subject: [PATCH 13/43] to typescript --- .../{applicationContainer.js => applicationContainer.tsx} | 0 .../screen/{applicationScreen.js => applicationScreen.tsx} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/screens/application/container/{applicationContainer.js => applicationContainer.tsx} (100%) rename src/screens/application/screen/{applicationScreen.js => applicationScreen.tsx} (100%) diff --git a/src/screens/application/container/applicationContainer.js b/src/screens/application/container/applicationContainer.tsx similarity index 100% rename from src/screens/application/container/applicationContainer.js rename to src/screens/application/container/applicationContainer.tsx diff --git a/src/screens/application/screen/applicationScreen.js b/src/screens/application/screen/applicationScreen.tsx similarity index 100% rename from src/screens/application/screen/applicationScreen.js rename to src/screens/application/screen/applicationScreen.tsx From 575fd3fccaa94ce89c20c4b07da1093d74c6480e Mon Sep 17 00:00:00 2001 From: noumantahir Date: Thu, 30 Jun 2022 15:57:32 +0500 Subject: [PATCH 14/43] added null safety while accessing accessToken --- src/screens/application/container/applicationContainer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index 3cbf962c2..1021474b2 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -832,7 +832,7 @@ class ApplicationContainer extends Component { //updateing fcm token with settings; otherAccounts.forEach((account) => { //since there can be more than one accounts, process access tokens separate - const encAccessToken = account.local.accessToken; + const encAccessToken = account?.local?.accessToken; //decrypt access token let accessToken = null; if (encAccessToken) { From caf3bf7182f8d69fc7e1eec2a4e335d6e5d9a976 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Thu, 30 Jun 2022 18:38:44 +0500 Subject: [PATCH 15/43] welcome modal logic in redux based and independent of application container --- src/redux/actions/applicationActions.ts | 6 ++ src/redux/constants/constants.js | 1 + src/redux/reducers/applicationReducer.ts | 9 ++- src/screens/application/index.tsx | 14 ++--- .../{welcomeScreen.tsx => welcomeModal.tsx} | 58 ++++++++++++++++--- 5 files changed, 68 insertions(+), 20 deletions(-) rename src/screens/application/screen/{welcomeScreen.tsx => welcomeModal.tsx} (59%) diff --git a/src/redux/actions/applicationActions.ts b/src/redux/actions/applicationActions.ts index 9d5201119..71422aa40 100644 --- a/src/redux/actions/applicationActions.ts +++ b/src/redux/actions/applicationActions.ts @@ -28,6 +28,7 @@ import { SET_PIN_CODE, IS_PIN_CODE_OPEN, IS_RENDER_REQUIRED, + SET_LAST_APP_VERSION, } from '../constants/constants'; export const login = (payload) => ({ @@ -183,3 +184,8 @@ export const isRenderRequired = (payload) => ({ type: IS_RENDER_REQUIRED, }); +export const setLastAppVersion = (versionNumber:string) => ({ + payload:versionNumber, + type: SET_LAST_APP_VERSION +}) + diff --git a/src/redux/constants/constants.js b/src/redux/constants/constants.js index 2c3c0b1b9..63c7605af 100644 --- a/src/redux/constants/constants.js +++ b/src/redux/constants/constants.js @@ -33,6 +33,7 @@ export const CHANGE_MENTION_NOTIFICATION = 'CHANGE_MENTION_NOTIFICATION'; export const CHANGE_REBLOG_NOTIFICATION = 'CHANGE_REBLOG_NOTIFICATION'; export const CHANGE_TRANSFERS_NOTIFICATION = 'CHANGE_TRANSFERS_NOTIFICATION'; export const CHANGE_ALL_NOTIFICATION_SETTINGS = 'CHANGE_ALL_NOTIFICATION_SETTINGS'; +export const SET_LAST_APP_VERSION = 'SET_LAST_APP_VERSION'; // Accounts export const ADD_OTHER_ACCOUNT = 'ADD_OTHER_ACCOUNT'; diff --git a/src/redux/reducers/applicationReducer.ts b/src/redux/reducers/applicationReducer.ts index e8032bd03..fed87ff9a 100644 --- a/src/redux/reducers/applicationReducer.ts +++ b/src/redux/reducers/applicationReducer.ts @@ -26,6 +26,7 @@ import { SET_PIN_CODE, IS_PIN_CODE_OPEN, IS_RENDER_REQUIRED, + SET_LAST_APP_VERSION, } from '../constants/constants'; const initialState = { @@ -61,7 +62,7 @@ const initialState = { pin: null, isPinCodeOpen: true, isRenderRequired: false, - + lastAppVersion:'' }; export default function (state = initialState, action) { @@ -212,6 +213,12 @@ export default function (state = initialState, action) { return Object.assign({}, state, { isRenderRequired: action.payload, }); + + case SET_LAST_APP_VERSION: + return { + ...state, + lastAppVersion:action.payload + } default: return state; diff --git a/src/screens/application/index.tsx b/src/screens/application/index.tsx index 161345070..de43ff346 100644 --- a/src/screens/application/index.tsx +++ b/src/screens/application/index.tsx @@ -4,7 +4,7 @@ import SplashScreen from 'react-native-splash-screen'; import { OrientationLocker, PORTRAIT } from 'react-native-orientation-locker'; import { useDispatch } from 'react-redux'; import ApplicationContainer from './container/applicationContainer'; -import WelcomeScreen from './screen/welcomeScreen'; +import WelcomeModal from './screen/welcomeModal'; import ApplicationScreen from './screen/applicationScreen'; import { Modal } from '../../components'; import { PinCode } from '../pinCode'; @@ -45,15 +45,9 @@ const Application = () => { onChange={(orientation) => console.log('orientation changed : ', orientation)} onDeviceChange={_handleDeviceOrientationChange} /> - - - + + + { +const WelcomeModal = () => { const intl = useIntl(); - + const dispatch = useAppDispatch(); + + const lastAppVersion = useAppSelector(state=>state.application.lastAppVersion) + const [showAnimation, setShowAnimation] = useState(true); + const [showWelcomeModal, setShowWelcomeModal] = useState(false); + + const [appVersion] = useState(VersionNumber.appVersion); + + useEffect(() => { + _compareAppVersion() + }, []) + useEffect(() => { if (showAnimation) { @@ -21,7 +36,20 @@ const WelcomeScreen = ({ handleButtonPress }) => { }, 3550); } }, [showAnimation]); - + + + const _compareAppVersion = () => { + if(!lastAppVersion || (parseVersionNumber(lastAppVersion) < parseVersionNumber(appVersion))){ + setShowWelcomeModal(true); + } + } + + + const _handleButtonPress = () => { + dispatch(setLastAppVersion(appVersion)) + setShowWelcomeModal(false); + } + const _renderInfo = (iconName, headingIntlId, bodyIntlId) => ( @@ -38,9 +66,9 @@ const WelcomeScreen = ({ handleButtonPress }) => { ); - return ( + const _renderContent = () => ( - + { { {showAnimation && } ); + + + return ( + + {_renderContent()} + ) }; -export default WelcomeScreen; +export default WelcomeModal; From f814c1626a701a999c160356358f78b98eea2e5c Mon Sep 17 00:00:00 2001 From: noumantahir Date: Thu, 30 Jun 2022 19:08:49 +0500 Subject: [PATCH 16/43] removed welcome modal login from application container --- .../container/applicationContainer.tsx | 19 +------------------ src/screens/application/index.tsx | 13 ++++++------- .../application/screen/welcomeModal.tsx | 9 +++++++-- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index 1021474b2..6bdb16c36 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -34,8 +34,6 @@ import { setAuthStatus, removeSCAccount, setExistUser, - getVersionForWelcomeModal, - setVersionForWelcomeModal, getLastUpdateCheck, setLastUpdateCheck, getTheme, @@ -131,7 +129,6 @@ class ApplicationContainer extends Component { isRenderRequire: true, isIos: Platform.OS !== 'android', appState: AppState.currentState, - showWelcomeModal: false, foregroundNotificationData: null, }; } @@ -160,11 +157,6 @@ class ApplicationContainer extends Component { //set avatar cache stamp to invalidate previous session avatars dispatch(setAvatarCacheStamp(new Date().getTime())); - getVersionForWelcomeModal().then((version) => { - if (version < parseVersionNumber(appVersion)) { - this.setState({ showWelcomeModal: true }); - } - }); setMomentLocale(); this._fetchApp(); @@ -981,13 +973,6 @@ class ApplicationContainer extends Component { dispatch(fetchSubscribedCommunities(_currentAccount.username)); }; - _handleWelcomeModalButtonPress = () => { - const { appVersion } = VersionNumber; - - setVersionForWelcomeModal(appVersion); - - this.setState({ showWelcomeModal: false }); - }; UNSAFE_componentWillReceiveProps(nextProps) { const { @@ -1043,7 +1028,7 @@ class ApplicationContainer extends Component { isPinCodeRequire, rcOffer, } = this.props; - const { isRenderRequire, showWelcomeModal, foregroundNotificationData } = this.state; + const { isRenderRequire, foregroundNotificationData } = this.state; return ( children && @@ -1055,9 +1040,7 @@ class ApplicationContainer extends Component { locale: selectedLanguage, rcOffer, toastNotification, - showWelcomeModal, foregroundNotificationData, - handleWelcomeModalButtonPress: this._handleWelcomeModalButtonPress, }) ); } diff --git a/src/screens/application/index.tsx b/src/screens/application/index.tsx index de43ff346..01463cf04 100644 --- a/src/screens/application/index.tsx +++ b/src/screens/application/index.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import SplashScreen from 'react-native-splash-screen'; import { OrientationLocker, PORTRAIT } from 'react-native-orientation-locker'; @@ -14,6 +14,8 @@ import { setDeviceOrientation } from '../../redux/actions/uiAction'; const Application = () => { const dispatch = useDispatch(); + const [welcomeModalVisible, setWelcomeModalVisible] = useState(false); + useEffect(() => { SplashScreen.hide(); }, []); @@ -33,8 +35,6 @@ const Application = () => { locale, rcOffer, toastNotification, - showWelcomeModal, - handleWelcomeModalButtonPress, foregroundNotificationData, }) => { @@ -45,12 +45,11 @@ const Application = () => { onChange={(orientation) => console.log('orientation changed : ', orientation)} onDeviceChange={_handleDeviceOrientationChange} /> - - - + + { +const WelcomeModal = ({onModalVisibilityChange}) => { const intl = useIntl(); const dispatch = useAppDispatch(); @@ -21,9 +21,9 @@ const WelcomeModal = () => { const [showAnimation, setShowAnimation] = useState(true); const [showWelcomeModal, setShowWelcomeModal] = useState(false); - const [appVersion] = useState(VersionNumber.appVersion); + useEffect(() => { _compareAppVersion() }, []) @@ -41,6 +41,7 @@ const WelcomeModal = () => { const _compareAppVersion = () => { if(!lastAppVersion || (parseVersionNumber(lastAppVersion) < parseVersionNumber(appVersion))){ setShowWelcomeModal(true); + onModalVisibilityChange(true) } } @@ -48,6 +49,10 @@ const WelcomeModal = () => { const _handleButtonPress = () => { dispatch(setLastAppVersion(appVersion)) setShowWelcomeModal(false); + setTimeout(()=>{ + onModalVisibilityChange(false) + }, 100) + } From 0ba23095c036766cd43f72d98524cc2adb0d5adb Mon Sep 17 00:00:00 2001 From: noumantahir Date: Thu, 30 Jun 2022 19:48:18 +0500 Subject: [PATCH 17/43] moved a bunch of pinCode modal logic out of application container --- src/redux/actions/applicationActions.ts | 2 +- .../container/applicationContainer.tsx | 28 +------ src/screens/application/index.tsx | 13 +--- .../application/screen/pinCodeModal.tsx | 77 +++++++++++++++++++ .../application/screen/welcomeModal.tsx | 34 ++++---- 5 files changed, 100 insertions(+), 54 deletions(-) create mode 100644 src/screens/application/screen/pinCodeModal.tsx diff --git a/src/redux/actions/applicationActions.ts b/src/redux/actions/applicationActions.ts index 71422aa40..4a281d609 100644 --- a/src/redux/actions/applicationActions.ts +++ b/src/redux/actions/applicationActions.ts @@ -48,7 +48,7 @@ export const isLoginDone = () => ({ type: IS_LOGIN_DONE, }); -export const openPinCodeModal = (payload) => ({ +export const openPinCodeModal = (payload = null) => ({ payload, type: OPEN_PIN_CODE_MODAL, }); diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index 6bdb16c36..dcc8e10d2 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -10,7 +10,6 @@ import { NavigationActions } from 'react-navigation'; import { bindActionCreators } from 'redux'; import EStyleSheet from 'react-native-extended-stylesheet'; import { isEmpty, some } from 'lodash'; -import { useDarkMode } from 'react-native-dynamic'; import messaging from '@react-native-firebase/messaging'; import PushNotification from 'react-native-push-notification'; import VersionNumber from 'react-native-version-number'; @@ -420,22 +419,10 @@ class ApplicationContainer extends Component { ); }; + _handleAppStateChange = (nextAppState) => { const { appState } = this.state; - const { isPinCodeOpen: _isPinCodeOpen } = this.props; - getExistUser().then((isExistUser) => { - if (isExistUser) { - if (appState.match(/active|forground/) && nextAppState === 'inactive') { - this._startPinCodeTimer(); - } - if (appState.match(/inactive|background/) && nextAppState === 'active') { - if (_isPinCodeOpen) { - clearTimeout(this._pinCodeTimer); - } - } - } - }); if (appState.match(/inactive|background/) && nextAppState === 'active') { this._refreshGlobalProps(); } @@ -445,15 +432,6 @@ class ApplicationContainer extends Component { }); }; - _startPinCodeTimer = () => { - const { dispatch, isPinCodeOpen: _isPinCodeOpen } = this.props; - - if (_isPinCodeOpen) { - this._pinCodeTimer = setTimeout(() => { - dispatch(openPinCodeModal()); - }, 1 * 60 * 1000); - } - }; _fetchApp = async () => { await this._getSettings(); @@ -674,11 +652,11 @@ class ApplicationContainer extends Component { // TODO: await switchAccount(realmObject[0].username); } - const isExistUser = await getExistUser(); + realmObject[0].name = currentUsername; // If in dev mode pin code does not show - if ((!isExistUser || !pinCode) && _isPinCodeOpen) { + if (_isPinCodeOpen) { dispatch(openPinCodeModal()); } else if (!_isPinCodeOpen) { const encryptedPin = encryptKey(Config.DEFAULT_PIN, Config.PIN_KEY); diff --git a/src/screens/application/index.tsx b/src/screens/application/index.tsx index 01463cf04..6c1a74633 100644 --- a/src/screens/application/index.tsx +++ b/src/screens/application/index.tsx @@ -10,6 +10,7 @@ import { Modal } from '../../components'; import { PinCode } from '../pinCode'; import ErrorBoundary from './screen/errorBoundary'; import { setDeviceOrientation } from '../../redux/actions/uiAction'; +import PinCodeModal from './screen/pinCodeModal'; const Application = () => { const dispatch = useDispatch(); @@ -48,15 +49,9 @@ const Application = () => { - - - + + + {isRenderRequire && ( { + const dispatch = useAppDispatch(); + + const pinCodeTimer = useRef(null); + const appState = useRef(AppState.currentState); + + const isPinCodeRequire = useAppSelector(state => state.application.isPinCodeRequire); + const isPinCodeOpen = useAppSelector(state => state.application.isPinCodeOpen); + + + useEffect(() => { + AppState.addEventListener('change', _handleAppStateChange); + return _unmount + }, []) + + + const _unmount = () => { + AppState.removeEventListener('change', _handleAppStateChange); + } + + + const _handleAppStateChange = (nextAppState) => { + getExistUser().then((isExistUser) => { + if (isExistUser) { + if (appState.current.match(/active|forground/) && nextAppState === 'inactive') { + _startPinCodeTimer(); + } + + if (appState.current.match(/inactive|background/) && nextAppState === 'active') { + if (isPinCodeOpen && pinCodeTimer.current) { + clearTimeout(pinCodeTimer.current); + } + } + } + }); + + appState.current = nextAppState; + }; + + + + const _startPinCodeTimer = () => { + if (isPinCodeOpen) { + pinCodeTimer.current = setTimeout(() => { + dispatch(openPinCodeModal()); + }, 1 * 60 * 1000); + } + }; + + + return ( + + + + ) +} + +export default PinCodeModal \ No newline at end of file diff --git a/src/screens/application/screen/welcomeModal.tsx b/src/screens/application/screen/welcomeModal.tsx index b979ead56..de4dcc134 100644 --- a/src/screens/application/screen/welcomeModal.tsx +++ b/src/screens/application/screen/welcomeModal.tsx @@ -13,11 +13,11 @@ import LaunchScreen from '../../launch'; import styles from './welcomeStyles'; -const WelcomeModal = ({onModalVisibilityChange}) => { +const WelcomeModal = ({ onModalVisibilityChange }) => { const intl = useIntl(); const dispatch = useAppDispatch(); - const lastAppVersion = useAppSelector(state=>state.application.lastAppVersion) + const lastAppVersion = useAppSelector(state => state.application.lastAppVersion) const [showAnimation, setShowAnimation] = useState(true); const [showWelcomeModal, setShowWelcomeModal] = useState(false); @@ -29,30 +29,26 @@ const WelcomeModal = ({onModalVisibilityChange}) => { }, []) - useEffect(() => { - if (showAnimation) { - setTimeout(() => { - setShowAnimation(false); - }, 3550); - } - }, [showAnimation]); - - const _compareAppVersion = () => { - if(!lastAppVersion || (parseVersionNumber(lastAppVersion) < parseVersionNumber(appVersion))){ - setShowWelcomeModal(true); - onModalVisibilityChange(true) - } + if (!lastAppVersion || (parseVersionNumber(lastAppVersion) < parseVersionNumber(appVersion))) { + _showWelcomeModal(); + } + } + + const _showWelcomeModal = () => { + setShowWelcomeModal(true); + onModalVisibilityChange(true); + setShowAnimation(true); + setTimeout(() => { + setShowAnimation(false); + }, 3550); } const _handleButtonPress = () => { dispatch(setLastAppVersion(appVersion)) setShowWelcomeModal(false); - setTimeout(()=>{ - onModalVisibilityChange(false) - }, 100) - + onModalVisibilityChange(false); } From c8e60c2271b9a2acf639e425beaa3a9f6ad5bee4 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Thu, 30 Jun 2022 20:40:20 +0500 Subject: [PATCH 18/43] added 300 ms timeout to splash screen hiding for testing --- src/screens/application/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/screens/application/index.tsx b/src/screens/application/index.tsx index 6c1a74633..5e1f3e6f5 100644 --- a/src/screens/application/index.tsx +++ b/src/screens/application/index.tsx @@ -6,8 +6,6 @@ import { useDispatch } from 'react-redux'; import ApplicationContainer from './container/applicationContainer'; import WelcomeModal from './screen/welcomeModal'; import ApplicationScreen from './screen/applicationScreen'; -import { Modal } from '../../components'; -import { PinCode } from '../pinCode'; import ErrorBoundary from './screen/errorBoundary'; import { setDeviceOrientation } from '../../redux/actions/uiAction'; import PinCodeModal from './screen/pinCodeModal'; @@ -18,7 +16,9 @@ const Application = () => { const [welcomeModalVisible, setWelcomeModalVisible] = useState(false); useEffect(() => { - SplashScreen.hide(); + setTimeout(()=>{ + SplashScreen.hide(); + }, 300) }, []); const _handleDeviceOrientationChange = (orientation) => { From 9a4455a570ecac97bf5e5f4ef05a5910ecfc0405 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Thu, 30 Jun 2022 20:45:50 +0500 Subject: [PATCH 19/43] added notification todo --- src/screens/application/container/applicationContainer.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index dcc8e10d2..8004d6e78 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -419,7 +419,7 @@ class ApplicationContainer extends Component { ); }; - + _handleAppStateChange = (nextAppState) => { const { appState } = this.state; @@ -665,6 +665,7 @@ class ApplicationContainer extends Component { if (isConnected) { this._fetchUserDataFromDsteem(realmObject[0]); + } return realmObject[0]; @@ -744,6 +745,7 @@ class ApplicationContainer extends Component { dispatch(updateCurrentAccount(accountData)); dispatch(fetchSubscribedCommunities(realmObject.username)); this._connectNotificationServer(accountData.name); + //TODO: better update device push token here after access token refresh } catch (err) { Alert.alert( `${intl.formatMessage({ id: 'alert.fetch_error' })} \n${err.message.substr(0, 20)}`, From 19285e8d122bdfca990fac68537c308e652bcc43 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 1 Jul 2022 17:47:40 +0500 Subject: [PATCH 20/43] removed package react-native-splash-screen --- ios/Ecency/AppDelegate.m | 2 -- ios/Podfile.lock | 8 +------- package.json | 1 - src/screens/application/index.tsx | 7 ------- yarn.lock | 5 ----- 5 files changed, 1 insertion(+), 22 deletions(-) diff --git a/ios/Ecency/AppDelegate.m b/ios/Ecency/AppDelegate.m index 023c4ec99..109178faf 100644 --- a/ios/Ecency/AppDelegate.m +++ b/ios/Ecency/AppDelegate.m @@ -1,4 +1,3 @@ -#import "RNSplashScreen.h" #import "AppDelegate.h" #import #import @@ -52,7 +51,6 @@ rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; - [RNSplashScreen show]; return YES; } diff --git a/ios/Podfile.lock b/ios/Podfile.lock index b15638732..6d6b1a1aa 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -361,8 +361,6 @@ PODS: - React-Core - react-native-safe-area-context (3.1.9): - React-Core - - react-native-splash-screen (3.2.0): - - React - react-native-udp (2.7.0): - React - react-native-version-number (0.3.6): @@ -537,7 +535,6 @@ DEPENDENCIES: - react-native-receive-sharing-intent (from `../node_modules/react-native-receive-sharing-intent`) - react-native-restart (from `../node_modules/react-native-restart`) - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) - - react-native-splash-screen (from `../node_modules/react-native-splash-screen`) - react-native-udp (from `../node_modules/react-native-udp`) - react-native-version-number (from `../node_modules/react-native-version-number`) - react-native-video (from `../node_modules/react-native-video`) @@ -666,8 +663,6 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-restart" react-native-safe-area-context: :path: "../node_modules/react-native-safe-area-context" - react-native-splash-screen: - :path: "../node_modules/react-native-splash-screen" react-native-udp: :path: "../node_modules/react-native-udp" react-native-version-number: @@ -791,7 +786,6 @@ SPEC CHECKSUMS: react-native-receive-sharing-intent: feba0a332a07977549a85aa58b496eb44368366a react-native-restart: aaad36f3ed7031daac3565f4a79d67e4f3884a50 react-native-safe-area-context: b6e0e284002381d2ff29fa4fff42b4d8282e3c94 - react-native-splash-screen: 200d11d188e2e78cea3ad319964f6142b6384865 react-native-udp: ff9d13e523f2b58e6bc5d4d32321ac60671b5dc9 react-native-version-number: b415bbec6a13f2df62bf978e85bc0d699462f37f react-native-video: a4c2635d0802f983594b7057e1bce8f442f0ad28 @@ -833,4 +827,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 0282022703ad578ab2d9afbf3147ba3b373b4311 -COCOAPODS: 1.11.2 +COCOAPODS: 1.10.2 diff --git a/package.json b/package.json index a57a96347..0b3037637 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,6 @@ "react-native-scrollable-tab-view": "ecency/react-native-scrollable-tab-view", "react-native-slider": "^0.11.0", "react-native-snap-carousel": "^3.8.0", - "react-native-splash-screen": "^3.2.0", "react-native-svg": "^12.1.1", "react-native-swiper": "^1.6.0-rc.3", "react-native-tcp": "^4.0.0", diff --git a/src/screens/application/index.tsx b/src/screens/application/index.tsx index 5e1f3e6f5..57ffc459d 100644 --- a/src/screens/application/index.tsx +++ b/src/screens/application/index.tsx @@ -1,5 +1,4 @@ import React, { useEffect, useState } from 'react'; -import SplashScreen from 'react-native-splash-screen'; import { OrientationLocker, PORTRAIT } from 'react-native-orientation-locker'; import { useDispatch } from 'react-redux'; @@ -15,12 +14,6 @@ const Application = () => { const [welcomeModalVisible, setWelcomeModalVisible] = useState(false); - useEffect(() => { - setTimeout(()=>{ - SplashScreen.hide(); - }, 300) - }, []); - const _handleDeviceOrientationChange = (orientation) => { console.log('device orientation changed at index : ', orientation); dispatch(setDeviceOrientation(orientation)); diff --git a/yarn.lock b/yarn.lock index ed5bf52dc..8744e58d9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9049,11 +9049,6 @@ react-native-snap-carousel@^3.8.0: prop-types "^15.6.1" react-addons-shallow-compare "15.6.2" -react-native-splash-screen@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/react-native-splash-screen/-/react-native-splash-screen-3.2.0.tgz#d47ec8557b1ba988ee3ea98d01463081b60fff45" - integrity sha512-Ls9qiNZzW/OLFoI25wfjjAcrf2DZ975hn2vr6U9gyuxi2nooVbzQeFoQS5vQcbCt9QX5NY8ASEEAtlLdIa6KVg== - react-native-svg@^12.1.1: version "12.1.1" resolved "https://registry.yarnpkg.com/react-native-svg/-/react-native-svg-12.1.1.tgz#5f292410b8bcc07bbc52b2da7ceb22caf5bcaaee" From c71954209608df99be8c58b834232d712d6cb78a Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 1 Jul 2022 17:50:06 +0500 Subject: [PATCH 21/43] updated splash screen configs --- ios/Ecency/Base.lproj/LaunchScreen.xib | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ios/Ecency/Base.lproj/LaunchScreen.xib b/ios/Ecency/Base.lproj/LaunchScreen.xib index 9296b97a7..5da3ecb75 100644 --- a/ios/Ecency/Base.lproj/LaunchScreen.xib +++ b/ios/Ecency/Base.lproj/LaunchScreen.xib @@ -1,29 +1,33 @@ - + + - + + + - - - - + + + + + - + From c9a49b76c7ca89e60c7cdf7a8a2fd0d67c993a97 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 1 Jul 2022 17:59:17 +0500 Subject: [PATCH 22/43] removed unused active application flag --- src/redux/actions/applicationActions.ts | 4 ---- src/redux/constants/constants.js | 1 - src/redux/reducers/applicationReducer.ts | 7 ------- .../application/container/applicationContainer.tsx | 11 ++++------- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/redux/actions/applicationActions.ts b/src/redux/actions/applicationActions.ts index 4a281d609..2ee7174c4 100644 --- a/src/redux/actions/applicationActions.ts +++ b/src/redux/actions/applicationActions.ts @@ -1,7 +1,6 @@ import getSymbolFromCurrency from 'currency-symbol-map'; import { getCurrencyRate } from '../../providers/ecency/ecency'; import { - ACTIVE_APPLICATION, CHANGE_COMMENT_NOTIFICATION, CHANGE_FOLLOW_NOTIFICATION, CHANGE_MENTION_NOTIFICATION, @@ -57,9 +56,6 @@ export const closePinCodeModal = () => ({ type: CLOSE_PIN_CODE_MODAL, }); -export const activeApplication = () => ({ - type: ACTIVE_APPLICATION, -}); // Settings actions export const setLanguage = (payload) => ({ diff --git a/src/redux/constants/constants.js b/src/redux/constants/constants.js index 63c7605af..ac7f3d00e 100644 --- a/src/redux/constants/constants.js +++ b/src/redux/constants/constants.js @@ -4,7 +4,6 @@ export const FETCH_USER_SUCCESS = 'FETCH_USER_SUCCESS'; export const SET_USER_DATA = 'SET_USER_DATA'; // Applicaiton -export const ACTIVE_APPLICATION = 'ACTIVE_APPLICATION'; export const CLOSE_PIN_CODE_MODAL = 'CLOSE_PIN_CODE_MODAL'; export const IS_CONNECTED = 'IS_CONNECTED'; export const IS_ANALYTICS = 'IS_ANALYTICS'; diff --git a/src/redux/reducers/applicationReducer.ts b/src/redux/reducers/applicationReducer.ts index fed87ff9a..e67cc0e49 100644 --- a/src/redux/reducers/applicationReducer.ts +++ b/src/redux/reducers/applicationReducer.ts @@ -1,5 +1,4 @@ import { - ACTIVE_APPLICATION, CHANGE_COMMENT_NOTIFICATION, CHANGE_FOLLOW_NOTIFICATION, CHANGE_MENTION_NOTIFICATION, @@ -36,7 +35,6 @@ const initialState = { currencyRate: 1, currencySymbol: '$', }, - isActive: false, isConnected: null, // internet connectivity isDarkTheme: false, isDefaultFooter: true, //TODO: remove present of isDefaultFooter as it's no longer in use @@ -108,11 +106,6 @@ export default function (state = initialState, action) { ...state, isPinCodeRequire: false, }; - case ACTIVE_APPLICATION: - return { - ...state, - isActive: true, - }; case SET_API: return Object.assign({}, state, { api: action.payload, diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index 8004d6e78..209723cb4 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -46,10 +46,8 @@ import { } from '../../../providers/hive/auth'; import { setPushToken, - markActivityAsRead, markNotifications, getUnreadNotificationCount, - getLatestQuotes, } from '../../../providers/ecency/ecency'; import { fetchLatestAppVersion } from '../../../providers/github/github'; import { navigate } from '../../../navigation/service'; @@ -61,10 +59,8 @@ import { updateUnreadActivityCount, removeOtherAccount, fetchGlobalProperties, - removeAllOtherAccount, } from '../../../redux/actions/accountAction'; import { - activeApplication, isDarkTheme, changeNotificationSettings, changeAllNotificationSettings, @@ -603,7 +599,6 @@ class ApplicationContainer extends Component { const { currentUsername } = res; if (res) { - dispatch(activeApplication()); dispatch(login(true)); const userData = await getUserData(); @@ -672,7 +667,6 @@ class ApplicationContainer extends Component { } dispatch(updateCurrentAccount({})); - dispatch(activeApplication()); return null; }; @@ -753,6 +747,8 @@ class ApplicationContainer extends Component { } }; + + //TODO keep settings in redux and get rid of getSettings _getSettings = async () => { const { dispatch } = this.props; @@ -787,6 +783,8 @@ class ApplicationContainer extends Component { } }; + + //update notification settings and update push token for each signed accoutn useing access tokens _initNotificationSettings = (settings) => { const { dispatch, otherAccounts } = this.props; @@ -1037,7 +1035,6 @@ export default connect( isConnected: state.application.isConnected, nav: state.nav.routes, isPinCodeRequire: state.application.isPinCodeRequire, - isActiveApp: state.application.isActive, api: state.application.api, isGlobalRenderRequired: state.application.isRenderRequired, isAnalytics: state.application.isAnalytics, From 7312e9178fa187ccd9735f7d2307ccd0fc39af23 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 1 Jul 2022 19:17:37 +0500 Subject: [PATCH 23/43] made color theme setting independent of realm --- src/redux/actions/applicationActions.ts | 6 +++ src/redux/constants/constants.js | 1 + src/redux/reducers/applicationReducer.ts | 49 ++++++++++++++++++- .../container/applicationContainer.tsx | 46 +++++++++++------ .../settings/container/settingsContainer.js | 19 +++---- src/screens/settings/screen/settingsScreen.js | 4 +- 6 files changed, 93 insertions(+), 32 deletions(-) diff --git a/src/redux/actions/applicationActions.ts b/src/redux/actions/applicationActions.ts index 2ee7174c4..92e61f0e8 100644 --- a/src/redux/actions/applicationActions.ts +++ b/src/redux/actions/applicationActions.ts @@ -28,6 +28,7 @@ import { IS_PIN_CODE_OPEN, IS_RENDER_REQUIRED, SET_LAST_APP_VERSION, + SET_COLOR_THEME } from '../constants/constants'; export const login = (payload) => ({ @@ -132,6 +133,11 @@ export const isDarkTheme = (payload) => ({ type: IS_DARK_THEME, }); +export const setColorTheme = (payload:number) => ({ + payload, + type: SET_COLOR_THEME +}) + export const isPinCodeOpen = (payload) => ({ payload, type: IS_PIN_CODE_OPEN, diff --git a/src/redux/constants/constants.js b/src/redux/constants/constants.js index ac7f3d00e..87b4f2e15 100644 --- a/src/redux/constants/constants.js +++ b/src/redux/constants/constants.js @@ -33,6 +33,7 @@ export const CHANGE_REBLOG_NOTIFICATION = 'CHANGE_REBLOG_NOTIFICATION'; export const CHANGE_TRANSFERS_NOTIFICATION = 'CHANGE_TRANSFERS_NOTIFICATION'; export const CHANGE_ALL_NOTIFICATION_SETTINGS = 'CHANGE_ALL_NOTIFICATION_SETTINGS'; export const SET_LAST_APP_VERSION = 'SET_LAST_APP_VERSION'; +export const SET_COLOR_THEME = 'SET_COLOR_THEME'; // Accounts export const ADD_OTHER_ACCOUNT = 'ADD_OTHER_ACCOUNT'; diff --git a/src/redux/reducers/applicationReducer.ts b/src/redux/reducers/applicationReducer.ts index e67cc0e49..059a8d76d 100644 --- a/src/redux/reducers/applicationReducer.ts +++ b/src/redux/reducers/applicationReducer.ts @@ -26,9 +26,47 @@ import { IS_PIN_CODE_OPEN, IS_RENDER_REQUIRED, SET_LAST_APP_VERSION, + SET_COLOR_THEME, } from '../constants/constants'; -const initialState = { +interface State { + api: string; + currency: { + currency: string, + currencyRate: number, + currencySymbol: string, + }, + isConnected: boolean|null, // internet connectivity + isDarkTheme: boolean; + colorTheme: number; + isDefaultFooter: boolean; //TODO: remove present of isDefaultFooter as it's no longer in use + isLoggedIn: boolean; // Has any logged in user. + isAnalytics: boolean; + isLoginDone: boolean; + isLogingOut: boolean; + isNotificationOpen: boolean; + isPinCodeRequire: boolean; + pinCodeNavigation: any, + language: string, + loading: boolean; // It is lock to all screen and shows loading animation. + notificationDetails: { + commentNotification: boolean, + followNotification: boolean, + mentionNotification: boolean, + reblogNotification: boolean, + transfersNotification: boolean, + voteNotification: boolean, + }, + upvotePercent: number, + nsfw: string, + pin: string|null, + isPinCodeOpen: boolean, + isRenderRequired: boolean, + lastAppVersion:string; + settingsMigrated: boolean, +} + +const initialState:State = { api: 'rpc.ecency.com', currency: { currency: 'usd', @@ -37,6 +75,7 @@ const initialState = { }, isConnected: null, // internet connectivity isDarkTheme: false, + colorTheme: 0, //values mapped from => src/constants/options/theme.ts isDefaultFooter: true, //TODO: remove present of isDefaultFooter as it's no longer in use isLoggedIn: false, // Has any logged in user. isAnalytics: false, @@ -60,7 +99,8 @@ const initialState = { pin: null, isPinCodeOpen: true, isRenderRequired: false, - lastAppVersion:'' + lastAppVersion:'', + settingsMigrated: false, }; export default function (state = initialState, action) { @@ -181,6 +221,11 @@ export default function (state = initialState, action) { return Object.assign({}, state, { isDarkTheme: action.payload, }); + case SET_COLOR_THEME: + return { + ...state, + colorTheme:action.payload + }; case IS_PIN_CODE_OPEN: return Object.assign({}, state, { isPinCodeOpen: action.payload, diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index 209723cb4..88080d9e1 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -20,6 +20,7 @@ import Matomo from 'react-native-matomo-sdk'; import AUTH_TYPE from '../../../constants/authType'; import ROUTES from '../../../constants/routeNames'; import postUrlParser from '../../../utils/postUrlParser'; +import THEME_OPTIONS from '../../../constants/options/theme'; // Services import { @@ -79,6 +80,7 @@ import { setPinCode as savePinCode, isRenderRequired, logout, + setColorTheme, } from '../../../redux/actions/applicationActions'; import { hideActionModal, @@ -751,7 +753,7 @@ class ApplicationContainer extends Component { //TODO keep settings in redux and get rid of getSettings _getSettings = async () => { - const { dispatch } = this.props; + const { dispatch, settingsMigrated } = this.props; //TOOD: no need for resetting modal here afer adding them to non persist store. //reset certain properties @@ -761,11 +763,20 @@ class ApplicationContainer extends Component { dispatch(purgeExpiredCache()); dispatch(setRcOffer(false)); + //TODO: set pin code navigation to null, else move it to non persisted state + + if(settingsMigrated){ + // this._initNotificationSettings(settings); + return; + } + + const settings = await getSettings(); if (settings) { const isDarkMode = Appearance.getColorScheme() === 'dark'; dispatch(isDarkTheme(settings.isDarkTheme !== null ? settings.isDarkTheme : isDarkMode)); + dispatch(setColorTheme(THEME_OPTIONS.findIndex(item=>item.value===settings.isDarkTheme))); if (settings.isPinCodeOpen !== '') await dispatch(isPinCodeOpen(settings.isPinCodeOpen)); if (settings.language !== '') dispatch(setLanguage(settings.language)); if (settings.server !== '') dispatch(setApi(settings.server)); @@ -774,12 +785,22 @@ class ApplicationContainer extends Component { } if (settings.isDefaultFooter !== '') dispatch(isDefaultFooter(settings.isDefaultFooter)); //TODO: remove as not being used - if (settings.notification !== '') { - this._initNotificationSettings(settings); - } + if (settings.nsfw !== '') dispatch(setNsfw(settings.nsfw)); - await dispatch(setCurrency(settings.currency !== '' ? settings.currency : 'usd')); + dispatch(setCurrency(settings.currency !== '' ? settings.currency : 'usd')); + + if (settings.notification !== '') { + dispatch( + changeNotificationSettings({ + type: 'notification', + action: settings.notification, + }), + ); + + dispatch(changeAllNotificationSettings(settings)); + this._initNotificationSettings(settings); + } } }; @@ -787,18 +808,8 @@ class ApplicationContainer extends Component { //update notification settings and update push token for each signed accoutn useing access tokens _initNotificationSettings = (settings) => { - const { dispatch, otherAccounts } = this.props; + const { otherAccounts } = this.props; - console.log('Notification Settings', settings.notification, otherAccounts); - //TODO: no need to set nottification settings here. - dispatch( - changeNotificationSettings({ - type: 'notification', - action: settings.notification, - }), - ); - - dispatch(changeAllNotificationSettings(settings)); //updateing fcm token with settings; otherAccounts.forEach((account) => { //since there can be more than one accounts, process access tokens separate @@ -815,6 +826,8 @@ class ApplicationContainer extends Component { }); }; + + _connectNotificationServer = (username) => { /* eslint no-undef: "warn" */ const ws = new WebSocket(`${Config.ACTIVITY_WEBSOCKET_URL}?user=${username}`); @@ -1039,6 +1052,7 @@ export default connect( isGlobalRenderRequired: state.application.isRenderRequired, isAnalytics: state.application.isAnalytics, lastUpdateCheck: state.application.lastUpdateCheck, + settingsMigrated: state.application.settingsMigrated, // Account unreadActivityCount: state.account.currentAccount.unread_activity_count, diff --git a/src/screens/settings/container/settingsContainer.js b/src/screens/settings/container/settingsContainer.js index ec99731bf..f958cf8b0 100644 --- a/src/screens/settings/container/settingsContainer.js +++ b/src/screens/settings/container/settingsContainer.js @@ -42,6 +42,7 @@ import { login, logoutDone, closePinCodeModal, + setColorTheme, } from '../../../redux/actions/applicationActions'; import { toastNotification } from '../../../redux/actions/uiAction'; import { setPushToken, getNodes } from '../../../providers/ecency/ecency'; @@ -91,12 +92,6 @@ class SettingsContainer extends Component { serverList: SERVER_LIST, }), ); - - getTheme().then((themeSetting) => { - this.setState({ - themeSetting, - }); - }); } // Component Functions @@ -127,11 +122,9 @@ class SettingsContainer extends Component { const systemTheme = Appearance.getColorScheme(); dispatch(isDarkTheme(setting === null ? systemTheme === 'dark' : setting)); + dispatch(setColorTheme(action)); + setTheme(setting); //TODO: remove before merging - setTheme(setting); - this.setState({ - themeSetting: setting, - }); break; default: @@ -469,7 +462,8 @@ class SettingsContainer extends Component { }; render() { - const { serverList, isNotificationMenuOpen, isLoading, themeSetting } = this.state; + const { serverList, isNotificationMenuOpen, isLoading } = this.state; + const { colorTheme } = this.props; return ( ); @@ -487,6 +481,7 @@ class SettingsContainer extends Component { const mapStateToProps = (state) => ({ isDarkTheme: state.application.isDarkTheme, + colorTheme: state.application.colorTheme, isPinCodeOpen: state.application.isPinCodeOpen, pinCode: state.application.pin, isDefaultFooter: state.application.isDefaultFooter, diff --git a/src/screens/settings/screen/settingsScreen.js b/src/screens/settings/screen/settingsScreen.js index 1f5198b94..5aa362e50 100644 --- a/src/screens/settings/screen/settingsScreen.js +++ b/src/screens/settings/screen/settingsScreen.js @@ -22,7 +22,7 @@ const SettingsScreen = ({ handleOnChange, intl, isDarkTheme, - themeSetting, + colorThemeIndex, isPinCodeOpen, isLoggedIn, isNotificationSettingsOpen, @@ -129,7 +129,7 @@ const SettingsScreen = ({ id: item.key, }), )} - selectedOptionIndex={THEME_OPTIONS.findIndex((item) => item.value === themeSetting)} + selectedOptionIndex={colorThemeIndex} handleOnChange={handleOnChange} /> From f52602ac8b7a05ca9ec4d074691f9d07e83c6fb1 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 1 Jul 2022 19:59:55 +0500 Subject: [PATCH 24/43] added more todos --- .../application/container/applicationContainer.tsx | 8 +++++--- src/screens/application/screen/applicationScreen.tsx | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index 88080d9e1..683c9591c 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -760,10 +760,10 @@ class ApplicationContainer extends Component { dispatch(hideActionModal()); dispatch(hideProfileModal()); dispatch(toastNotification('')); - dispatch(purgeExpiredCache()); dispatch(setRcOffer(false)); - //TODO: set pin code navigation to null, else move it to non persisted state + dispatch(purgeExpiredCache()); + if(settingsMigrated){ // this._initNotificationSettings(settings); @@ -801,6 +801,8 @@ class ApplicationContainer extends Component { dispatch(changeAllNotificationSettings(settings)); this._initNotificationSettings(settings); } + + //TODO: set migration to true } }; @@ -826,7 +828,7 @@ class ApplicationContainer extends Component { }); }; - + _connectNotificationServer = (username) => { /* eslint no-undef: "warn" */ diff --git a/src/screens/application/screen/applicationScreen.tsx b/src/screens/application/screen/applicationScreen.tsx index 98cbf2263..48280757a 100644 --- a/src/screens/application/screen/applicationScreen.tsx +++ b/src/screens/application/screen/applicationScreen.tsx @@ -45,6 +45,7 @@ class ApplicationScreen extends Component { const { rcOffer, dispatch, intl } = this.props; const { rcOffer: rcOfferPrev } = prevProps; + //TODO: display action modal instead if (!rcOfferPrev && rcOffer) { setTimeout(() => { Alert.alert( From bf8d3b8553d368ac6c7c016fbd4058059de2ab65 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 1 Jul 2022 20:35:46 +0500 Subject: [PATCH 25/43] setup settings migration without affecting notifications settings --- src/redux/actions/applicationActions.ts | 8 ++++++- src/redux/constants/constants.js | 1 + src/redux/reducers/applicationReducer.ts | 7 ++++++ .../container/applicationContainer.tsx | 22 ++++++++++++++----- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/redux/actions/applicationActions.ts b/src/redux/actions/applicationActions.ts index 92e61f0e8..086cf5765 100644 --- a/src/redux/actions/applicationActions.ts +++ b/src/redux/actions/applicationActions.ts @@ -28,7 +28,8 @@ import { IS_PIN_CODE_OPEN, IS_RENDER_REQUIRED, SET_LAST_APP_VERSION, - SET_COLOR_THEME + SET_COLOR_THEME, + SET_SETTINGS_MIGRATED } from '../constants/constants'; export const login = (payload) => ({ @@ -191,3 +192,8 @@ export const setLastAppVersion = (versionNumber:string) => ({ type: SET_LAST_APP_VERSION }) +export const setSettingsMigrated = (isMigrated:boolean) => ({ + payload:isMigrated, + type: SET_SETTINGS_MIGRATED +}) + diff --git a/src/redux/constants/constants.js b/src/redux/constants/constants.js index 87b4f2e15..61fe4500e 100644 --- a/src/redux/constants/constants.js +++ b/src/redux/constants/constants.js @@ -34,6 +34,7 @@ export const CHANGE_TRANSFERS_NOTIFICATION = 'CHANGE_TRANSFERS_NOTIFICATION'; export const CHANGE_ALL_NOTIFICATION_SETTINGS = 'CHANGE_ALL_NOTIFICATION_SETTINGS'; export const SET_LAST_APP_VERSION = 'SET_LAST_APP_VERSION'; export const SET_COLOR_THEME = 'SET_COLOR_THEME'; +export const SET_SETTINGS_MIGRATED = 'SET_SETTINGS_MIGRATED'; // Accounts export const ADD_OTHER_ACCOUNT = 'ADD_OTHER_ACCOUNT'; diff --git a/src/redux/reducers/applicationReducer.ts b/src/redux/reducers/applicationReducer.ts index 059a8d76d..bb7b41279 100644 --- a/src/redux/reducers/applicationReducer.ts +++ b/src/redux/reducers/applicationReducer.ts @@ -27,6 +27,7 @@ import { IS_RENDER_REQUIRED, SET_LAST_APP_VERSION, SET_COLOR_THEME, + SET_SETTINGS_MIGRATED, } from '../constants/constants'; interface State { @@ -258,6 +259,12 @@ export default function (state = initialState, action) { lastAppVersion:action.payload } + case SET_SETTINGS_MIGRATED: + return { + ...state, + settingsMigrated:action.payload + } + default: return state; } diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index 683c9591c..c9a5da614 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -81,6 +81,7 @@ import { isRenderRequired, logout, setColorTheme, + setSettingsMigrated, } from '../../../redux/actions/applicationActions'; import { hideActionModal, @@ -432,6 +433,7 @@ class ApplicationContainer extends Component { _fetchApp = async () => { + this._initNotificationSettings(); await this._getSettings(); this._refreshGlobalProps(); await this._getUserDataFromRealm(); @@ -751,7 +753,7 @@ class ApplicationContainer extends Component { - //TODO keep settings in redux and get rid of getSettings + //TODO rename to migrateSettings and move out of application container _getSettings = async () => { const { dispatch, settingsMigrated } = this.props; @@ -766,7 +768,6 @@ class ApplicationContainer extends Component { if(settingsMigrated){ - // this._initNotificationSettings(settings); return; } @@ -802,15 +803,22 @@ class ApplicationContainer extends Component { this._initNotificationSettings(settings); } - //TODO: set migration to true + dispatch(setSettingsMigrated(true)) } }; //update notification settings and update push token for each signed accoutn useing access tokens - _initNotificationSettings = (settings) => { - const { otherAccounts } = this.props; + _initNotificationSettings = (settings?:any) => { + const { otherAccounts, notificationDetails, isNotificationsEnabled } = this.props; + + if(!settings){ + settings = notificationDetails; + } + + const isEnabled = settings ? !!settings.notification : isNotificationsEnabled; + //updateing fcm token with settings; otherAccounts.forEach((account) => { @@ -824,7 +832,7 @@ class ApplicationContainer extends Component { accessToken = decryptKey(encAccessToken, Config.DEFAULT_PIN); } - this._enableNotification(account.name, settings.notification, settings, accessToken); + this._enableNotification(account.name, isEnabled, settings, accessToken); }); }; @@ -1055,6 +1063,8 @@ export default connect( isAnalytics: state.application.isAnalytics, lastUpdateCheck: state.application.lastUpdateCheck, settingsMigrated: state.application.settingsMigrated, + isNotificationsEnabled: state.application.isNotificationOpen, + notificationDetails: state.application.notificationDetails, // Account unreadActivityCount: state.account.currentAccount.unread_activity_count, From 40bc598f166da840e15d735d821c060dd408e33a Mon Sep 17 00:00:00 2001 From: noumantahir Date: Fri, 1 Jul 2022 20:51:18 +0500 Subject: [PATCH 26/43] repositions device notification registering --- .../application/container/applicationContainer.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index c9a5da614..e996c63bc 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -433,11 +433,11 @@ class ApplicationContainer extends Component { _fetchApp = async () => { - this._initNotificationSettings(); await this._getSettings(); this._refreshGlobalProps(); await this._getUserDataFromRealm(); this._compareAndPromptForUpdate(); + this._registerDeviceForNotifications(); }; _pushNavigate = (notification) => { @@ -800,24 +800,20 @@ class ApplicationContainer extends Component { ); dispatch(changeAllNotificationSettings(settings)); - this._initNotificationSettings(settings); } - dispatch(setSettingsMigrated(true)) + await dispatch(setSettingsMigrated(true)) } }; //update notification settings and update push token for each signed accoutn useing access tokens - _initNotificationSettings = (settings?:any) => { + _registerDeviceForNotifications = (settings?:any) => { const { otherAccounts, notificationDetails, isNotificationsEnabled } = this.props; - - if(!settings){ - settings = notificationDetails; - } - + const isEnabled = settings ? !!settings.notification : isNotificationsEnabled; + settings = settings || notificationDetails; //updateing fcm token with settings; From e2df0cc8fd7e897933de28032c2212d3f2ca29e9 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Sat, 2 Jul 2022 03:29:16 +0500 Subject: [PATCH 27/43] made ui store non-persist --- src/redux/store/store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/redux/store/store.ts b/src/redux/store/store.ts index f59286f13..433569028 100644 --- a/src/redux/store/store.ts +++ b/src/redux/store/store.ts @@ -37,7 +37,7 @@ const persistConfig = { // Storage Method (React Native) storage: AsyncStorage, // Blacklist (Don't Save Specific Reducers) - blacklist: ['nav', 'communities', 'user'], + blacklist: ['nav', 'communities', 'user', 'ui'], timeout: 0, transforms:[ transformCacheVoteMap, From 099d1a4f7fded9d01c17714504dcf5caa35c44b4 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Sat, 2 Jul 2022 03:30:08 +0500 Subject: [PATCH 28/43] moved hidePostsThumbnails to application store as it has to persist --- .../container/basicHeaderContainer.js | 6 +++--- .../header/container/headerContainer.js | 6 +++--- .../posts/container/postsContainer.js | 6 +++--- .../container/postsListContainer.tsx | 2 +- .../profile/children/commentsTabContent.tsx | 2 +- .../tabbedPosts/view/stackedTabBar.tsx | 6 +++--- src/containers/profileContainer.js | 2 +- src/redux/actions/applicationActions.ts | 9 +++++++- src/redux/actions/uiAction.ts | 6 ------ src/redux/reducers/applicationReducer.ts | 21 +++++++++++++------ src/redux/reducers/uiReducer.ts | 9 -------- 11 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/components/basicHeader/container/basicHeaderContainer.js b/src/components/basicHeader/container/basicHeaderContainer.js index 6823d3bec..58c860f3d 100644 --- a/src/components/basicHeader/container/basicHeaderContainer.js +++ b/src/components/basicHeader/container/basicHeaderContainer.js @@ -4,14 +4,14 @@ import { withNavigation } from 'react-navigation'; // Constants import { default as ROUTES } from '../../../constants/routeNames'; import { useAppDispatch, useAppSelector } from '../../../hooks'; -import { hidePostsThumbnails } from '../../../redux/actions/uiAction'; +import { setHidePostsThumbnails } from '../../../redux/actions/applicationActions'; // Components import BasicHeaderView from '../view/basicHeaderView'; const BasicHeaderContainer = (props) => { const dispatch = useAppDispatch(); - const isHideImages = useAppSelector((state) => state.ui.hidePostsThumbnails); + const isHideImages = useAppSelector((state) => state.application.hidePostsThumbnails); const _handleOnPressBackButton = () => { const { navigation, isNewPost, handleOnBackPress } = props; @@ -30,7 +30,7 @@ const BasicHeaderContainer = (props) => { }; const _handleViewModeToggle = () => { - dispatch(hidePostsThumbnails(!isHideImages)); + dispatch(setHidePostsThumbnails(!isHideImages)); }; return ( diff --git a/src/components/header/container/headerContainer.js b/src/components/header/container/headerContainer.js index a1825abf3..b725bc11a 100644 --- a/src/components/header/container/headerContainer.js +++ b/src/components/header/container/headerContainer.js @@ -8,8 +8,8 @@ import { useDispatch, useSelector } from 'react-redux'; import HeaderView from '../view/headerView'; import { AccountContainer, ThemeContainer } from '../../../containers'; -import { hidePostsThumbnails } from '../../../redux/actions/uiAction'; import { parseReputation } from '../../../utils/user'; +import { setHidePostsThumbnails } from '../../../redux/actions/applicationActions'; const HeaderContainer = ({ selectedUser, @@ -22,7 +22,7 @@ const HeaderContainer = ({ const dispatch = useDispatch(); //redux properties - const isHideImages = useSelector((state) => state.ui.hidePostsThumbnails); + const isHideImages = useSelector((state) => state.application.hidePostsThumbnails); const _handleOpenDrawer = () => { if (has(navigation, 'openDrawer') && typeof get(navigation, 'openDrawer') === 'function') { @@ -39,7 +39,7 @@ const HeaderContainer = ({ }; const _handleViewModeTogglePress = () => { - dispatch(hidePostsThumbnails(!isHideImages)); + dispatch(setHidePostsThumbnails(!isHideImages)); }; return ( diff --git a/src/components/posts/container/postsContainer.js b/src/components/posts/container/postsContainer.js index 90a07b603..2c87a9082 100644 --- a/src/components/posts/container/postsContainer.js +++ b/src/components/posts/container/postsContainer.js @@ -25,7 +25,6 @@ import { setOtherPosts, setInitPosts, } from '../../../redux/actions/postsAction'; -import { hidePostsThumbnails } from '../../../redux/actions/uiAction'; import { fetchLeaderboard, followUser, unfollowUser } from '../../../redux/actions/userAction'; import { subscribeCommunity, @@ -34,6 +33,7 @@ import { } from '../../../redux/actions/communitiesAction'; import useIsMountedRef from '../../../customHooks/useIsMountedRef'; +import { setHidePostsThumbnails } from '../../../redux/actions/applicationActions'; const PostsContainer = ({ changeForceLoadPostState, @@ -59,7 +59,7 @@ const PostsContainer = ({ const nsfw = useSelector((state) => state.application.nsfw); const initPosts = useSelector((state) => state.posts.initPosts); const isConnected = useSelector((state) => state.application.isConnected); - const isHideImages = useSelector((state) => state.ui.hidePostsThumbnails); + const isHideImages = useSelector((state) => state.application.hidePostsThumbnails); const username = useSelector((state) => state.account.currentAccount.name); const isLoggedIn = useSelector((state) => state.application.isLoggedIn); const isAnalytics = useSelector((state) => state.application.isAnalytics); @@ -467,7 +467,7 @@ const PostsContainer = ({ }; const _handleImagesHide = () => { - dispatch(hidePostsThumbnails(!isHideImages)); + dispatch(setHidePostsThumbnails(!isHideImages)); }; const _getPromotePosts = async () => { diff --git a/src/components/postsList/container/postsListContainer.tsx b/src/components/postsList/container/postsListContainer.tsx index bac83b254..fa1a7a14d 100644 --- a/src/components/postsList/container/postsListContainer.tsx +++ b/src/components/postsList/container/postsListContainer.tsx @@ -37,7 +37,7 @@ const postsListContainer = ({ const [imageHeights, setImageHeights] = useState(new Map()); - const isHideImages = useSelector((state) => state.ui.hidePostsThumbnails); + const isHideImages = useSelector((state) => state.application.hidePostsThumbnails); const posts = useSelector((state) => { return isFeedScreen ? state.posts.feedPosts diff --git a/src/components/profile/children/commentsTabContent.tsx b/src/components/profile/children/commentsTabContent.tsx index fa8d202d2..a47622e49 100644 --- a/src/components/profile/children/commentsTabContent.tsx +++ b/src/components/profile/children/commentsTabContent.tsx @@ -20,7 +20,7 @@ const CommentsTabContent = ({isOwnProfile, username, type, onScroll, selectedUse const intl = useIntl(); - const isHideImage = useAppSelector(state => state.ui.hidePostsThumbnails); + const isHideImage = useAppSelector(state => state.application.hidePostsThumbnails); const isAnalytics = useAppSelector(state => state.application.isAnalytics); const [data, setData] = useState([]); diff --git a/src/components/tabbedPosts/view/stackedTabBar.tsx b/src/components/tabbedPosts/view/stackedTabBar.tsx index dfd7098b6..eb924b568 100644 --- a/src/components/tabbedPosts/view/stackedTabBar.tsx +++ b/src/components/tabbedPosts/view/stackedTabBar.tsx @@ -2,7 +2,7 @@ import React, { useRef, useState } from "react"; import { useIntl } from "react-intl"; import { useDispatch, useSelector } from "react-redux"; import { CustomiseFiltersModal, FilterBar } from "../.."; -import { hidePostsThumbnails } from "../../../redux/actions/uiAction"; +import { setHidePostsThumbnails } from "../../../redux/actions/applicationActions"; import { CustomiseFiltersModalRef } from "../../customiseFiltersModal/customiseFiltersModal"; export interface TabItem { @@ -42,7 +42,7 @@ export const StackedTabBar = ({ const customiseModalRef = useRef(); //redux properties - const isHideImages = useSelector((state) => state.ui.hidePostsThumbnails); + const isHideImages = useSelector((state) => state.application.hidePostsThumbnails); const [selectedFilterIndex, setSelectedFilterIndex] = useState(initialFirstStackIndex); const [selectedSecondStackIndex, setSelectedSecondStackIndex] = useState(0); @@ -57,7 +57,7 @@ export const StackedTabBar = ({ } const _onToggleImagesPress = () => { - dispatch(hidePostsThumbnails(!isHideImages)) + dispatch(setHidePostsThumbnails(!isHideImages)) } return ( diff --git a/src/containers/profileContainer.js b/src/containers/profileContainer.js index dc6ef1451..78d444830 100644 --- a/src/containers/profileContainer.js +++ b/src/containers/profileContainer.js @@ -606,7 +606,7 @@ const mapStateToProps = (state) => ({ isAnalytics: state.application.isAnalytics, activeBottomTab: state.ui.activeBottomTab, currentAccount: state.account.currentAccount, - isHideImage: state.ui.hidePostsThumbnails, + isHideImage: state.application.hidePostsThumbnails, }); export default connect(mapStateToProps)(injectIntl(withNavigation(ProfileContainer))); diff --git a/src/redux/actions/applicationActions.ts b/src/redux/actions/applicationActions.ts index 086cf5765..a887c3c19 100644 --- a/src/redux/actions/applicationActions.ts +++ b/src/redux/actions/applicationActions.ts @@ -29,7 +29,8 @@ import { IS_RENDER_REQUIRED, SET_LAST_APP_VERSION, SET_COLOR_THEME, - SET_SETTINGS_MIGRATED + SET_SETTINGS_MIGRATED, + HIDE_POSTS_THUMBNAILS } from '../constants/constants'; export const login = (payload) => ({ @@ -197,3 +198,9 @@ export const setSettingsMigrated = (isMigrated:boolean) => ({ type: SET_SETTINGS_MIGRATED }) +export const setHidePostsThumbnails = (shouldHide:boolean) => ({ + payload:shouldHide, + type: HIDE_POSTS_THUMBNAILS, +}); + + diff --git a/src/redux/actions/uiAction.ts b/src/redux/actions/uiAction.ts index afb6f9aeb..5a26206b3 100644 --- a/src/redux/actions/uiAction.ts +++ b/src/redux/actions/uiAction.ts @@ -1,9 +1,7 @@ -import { AlertButton } from 'react-native'; import { TOAST_NOTIFICATION, UPDATE_ACTIVE_BOTTOM_TAB, - HIDE_POSTS_THUMBNAILS, RC_OFFER, TOGGLE_ACCOUNTS_BOTTOM_SHEET, SHOW_ACTION_MODAL, @@ -58,10 +56,6 @@ export const setRcOffer = (payload:boolean) => ({ type: RC_OFFER, }); -export const hidePostsThumbnails = (payload:boolean) => ({ - payload, - type: HIDE_POSTS_THUMBNAILS, -}); export const toggleAccountsBottomSheet = (payload:boolean) => ({ payload, diff --git a/src/redux/reducers/applicationReducer.ts b/src/redux/reducers/applicationReducer.ts index bb7b41279..2a96dd5ae 100644 --- a/src/redux/reducers/applicationReducer.ts +++ b/src/redux/reducers/applicationReducer.ts @@ -28,6 +28,7 @@ import { SET_LAST_APP_VERSION, SET_COLOR_THEME, SET_SETTINGS_MIGRATED, + HIDE_POSTS_THUMBNAILS, } from '../constants/constants'; interface State { @@ -58,13 +59,14 @@ interface State { transfersNotification: boolean, voteNotification: boolean, }, - upvotePercent: number, - nsfw: string, - pin: string|null, - isPinCodeOpen: boolean, - isRenderRequired: boolean, + upvotePercent: number; + nsfw: string; + pin: string|null; + isPinCodeOpen: boolean; + isRenderRequired: boolean; lastAppVersion:string; - settingsMigrated: boolean, + settingsMigrated: boolean; + hidePostsThumbnails: boolean; } const initialState:State = { @@ -102,6 +104,7 @@ const initialState:State = { isRenderRequired: false, lastAppVersion:'', settingsMigrated: false, + hidePostsThumbnails: false, }; export default function (state = initialState, action) { @@ -265,6 +268,12 @@ export default function (state = initialState, action) { settingsMigrated:action.payload } + case HIDE_POSTS_THUMBNAILS: + return { + ...state, + hidePostsThumbnails:action.payload + } + default: return state; } diff --git a/src/redux/reducers/uiReducer.ts b/src/redux/reducers/uiReducer.ts index c2fe66a62..d5738f2a4 100644 --- a/src/redux/reducers/uiReducer.ts +++ b/src/redux/reducers/uiReducer.ts @@ -1,7 +1,6 @@ import { UPDATE_ACTIVE_BOTTOM_TAB, TOAST_NOTIFICATION, - HIDE_POSTS_THUMBNAILS, RC_OFFER, TOGGLE_ACCOUNTS_BOTTOM_SHEET, SHOW_ACTION_MODAL, @@ -17,7 +16,6 @@ import { orientations } from '../constants/orientationsConstants'; interface UiState { activeBottomTab:string; toastNotification:string; - hidePostsThumbnails:boolean; rcOffer:boolean; isVisibleAccountsBottomSheet:boolean; actionModalVisible:boolean; @@ -31,7 +29,6 @@ interface UiState { const initialState:UiState = { activeBottomTab: 'HomeTabbar', toastNotification: '', - hidePostsThumbnails: false, rcOffer: false, isVisibleAccountsBottomSheet: false, actionModalVisible: false, @@ -92,12 +89,6 @@ export default function (state = initialState, action) { rcOffer: action.payload, }; - case HIDE_POSTS_THUMBNAILS: - return { - ...state, - hidePostsThumbnails: action.payload, - }; - case TOGGLE_ACCOUNTS_BOTTOM_SHEET: return { ...state, From 7ccb36bafafba6e94644dc7c70cd3c5721e0e2c2 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Sat, 2 Jul 2022 03:34:04 +0500 Subject: [PATCH 29/43] rearranged setting reset events --- .../application/container/applicationContainer.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index e996c63bc..0ca3ff7d6 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -25,7 +25,6 @@ import THEME_OPTIONS from '../../../constants/options/theme'; // Services import { getAuthStatus, - getExistUser, getSettings, getUserData, removeUserData, @@ -438,6 +437,7 @@ class ApplicationContainer extends Component { await this._getUserDataFromRealm(); this._compareAndPromptForUpdate(); this._registerDeviceForNotifications(); + this.props.dispatch(purgeExpiredCache()); }; _pushNavigate = (notification) => { @@ -757,20 +757,16 @@ class ApplicationContainer extends Component { _getSettings = async () => { const { dispatch, settingsMigrated } = this.props; - //TOOD: no need for resetting modal here afer adding them to non persist store. + if(settingsMigrated){ + return; + } + //reset certain properties dispatch(hideActionModal()); dispatch(hideProfileModal()); dispatch(toastNotification('')); dispatch(setRcOffer(false)); - dispatch(purgeExpiredCache()); - - - if(settingsMigrated){ - return; - } - const settings = await getSettings(); From f19320f90dc4c57aeddb2cda23804a243bc13759 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Mon, 4 Jul 2022 21:48:22 +0500 Subject: [PATCH 30/43] refractor screen -> app-startup --- .../{screen => children}/applicationScreen.tsx | 0 .../application/{screen => children}/errorBoundary.js | 0 .../application/{screen => children}/pinCodeModal.tsx | 0 .../application/{screen => children}/welcomeModal.tsx | 0 .../application/{screen => children}/welcomeStyles.js | 0 src/screens/application/index.tsx | 10 +++++----- 6 files changed, 5 insertions(+), 5 deletions(-) rename src/screens/application/{screen => children}/applicationScreen.tsx (100%) rename src/screens/application/{screen => children}/errorBoundary.js (100%) rename src/screens/application/{screen => children}/pinCodeModal.tsx (100%) rename src/screens/application/{screen => children}/welcomeModal.tsx (100%) rename src/screens/application/{screen => children}/welcomeStyles.js (100%) diff --git a/src/screens/application/screen/applicationScreen.tsx b/src/screens/application/children/applicationScreen.tsx similarity index 100% rename from src/screens/application/screen/applicationScreen.tsx rename to src/screens/application/children/applicationScreen.tsx diff --git a/src/screens/application/screen/errorBoundary.js b/src/screens/application/children/errorBoundary.js similarity index 100% rename from src/screens/application/screen/errorBoundary.js rename to src/screens/application/children/errorBoundary.js diff --git a/src/screens/application/screen/pinCodeModal.tsx b/src/screens/application/children/pinCodeModal.tsx similarity index 100% rename from src/screens/application/screen/pinCodeModal.tsx rename to src/screens/application/children/pinCodeModal.tsx diff --git a/src/screens/application/screen/welcomeModal.tsx b/src/screens/application/children/welcomeModal.tsx similarity index 100% rename from src/screens/application/screen/welcomeModal.tsx rename to src/screens/application/children/welcomeModal.tsx diff --git a/src/screens/application/screen/welcomeStyles.js b/src/screens/application/children/welcomeStyles.js similarity index 100% rename from src/screens/application/screen/welcomeStyles.js rename to src/screens/application/children/welcomeStyles.js diff --git a/src/screens/application/index.tsx b/src/screens/application/index.tsx index 57ffc459d..47fe7eba8 100644 --- a/src/screens/application/index.tsx +++ b/src/screens/application/index.tsx @@ -1,13 +1,13 @@ -import React, { useEffect, useState } from 'react'; +import React, { useState } from 'react'; import { OrientationLocker, PORTRAIT } from 'react-native-orientation-locker'; import { useDispatch } from 'react-redux'; import ApplicationContainer from './container/applicationContainer'; -import WelcomeModal from './screen/welcomeModal'; -import ApplicationScreen from './screen/applicationScreen'; -import ErrorBoundary from './screen/errorBoundary'; +import WelcomeModal from './children/welcomeModal'; +import ApplicationScreen from './children/applicationScreen'; +import ErrorBoundary from './children/errorBoundary'; import { setDeviceOrientation } from '../../redux/actions/uiAction'; -import PinCodeModal from './screen/pinCodeModal'; +import PinCodeModal from './children/pinCodeModal'; const Application = () => { const dispatch = useDispatch(); From f00bbff0d3922e9acf29fcb3ab93081251c955d2 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Mon, 4 Jul 2022 21:57:59 +0500 Subject: [PATCH 31/43] removed getSettings method from applicationContainer in favour of MigrationHelpers --- .../application/children/migrationHelpers.ts | 83 +++++++++++++++++++ .../container/applicationContainer.tsx | 58 ++----------- 2 files changed, 88 insertions(+), 53 deletions(-) create mode 100644 src/screens/application/children/migrationHelpers.ts diff --git a/src/screens/application/children/migrationHelpers.ts b/src/screens/application/children/migrationHelpers.ts new file mode 100644 index 000000000..4fa87aebb --- /dev/null +++ b/src/screens/application/children/migrationHelpers.ts @@ -0,0 +1,83 @@ +import { Appearance } from 'react-native'; + +// Constants +import THEME_OPTIONS from '../../../constants/options/theme'; + +// Services +import { + getSettings, +} from '../../../realm/realm'; + +import { + isDarkTheme, + changeNotificationSettings, + changeAllNotificationSettings, + setApi, + setCurrency, + setLanguage, + setUpvotePercent, + setNsfw, + isDefaultFooter, + isPinCodeOpen, + setColorTheme, + setSettingsMigrated, +} from '../../../redux/actions/applicationActions'; +import { + hideActionModal, + hideProfileModal, + setRcOffer, + toastNotification, +} from '../../../redux/actions/uiAction'; + + +//migrates settings from realm to redux once and do no user realm for settings again; +export const migrateSettings = async (dispatch: any, settingsMigrated: boolean) => { + + if (settingsMigrated) { + return; + } + + //reset certain properties + dispatch(hideActionModal()); + dispatch(hideProfileModal()); + dispatch(toastNotification('')); + dispatch(setRcOffer(false)); + + + const settings = await getSettings(); + + if (settings) { + const isDarkMode = Appearance.getColorScheme() === 'dark'; + dispatch(isDarkTheme(settings.isDarkTheme !== null ? settings.isDarkTheme : isDarkMode)); + dispatch(setColorTheme(THEME_OPTIONS.findIndex(item => item.value === settings.isDarkTheme))); + if (settings.isPinCodeOpen !== '') await dispatch(isPinCodeOpen(settings.isPinCodeOpen)); + if (settings.language !== '') dispatch(setLanguage(settings.language)); + if (settings.server !== '') dispatch(setApi(settings.server)); + if (settings.upvotePercent !== '') { + dispatch(setUpvotePercent(Number(settings.upvotePercent))); + } + if (settings.isDefaultFooter !== '') dispatch(isDefaultFooter(settings.isDefaultFooter)); //TODO: remove as not being used + + + if (settings.nsfw !== '') dispatch(setNsfw(settings.nsfw)); + + dispatch(setCurrency(settings.currency !== '' ? settings.currency : 'usd')); + + if (settings.notification !== '') { + dispatch( + changeNotificationSettings({ + type: 'notification', + action: settings.notification, + }), + ); + + dispatch(changeAllNotificationSettings(settings)); + } + + await dispatch(setSettingsMigrated(true)) + } +} + +export default { + migrateSettings +} \ No newline at end of file diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index 0ca3ff7d6..ebb64cb9b 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -104,6 +104,7 @@ import { setMomentLocale } from '../../../utils/time'; import parseAuthUrl from '../../../utils/parseAuthUrl'; import { purgeExpiredCache } from '../../../redux/actions/cacheActions'; import { fetchSubscribedCommunities } from '../../../redux/actions/communitiesAction'; +import MigrationHelpers from '../children/migrationHelpers'; // Workaround let previousAppState = 'background'; @@ -432,12 +433,14 @@ class ApplicationContainer extends Component { _fetchApp = async () => { - await this._getSettings(); + const {dispatch, settingsMigrated} = this.props; + + await MigrationHelpers.migrateSettings(dispatch, settingsMigrated) this._refreshGlobalProps(); await this._getUserDataFromRealm(); this._compareAndPromptForUpdate(); this._registerDeviceForNotifications(); - this.props.dispatch(purgeExpiredCache()); + dispatch(purgeExpiredCache()); }; _pushNavigate = (notification) => { @@ -753,57 +756,6 @@ class ApplicationContainer extends Component { - //TODO rename to migrateSettings and move out of application container - _getSettings = async () => { - const { dispatch, settingsMigrated } = this.props; - - if(settingsMigrated){ - return; - } - - //reset certain properties - dispatch(hideActionModal()); - dispatch(hideProfileModal()); - dispatch(toastNotification('')); - dispatch(setRcOffer(false)); - - - const settings = await getSettings(); - - if (settings) { - const isDarkMode = Appearance.getColorScheme() === 'dark'; - dispatch(isDarkTheme(settings.isDarkTheme !== null ? settings.isDarkTheme : isDarkMode)); - dispatch(setColorTheme(THEME_OPTIONS.findIndex(item=>item.value===settings.isDarkTheme))); - if (settings.isPinCodeOpen !== '') await dispatch(isPinCodeOpen(settings.isPinCodeOpen)); - if (settings.language !== '') dispatch(setLanguage(settings.language)); - if (settings.server !== '') dispatch(setApi(settings.server)); - if (settings.upvotePercent !== '') { - dispatch(setUpvotePercent(Number(settings.upvotePercent))); - } - if (settings.isDefaultFooter !== '') dispatch(isDefaultFooter(settings.isDefaultFooter)); //TODO: remove as not being used - - - if (settings.nsfw !== '') dispatch(setNsfw(settings.nsfw)); - - dispatch(setCurrency(settings.currency !== '' ? settings.currency : 'usd')); - - if (settings.notification !== '') { - dispatch( - changeNotificationSettings({ - type: 'notification', - action: settings.notification, - }), - ); - - dispatch(changeAllNotificationSettings(settings)); - } - - await dispatch(setSettingsMigrated(true)) - } - }; - - - //update notification settings and update push token for each signed accoutn useing access tokens _registerDeviceForNotifications = (settings?:any) => { const { otherAccounts, notificationDetails, isNotificationsEnabled } = this.props; From f11659dccf45e4dc09e4b7a674f583a17c203b93 Mon Sep 17 00:00:00 2001 From: Sadaqat Ali Date: Tue, 5 Jul 2022 15:27:17 +0500 Subject: [PATCH 32/43] added checkbox in welcome page --- src/config/locales/en-US.json | 4 +- .../application/screen/welcomeScreen.js | 38 ++++++++++++++++--- .../application/screen/welcomeStyles.js | 23 +++++++++++ 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index 83e24ac23..ca92329bd 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -783,7 +783,9 @@ "line2_body":"Utilizing blockchain, censorship-free, decentralized and rewarding.", "line3_heading":"Join Ecency communities!", "line3_body":"Build community you own, get rewarded and reward others.", - "get_started":"Get started!" + "get_started":"Get started!", + "terms_description": "By using app, you agree to our ", + "terms_text": " Terms" }, "time":{ "second":"seconds", diff --git a/src/screens/application/screen/welcomeScreen.js b/src/screens/application/screen/welcomeScreen.js index 6d44ef96b..52a163feb 100644 --- a/src/screens/application/screen/welcomeScreen.js +++ b/src/screens/application/screen/welcomeScreen.js @@ -1,15 +1,20 @@ -import React from 'react'; +import React, { useState } from 'react'; import { useIntl } from 'react-intl'; -import { Text, Image, View, SafeAreaView, TouchableOpacity } from 'react-native'; +import { Text, Image, View, SafeAreaView, TouchableOpacity, Linking } from 'react-native'; import EStyleSheet from 'react-native-extended-stylesheet'; -import { Icon, MainButton } from '../../../components'; +import { CheckBox, Icon, MainButton } from '../../../components'; import styles from './welcomeStyles'; const WelcomeScreen = ({ handleButtonPress }) => { const intl = useIntl(); + const [isConsentChecked, setIsConsentChecked] = useState(false); + + const _onCheckPress = (value, isCheck) => { + setIsConsentChecked(isCheck); + }; const _renderInfo = (iconName, headingIntlId, bodyIntlId) => ( @@ -26,9 +31,29 @@ const WelcomeScreen = ({ handleButtonPress }) => { ); + const _renderConsent = () => ( + + + + + {intl.formatMessage({ + id: 'welcome.terms_description', + })} + + Linking.openURL('https://ecency.com/terms-of-service')}> + + {intl.formatMessage({ + id: 'welcome.terms_text', + })} + + + + + ); + return ( - + { {_renderInfo('question', 'welcome.line1_heading', 'welcome.line1_body')} {_renderInfo('emotsmile', 'welcome.line2_heading', 'welcome.line2_body')} {_renderInfo('people', 'welcome.line3_heading', 'welcome.line3_body')} + {_renderConsent()} - + ); }; diff --git a/src/screens/application/screen/welcomeStyles.js b/src/screens/application/screen/welcomeStyles.js index 2f3b125f1..b8ab616d0 100644 --- a/src/screens/application/screen/welcomeStyles.js +++ b/src/screens/application/screen/welcomeStyles.js @@ -69,4 +69,27 @@ export default EStyleSheet.create({ flex1: { flex: 1, }, + consentContainer: { + flexDirection: 'row', + marginTop: 52, + alignItems: 'center', + }, + checkStyle: { + backgroundColor: '$white', + marginRight: 12, + }, + consentTextContainer: { + flexDirection: 'row', + flex: 1, + flexWrap: 'wrap', + }, + termsDescText: { + fontSize: 14, + color: '$primaryBlack', + }, + termsLinkText: { + fontSize: 14, + fontWeight: '700', + color: '$primaryBlue', + }, }); From bdd8d222e591bf65304c60eb50dce1c20a54ed69 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 5 Jul 2022 19:25:45 +0500 Subject: [PATCH 33/43] updated terms message --- src/config/locales/en-US.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index ca92329bd..d3c5e24fb 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -784,8 +784,8 @@ "line3_heading":"Join Ecency communities!", "line3_body":"Build community you own, get rewarded and reward others.", "get_started":"Get started!", - "terms_description": "By using app, you agree to our ", - "terms_text": " Terms" + "terms_description": "By accepting, you agree to our Terms of Service and Privacy Policies.", + "terms_text": " Read Here!" }, "time":{ "second":"seconds", From 42e55a4a98996b87757fa72bb42c0dcc4500b8ca Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 5 Jul 2022 19:26:25 +0500 Subject: [PATCH 34/43] rearranged reader consent component --- .../application/screen/welcomeScreen.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/screens/application/screen/welcomeScreen.js b/src/screens/application/screen/welcomeScreen.js index 52a163feb..1d50c25d2 100644 --- a/src/screens/application/screen/welcomeScreen.js +++ b/src/screens/application/screen/welcomeScreen.js @@ -34,20 +34,20 @@ const WelcomeScreen = ({ handleButtonPress }) => { const _renderConsent = () => ( - - - {intl.formatMessage({ - id: 'welcome.terms_description', - })} - - Linking.openURL('https://ecency.com/terms-of-service')}> - + Linking.openURL('https://ecency.com/terms-of-service')}> + + {intl.formatMessage({ - id: 'welcome.terms_text', + id: 'welcome.terms_description', })} + + {intl.formatMessage({ + id: 'welcome.terms_text', + })} + - - + + ); From a5625e3addb5d93be6b7268249ab93129e314d77 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 5 Jul 2022 20:22:28 +0500 Subject: [PATCH 35/43] updated welcome modal with consent changes --- .../application/children/welcomeModal.tsx | 35 +++++++- .../application/screen/welcomeScreen.js | 86 ------------------- 2 files changed, 32 insertions(+), 89 deletions(-) delete mode 100644 src/screens/application/screen/welcomeScreen.js diff --git a/src/screens/application/children/welcomeModal.tsx b/src/screens/application/children/welcomeModal.tsx index de4dcc134..53afec07f 100644 --- a/src/screens/application/children/welcomeModal.tsx +++ b/src/screens/application/children/welcomeModal.tsx @@ -1,11 +1,11 @@ import React, { useState, useEffect } from 'react'; import { useIntl } from 'react-intl'; -import { Text, Image, View, SafeAreaView, TouchableOpacity } from 'react-native'; +import { Text, Image, View, SafeAreaView, TouchableOpacity, Linking } from 'react-native'; import EStyleSheet from 'react-native-extended-stylesheet'; import VersionNumber from 'react-native-version-number'; -import { Icon, MainButton, Modal } from '../../../components'; +import { CheckBox, Icon, MainButton, Modal } from '../../../components'; import { useAppDispatch, useAppSelector } from '../../../hooks'; import { setLastAppVersion } from '../../../redux/actions/applicationActions'; import parseVersionNumber from '../../../utils/parseVersionNumber'; @@ -21,11 +21,15 @@ const WelcomeModal = ({ onModalVisibilityChange }) => { const [showAnimation, setShowAnimation] = useState(true); const [showWelcomeModal, setShowWelcomeModal] = useState(false); + const [isConsentChecked, setIsConsentChecked] = useState(false); + const [appVersion] = useState(VersionNumber.appVersion); useEffect(() => { _compareAppVersion() + _showWelcomeModal(); + }, []) @@ -51,6 +55,10 @@ const WelcomeModal = ({ onModalVisibilityChange }) => { onModalVisibilityChange(false); } + const _onCheckPress = (value, isCheck) => { + setIsConsentChecked(isCheck); + }; + const _renderInfo = (iconName, headingIntlId, bodyIntlId) => ( @@ -67,6 +75,26 @@ const WelcomeModal = ({ onModalVisibilityChange }) => { ); + const _renderConsent = () => ( + + + Linking.openURL('https://ecency.com/terms-of-service')}> + + + {intl.formatMessage({ + id: 'welcome.terms_description', + })} + + {intl.formatMessage({ + id: 'welcome.terms_text', + })} + + + + + + ); + const _renderContent = () => ( @@ -83,11 +111,12 @@ const WelcomeModal = ({ onModalVisibilityChange }) => { {_renderInfo('question', 'welcome.line1_heading', 'welcome.line1_body')} {_renderInfo('emotsmile', 'welcome.line2_heading', 'welcome.line2_body')} {_renderInfo('people', 'welcome.line3_heading', 'welcome.line3_body')} + {_renderConsent()} { - const intl = useIntl(); - const [isConsentChecked, setIsConsentChecked] = useState(false); - - const _onCheckPress = (value, isCheck) => { - setIsConsentChecked(isCheck); - }; - - const _renderInfo = (iconName, headingIntlId, bodyIntlId) => ( - - - - {intl.formatMessage({ id: headingIntlId })} - {intl.formatMessage({ id: bodyIntlId })} - - - ); - - const _renderConsent = () => ( - - - Linking.openURL('https://ecency.com/terms-of-service')}> - - - {intl.formatMessage({ - id: 'welcome.terms_description', - })} - - {intl.formatMessage({ - id: 'welcome.terms_text', - })} - - - - - - ); - - return ( - - - - - {intl.formatMessage({ id: 'welcome.label' })} - {intl.formatMessage({ id: 'welcome.title' })} - - - {_renderInfo('question', 'welcome.line1_heading', 'welcome.line1_body')} - {_renderInfo('emotsmile', 'welcome.line2_heading', 'welcome.line2_body')} - {_renderInfo('people', 'welcome.line3_heading', 'welcome.line3_body')} - {_renderConsent()} - - - - - - - ); -}; - -export default WelcomeScreen; From e0b41459a01408819b97f34b9f210e0c7a7c2ef2 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 5 Jul 2022 20:25:28 +0500 Subject: [PATCH 36/43] fixed disable bug --- src/screens/application/children/welcomeModal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/screens/application/children/welcomeModal.tsx b/src/screens/application/children/welcomeModal.tsx index 53afec07f..8202da1b9 100644 --- a/src/screens/application/children/welcomeModal.tsx +++ b/src/screens/application/children/welcomeModal.tsx @@ -78,7 +78,7 @@ const WelcomeModal = ({ onModalVisibilityChange }) => { const _renderConsent = () => ( - Linking.openURL('https://ecency.com/terms-of-service')}> + Linking.openURL('https://ecency.com/terms-of-service')}> {intl.formatMessage({ @@ -97,7 +97,7 @@ const WelcomeModal = ({ onModalVisibilityChange }) => { const _renderContent = () => ( - + Date: Tue, 5 Jul 2022 20:50:56 +0500 Subject: [PATCH 37/43] improved welcome modal ui in favour of small screen devices --- .../application/children/welcomeModal.tsx | 28 +++++++++++++------ .../application/children/welcomeStyles.js | 14 ++++++++-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/screens/application/children/welcomeModal.tsx b/src/screens/application/children/welcomeModal.tsx index 8202da1b9..089f7f94b 100644 --- a/src/screens/application/children/welcomeModal.tsx +++ b/src/screens/application/children/welcomeModal.tsx @@ -3,6 +3,7 @@ import { useIntl } from 'react-intl'; import { Text, Image, View, SafeAreaView, TouchableOpacity, Linking } from 'react-native'; import EStyleSheet from 'react-native-extended-stylesheet'; +import { ScrollView } from 'react-native-gesture-handler'; import VersionNumber from 'react-native-version-number'; import { CheckBox, Icon, MainButton, Modal } from '../../../components'; @@ -97,23 +98,32 @@ const WelcomeModal = ({ onModalVisibilityChange }) => { const _renderContent = () => ( - + + + {intl.formatMessage({ id: 'welcome.label' })} {intl.formatMessage({ id: 'welcome.title' })} - - {_renderInfo('question', 'welcome.line1_heading', 'welcome.line1_body')} - {_renderInfo('emotsmile', 'welcome.line2_heading', 'welcome.line2_body')} - {_renderInfo('people', 'welcome.line3_heading', 'welcome.line3_body')} + + + + + {_renderInfo('question', 'welcome.line1_heading', 'welcome.line1_body')} + {_renderInfo('emotsmile', 'welcome.line2_heading', 'welcome.line2_body')} + {_renderInfo('people', 'welcome.line3_heading', 'welcome.line3_body')} + + + + + + {_renderConsent()} - - { text={intl.formatMessage({ id: 'welcome.get_started' })} /> - + + + {showAnimation && } ); diff --git a/src/screens/application/children/welcomeStyles.js b/src/screens/application/children/welcomeStyles.js index b8ab616d0..e628108a1 100644 --- a/src/screens/application/children/welcomeStyles.js +++ b/src/screens/application/children/welcomeStyles.js @@ -20,6 +20,11 @@ export default EStyleSheet.create({ paddingBottom: 20, paddingHorizontal: 40, }, + + contentContainer: { + flexGrow: 1, + justifyContent: 'center', + }, welcomeText: { fontSize: scalePx(34), color: '$primaryBlack', @@ -47,8 +52,10 @@ export default EStyleSheet.create({ topText: { marginTop: 40, }, - bottomButton: { - paddingTop: 10, + bottomContainer: { + marginTop: 8, + borderTopWidth: EStyleSheet.hairlineWidth, + borderColor: '$iconColor', }, sectionRow: { flexDirection: 'row', @@ -71,8 +78,9 @@ export default EStyleSheet.create({ }, consentContainer: { flexDirection: 'row', - marginTop: 52, alignItems: 'center', + marginTop: 32, + marginBottom: 40, }, checkStyle: { backgroundColor: '$white', From 35f1f8456756f12d269f1011f9898b4da7baba3b Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 5 Jul 2022 21:04:09 +0500 Subject: [PATCH 38/43] integrated terms acceptance with redux --- src/redux/actions/applicationActions.ts | 8 +++++++- src/redux/constants/constants.js | 1 + src/redux/reducers/applicationReducer.ts | 9 +++++++++ src/screens/application/children/welcomeModal.tsx | 8 +++++--- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/redux/actions/applicationActions.ts b/src/redux/actions/applicationActions.ts index a887c3c19..65effa481 100644 --- a/src/redux/actions/applicationActions.ts +++ b/src/redux/actions/applicationActions.ts @@ -30,7 +30,8 @@ import { SET_LAST_APP_VERSION, SET_COLOR_THEME, SET_SETTINGS_MIGRATED, - HIDE_POSTS_THUMBNAILS + HIDE_POSTS_THUMBNAILS, + SET_TERMS_ACCEPTED } from '../constants/constants'; export const login = (payload) => ({ @@ -203,4 +204,9 @@ export const setHidePostsThumbnails = (shouldHide:boolean) => ({ type: HIDE_POSTS_THUMBNAILS, }); +export const setIsTermsAccepted = (isTermsAccepted:boolean) => ({ + payload:isTermsAccepted, + type: SET_TERMS_ACCEPTED +}) + diff --git a/src/redux/constants/constants.js b/src/redux/constants/constants.js index 61fe4500e..f54f0d7d4 100644 --- a/src/redux/constants/constants.js +++ b/src/redux/constants/constants.js @@ -35,6 +35,7 @@ export const CHANGE_ALL_NOTIFICATION_SETTINGS = 'CHANGE_ALL_NOTIFICATION_SETTING export const SET_LAST_APP_VERSION = 'SET_LAST_APP_VERSION'; export const SET_COLOR_THEME = 'SET_COLOR_THEME'; export const SET_SETTINGS_MIGRATED = 'SET_SETTINGS_MIGRATED'; +export const SET_TERMS_ACCEPTED = 'SET_TERMS_ACCEPTED'; // Accounts export const ADD_OTHER_ACCOUNT = 'ADD_OTHER_ACCOUNT'; diff --git a/src/redux/reducers/applicationReducer.ts b/src/redux/reducers/applicationReducer.ts index 2a96dd5ae..6d02dfe8d 100644 --- a/src/redux/reducers/applicationReducer.ts +++ b/src/redux/reducers/applicationReducer.ts @@ -29,6 +29,7 @@ import { SET_COLOR_THEME, SET_SETTINGS_MIGRATED, HIDE_POSTS_THUMBNAILS, + SET_TERMS_ACCEPTED, } from '../constants/constants'; interface State { @@ -67,6 +68,7 @@ interface State { lastAppVersion:string; settingsMigrated: boolean; hidePostsThumbnails: boolean; + isTermsAccepted: boolean; } const initialState:State = { @@ -105,6 +107,7 @@ const initialState:State = { lastAppVersion:'', settingsMigrated: false, hidePostsThumbnails: false, + isTermsAccepted: false, }; export default function (state = initialState, action) { @@ -273,6 +276,12 @@ export default function (state = initialState, action) { ...state, hidePostsThumbnails:action.payload } + + case SET_TERMS_ACCEPTED: + return { + ...state, + isTermsAccepted:action.payload + } default: return state; diff --git a/src/screens/application/children/welcomeModal.tsx b/src/screens/application/children/welcomeModal.tsx index 089f7f94b..2bb62d5eb 100644 --- a/src/screens/application/children/welcomeModal.tsx +++ b/src/screens/application/children/welcomeModal.tsx @@ -8,7 +8,7 @@ import VersionNumber from 'react-native-version-number'; import { CheckBox, Icon, MainButton, Modal } from '../../../components'; import { useAppDispatch, useAppSelector } from '../../../hooks'; -import { setLastAppVersion } from '../../../redux/actions/applicationActions'; +import { setLastAppVersion, setIsTermsAccepted } from '../../../redux/actions/applicationActions'; import parseVersionNumber from '../../../utils/parseVersionNumber'; import LaunchScreen from '../../launch'; @@ -19,10 +19,11 @@ const WelcomeModal = ({ onModalVisibilityChange }) => { const dispatch = useAppDispatch(); const lastAppVersion = useAppSelector(state => state.application.lastAppVersion) + const isTermsAccepted = useAppSelector(state => state.application.isTermsAccepted); const [showAnimation, setShowAnimation] = useState(true); const [showWelcomeModal, setShowWelcomeModal] = useState(false); - const [isConsentChecked, setIsConsentChecked] = useState(false); + const [isConsentChecked, setIsConsentChecked] = useState(isTermsAccepted); const [appVersion] = useState(VersionNumber.appVersion); @@ -52,6 +53,7 @@ const WelcomeModal = ({ onModalVisibilityChange }) => { const _handleButtonPress = () => { dispatch(setLastAppVersion(appVersion)) + dispatch(setIsTermsAccepted(isConsentChecked)); setShowWelcomeModal(false); onModalVisibilityChange(false); } @@ -78,7 +80,7 @@ const WelcomeModal = ({ onModalVisibilityChange }) => { const _renderConsent = () => ( - + Linking.openURL('https://ecency.com/terms-of-service')}> From 5f2992f0812bff099efb465cb6ed34029b3f23a8 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 5 Jul 2022 21:19:32 +0500 Subject: [PATCH 39/43] removed test code --- src/screens/application/children/welcomeModal.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/screens/application/children/welcomeModal.tsx b/src/screens/application/children/welcomeModal.tsx index 2bb62d5eb..e71d2102b 100644 --- a/src/screens/application/children/welcomeModal.tsx +++ b/src/screens/application/children/welcomeModal.tsx @@ -30,8 +30,6 @@ const WelcomeModal = ({ onModalVisibilityChange }) => { useEffect(() => { _compareAppVersion() - _showWelcomeModal(); - }, []) From ef7c3cbc34157aaf642faa9245ceefc4317028e5 Mon Sep 17 00:00:00 2001 From: feruz Date: Tue, 5 Jul 2022 21:24:20 +0300 Subject: [PATCH 40/43] remove space --- src/config/locales/en-US.json | 2 +- src/screens/application/children/welcomeModal.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index d3c5e24fb..2c5b2f8c3 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -785,7 +785,7 @@ "line3_body":"Build community you own, get rewarded and reward others.", "get_started":"Get started!", "terms_description": "By accepting, you agree to our Terms of Service and Privacy Policies.", - "terms_text": " Read Here!" + "terms_text": "Read Here!" }, "time":{ "second":"seconds", diff --git a/src/screens/application/children/welcomeModal.tsx b/src/screens/application/children/welcomeModal.tsx index e71d2102b..d49bc7b9a 100644 --- a/src/screens/application/children/welcomeModal.tsx +++ b/src/screens/application/children/welcomeModal.tsx @@ -86,6 +86,7 @@ const WelcomeModal = ({ onModalVisibilityChange }) => { id: 'welcome.terms_description', })} + {' '} {intl.formatMessage({ id: 'welcome.terms_text', })} From f7e139df0b0885fc0cc0c33fe2e842937cb06de1 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Wed, 6 Jul 2022 17:44:51 +0500 Subject: [PATCH 41/43] revert launchscreen xib --- ios/Ecency/Base.lproj/LaunchScreen.xib | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/ios/Ecency/Base.lproj/LaunchScreen.xib b/ios/Ecency/Base.lproj/LaunchScreen.xib index 5da3ecb75..9296b97a7 100644 --- a/ios/Ecency/Base.lproj/LaunchScreen.xib +++ b/ios/Ecency/Base.lproj/LaunchScreen.xib @@ -1,33 +1,29 @@ - - + - + - - - - - - + + + + - - + From b3bee92599578a1125c0daceba90aab300aa6fba Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Wed, 6 Jul 2022 17:49:18 +0500 Subject: [PATCH 42/43] put back splash screen package --- ios/Ecency/AppDelegate.m | 3 +++ ios/Podfile.lock | 8 +++++++- package.json | 1 + .../application/container/applicationContainer.tsx | 3 ++- yarn.lock | 5 +++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ios/Ecency/AppDelegate.m b/ios/Ecency/AppDelegate.m index 109178faf..33770fada 100644 --- a/ios/Ecency/AppDelegate.m +++ b/ios/Ecency/AppDelegate.m @@ -1,4 +1,6 @@ #import "AppDelegate.h" +#import "RNSplashScreen.h" + #import #import #import @@ -51,6 +53,7 @@ rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; + [RNSplashScreen show]; return YES; } diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 6d6b1a1aa..dc123e25e 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -361,6 +361,8 @@ PODS: - React-Core - react-native-safe-area-context (3.1.9): - React-Core + - react-native-splash-screen (3.3.0): + - React-Core - react-native-udp (2.7.0): - React - react-native-version-number (0.3.6): @@ -535,6 +537,7 @@ DEPENDENCIES: - react-native-receive-sharing-intent (from `../node_modules/react-native-receive-sharing-intent`) - react-native-restart (from `../node_modules/react-native-restart`) - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) + - react-native-splash-screen (from `../node_modules/react-native-splash-screen`) - react-native-udp (from `../node_modules/react-native-udp`) - react-native-version-number (from `../node_modules/react-native-version-number`) - react-native-video (from `../node_modules/react-native-video`) @@ -663,6 +666,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-restart" react-native-safe-area-context: :path: "../node_modules/react-native-safe-area-context" + react-native-splash-screen: + :path: "../node_modules/react-native-splash-screen" react-native-udp: :path: "../node_modules/react-native-udp" react-native-version-number: @@ -786,6 +791,7 @@ SPEC CHECKSUMS: react-native-receive-sharing-intent: feba0a332a07977549a85aa58b496eb44368366a react-native-restart: aaad36f3ed7031daac3565f4a79d67e4f3884a50 react-native-safe-area-context: b6e0e284002381d2ff29fa4fff42b4d8282e3c94 + react-native-splash-screen: 4312f786b13a81b5169ef346d76d33bc0c6dc457 react-native-udp: ff9d13e523f2b58e6bc5d4d32321ac60671b5dc9 react-native-version-number: b415bbec6a13f2df62bf978e85bc0d699462f37f react-native-video: a4c2635d0802f983594b7057e1bce8f442f0ad28 @@ -827,4 +833,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 0282022703ad578ab2d9afbf3147ba3b373b4311 -COCOAPODS: 1.10.2 +COCOAPODS: 1.11.3 diff --git a/package.json b/package.json index 0b3037637..7effffa93 100644 --- a/package.json +++ b/package.json @@ -128,6 +128,7 @@ "react-native-scrollable-tab-view": "ecency/react-native-scrollable-tab-view", "react-native-slider": "^0.11.0", "react-native-snap-carousel": "^3.8.0", + "react-native-splash-screen": "^3.3.0", "react-native-svg": "^12.1.1", "react-native-swiper": "^1.6.0-rc.3", "react-native-tcp": "^4.0.0", diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index ebb64cb9b..eeea041b9 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -15,6 +15,7 @@ import PushNotification from 'react-native-push-notification'; import VersionNumber from 'react-native-version-number'; import ReceiveSharingIntent from 'react-native-receive-sharing-intent'; import Matomo from 'react-native-matomo-sdk'; +import SplashScreen from 'react-native-splash-screen' // Constants import AUTH_TYPE from '../../../constants/authType'; @@ -155,7 +156,7 @@ class ApplicationContainer extends Component { //set avatar cache stamp to invalidate previous session avatars dispatch(setAvatarCacheStamp(new Date().getTime())); - + SplashScreen.hide(); setMomentLocale(); this._fetchApp(); diff --git a/yarn.lock b/yarn.lock index 8744e58d9..5d346ba07 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9049,6 +9049,11 @@ react-native-snap-carousel@^3.8.0: prop-types "^15.6.1" react-addons-shallow-compare "15.6.2" +react-native-splash-screen@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/react-native-splash-screen/-/react-native-splash-screen-3.3.0.tgz#3af71ed17afe50fee69590a45aec399d071ead02" + integrity sha512-rGjt6HkoSXxMqH4SQUJ1gnPQlPJV8+J47+4yhgTIan4bVvAwJhEeJH7wWt9hXSdH4+VfwTS0GTaflj1Tw83IhA== + react-native-svg@^12.1.1: version "12.1.1" resolved "https://registry.yarnpkg.com/react-native-svg/-/react-native-svg-12.1.1.tgz#5f292410b8bcc07bbc52b2da7ceb22caf5bcaaee" From 0cd4db2c704af66ee7afc4c3bd5d4c3d3748be39 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Wed, 6 Jul 2022 17:50:54 +0500 Subject: [PATCH 43/43] applicationContainer cleanup --- .../container/applicationContainer.tsx | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index eeea041b9..67ee3a844 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -21,12 +21,10 @@ import SplashScreen from 'react-native-splash-screen' import AUTH_TYPE from '../../../constants/authType'; import ROUTES from '../../../constants/routeNames'; import postUrlParser from '../../../utils/postUrlParser'; -import THEME_OPTIONS from '../../../constants/options/theme'; // Services import { getAuthStatus, - getSettings, getUserData, removeUserData, getUserDataWithUsername, @@ -63,31 +61,17 @@ import { } from '../../../redux/actions/accountAction'; import { isDarkTheme, - changeNotificationSettings, - changeAllNotificationSettings, login, logoutDone, openPinCodeModal, - setApi, setConnectivityStatus, setAnalyticsStatus, - setCurrency, - setLanguage, - setUpvotePercent, - setNsfw, - isDefaultFooter, - isPinCodeOpen, setPinCode as savePinCode, isRenderRequired, logout, - setColorTheme, - setSettingsMigrated, } from '../../../redux/actions/applicationActions'; import { - hideActionModal, - hideProfileModal, setAvatarCacheStamp, - setRcOffer, showActionModal, toastNotification, updateActiveBottomTab, @@ -134,7 +118,6 @@ class ApplicationContainer extends Component { componentDidMount = () => { const { isIos } = this.state; - const { appVersion } = VersionNumber; const { dispatch, isAnalytics } = this.props; this._setNetworkListener();