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')}>