Commit a829ef1c by HaOuiha

update

parent ad51094f
......@@ -13,12 +13,42 @@ import rootStore from './reduxStore';
import { Root } from 'native-base';
import { fixTimerWarning } from './utils/fixTimerWarning';
// import { default as customMapping } from './custom-mapping.json';
import { fireStore } from './firebase';
console.disableYellowBox = true;
const Application = () => {
useEffect(() => {
fixTimerWarning();
// const data = {
// 0: {
// details: {
// description: 'description',
// name: 'main222',
// notification: true,
// rcbo: 10,
// },
// timers: {
// isActive: true,
// isPowerOn: true,
// timer: 1566378008,
// repeatOn: [
// { id: 0, day: 'Monday', isRepeat: false },
// { id: 1, day: 'Tuesday', isRepeat: false },
// { id: 2, day: 'Wednesday', isRepeat: false },
// { id: 3, day: 'Thursday', isRepeat: false },
// { id: 4, day: 'Friday', isRepeat: false },
// { id: 5, day: 'Saturday', isRepeat: false },
// { id: 6, day: 'Sunday', isRepeat: false },
// ],
// },
// },
// };
// fireStore
// .collection('device')
// .doc('iYs6Th9Pkg1vTEDIyPa5')
// .update(data);
}, []);
return (
......
......@@ -49,9 +49,19 @@ const defaultNavigationOptions = {
},
};
const SmartMeterStack = createStackNavigator(
const HomeStack = createStackNavigator(
{
SmartMeter: SmartMeterScreen,
},
{
headerLayoutPreset: 'center',
defaultNavigationOptions,
}
);
const SmartMeterStack = createStackNavigator(
{
// SmartMeter: SmartMeterScreen,
SmartMeterDetail: SmartMeterDetailScreen,
},
{
......@@ -218,6 +228,7 @@ const WithBottomTabStack = createBottomTabNavigator(
const MainStack = createStackNavigator(
{
Home: HomeStack,
WithBottomTab: WithBottomTabStack,
Camera: CameraStack,
},
......
......@@ -11,41 +11,42 @@ import { format } from 'date-fns';
const AnimatedIcon = Animated.createAnimatedComponent(IconMaterialIcons);
const Row = ({ data }) => {
// console.log(data);
console.log('ROWdata', data);
return (
<RectButton style={styles.rectButton} onPress={() => alert('hello ' + data.name)}>
<View style={{ flexDirection: 'row', paddingVertical: 5 }}>
<View style={{ flex: 1 }}>
<Text style={[theme.title, { color: data.active ? color.black : color.grey }]}>
<Text style={[theme.title, { color: data.isActive ? color.black : color.grey }]}>
{format(data.time, 'h:mm')}{' '}
<Text
style={[
theme.description,
theme.textDark,
{ color: data.active ? color.black : color.grey },
{ color: data.isActive ? color.black : color.grey },
]}
>
{format(data.time, 'A')}
</Text>
</Text>
<View style={theme.rowContainer}>
{data.repeatDays.map((item, index) => (
{Object.values(data.repeatOn).map((bool, index) => (
<Text
key={index}
style={[
theme.description,
{
color: data.active
? item.isRepeat
color: data.isActive
? bool
? color.primary
: color.grey
: item.isRepeat
: bool
? color.darkGrey
: color.grey,
},
]}
>
{item.day}{' '}
{Object.keys(data.repeatOn)[index].substr(0, 1)}
</Text>
))}
</View>
......@@ -54,9 +55,9 @@ const Row = ({ data }) => {
<Text
style={[theme.title, { fontWeight: 'normal', color: data.active ? color.black : color.grey }]}
>
{data.name}
{data.name || 'untitled'}
</Text>
<Text style={theme.description}>{data.active ? 'Active' : 'Inactive'} </Text>
{/* <Text style={theme.description}>{data.active ? 'Active' : 'Inactive'} </Text> */}
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<View style={{ alignItems: 'center' }}>
......@@ -69,7 +70,7 @@ const Row = ({ data }) => {
},
]}
>
{data.power ? 'ON' : 'OFF'}
{data.isPowerOn ? 'ON' : 'OFF'}
</Text>
<Text style={theme.description}>Power</Text>
</View>
......@@ -84,6 +85,7 @@ class SwipeableRow extends Component {
state = {
isVisible: false,
};
renderRightActions = (progress, dragX) => {
const scale = dragX.interpolate({
inputRange: [-80, 0],
......
......@@ -14,6 +14,9 @@
"@react-native-community/async-storage": "^1.6.1",
"date-fns": "^1.30.1",
"firebase": "^6.3.5",
"lodash": "^4.17.15",
"lodash.defaults": "^4.2.0",
"lodash.flatten": "^4.4.0",
"native-base": "^2.12.2",
"react": "^16.9.0",
"react-native": "^0.60.4",
......
import { fireStore } from '../../firebase';
// export const GET_ALL_DEVICE_ID = 'GET_ALL_DEVICE_ID';
export const GET_ALL_DEVICE_INFO = 'GET_ALL_DEVICE_INFO';
// export const getAllDeviceIdAction = allDeviceId => ({
// type: GET_ALL_DEVICE_ID,
// allDeviceId,
// });
export const GET_ALL_DEVICE_INFO_LOADING = 'GET_ALL_DEVICE_INFO_LOADING';
export const GET_ALL_DEVICE_INFO_ERROR = 'GET_ALL_DEVICE_INFO_ERROR';
export const getAllDeviceInfoAction = allDeviceInfo => ({
type: GET_ALL_DEVICE_INFO,
allDeviceInfo,
});
// export const getAllDeviceId = () => async (dispatch, getState) => {
// const { currentUserReducer } = getState();
// const currentUserId = currentUserReducer.uid;
// const allOwnerDeviceId = await fireStore
// .collection('owner')
// .doc(currentUserId)
// .get();
// const allSharingDeviceId = await fireStore
// .collection('sharing')
// .doc(currentUserId)
// .get();
// const allDeviceId = Object.keys({ ...allOwnerDeviceId.data(), ...allSharingDeviceId.data() });
export const loadingAction = bool => ({
type: GET_ALL_DEVICE_INFO_LOADING,
isLoading: bool,
});
// return dispatch(getAllDeviceIdAction(allDeviceId));
// };
export const errorAction = error => ({
type: GET_ALL_DEVICE_INFO_ERROR,
error,
});
export const getAllDeviceInfo = () => async (dispatch, getState) => {
dispatch(loadingAction(true));
const { currentUserReducer } = getState();
const currentUserId = currentUserReducer.uid;
try {
......@@ -49,31 +37,30 @@ export const getAllDeviceInfo = () => async (dispatch, getState) => {
const allOwnerDeviceId = Object.keys({ ...allOwnerDevice.data() });
const allSharingDeviceId = Object.keys({ ...allSharingDevice.data() });
let alldeviceInfo = [];
await allOwnerDeviceId.map((deviceId, index) => {
let allDeviceInfoData = [];
allOwnerDeviceId.map((deviceId, index) => {
fireStore
.collection('device')
.doc(deviceId)
.get()
.then(deviceInfo =>
alldeviceInfo.push(Object.assign(deviceInfo.data(), { deviceId, isSharing: false }))
allDeviceInfoData.push(Object.assign(deviceInfo.data(), { deviceId, isSharing: false }))
);
});
await allSharingDeviceId.map((deviceId, index) => {
allSharingDeviceId.map((deviceId, index) => {
fireStore
.collection('device')
.doc(deviceId)
.get()
.then(deviceInfo =>
alldeviceInfo.push(Object.assign(deviceInfo.data(), { deviceId, isSharing: true }))
allDeviceInfoData.push(Object.assign(deviceInfo.data(), { deviceId, isSharing: true }))
);
});
const allDataInfo = await alldeviceInfo;
console.log(allDataInfo);
return dispatch(getAllDeviceInfoAction(allDataInfo));
dispatch(getAllDeviceInfoAction(allDeviceInfoData));
dispatch(loadingAction(false));
} catch (error) {
alert(error);
dispatch(errorAction(error || error.message || 'Error'));
dispatch(loadingAction(false));
}
};
import app from '../../firebase';
export const GET_CURRENT_USER = 'GET_CURRENT_USER';
export const getCurrentUserAction = (displayName, email, emailVerified, phoneNumber, uid) => ({
......@@ -11,7 +9,7 @@ export const getCurrentUserAction = (displayName, email, emailVerified, phoneNum
uid,
});
export const getCurrentUser = () => async dispatch => {
const { displayName, email, emailVerified, phoneNumber, uid } = await app.auth().currentUser;
return dispatch(getCurrentUserAction(displayName, email, emailVerified, phoneNumber, uid));
export const getCurrentUser = user => async dispatch => {
const { displayName, email, emailVerified, phoneNumber, uid } = user;
dispatch(getCurrentUserAction(displayName, email, emailVerified, phoneNumber, uid));
};
export const SET_CURRENT_SELECTED = 'SET_CURRENT_SELECTED';
export const setCurrentSelectedAction = selectedDeviceId => ({
type: GET_CURRENT_SELECTED,
type: SET_CURRENT_SELECTED,
selectedDeviceId,
});
export const setCurrentSelected = DeviceId => async dispatch => {
return dispatch(setCurrentSelectedAction(DeviceId));
await dispatch(setCurrentSelectedAction(DeviceId));
};
import AsyncStorage from '@react-native-community/async-storage';
export const getToken = token => ({
type: 'GET_TOKEN',
token,
});
export const saveToken = token => ({
type: 'SAVE_TOKEN',
token,
});
export const removeToken = () => ({
type: 'REMOVE_TOKEN',
});
export const loading = bool => ({
type: 'LOADING',
isLoading: bool,
});
export const error = error => ({
type: 'ERROR',
error,
});
export const getUserToken = () => async dispatch => {
try {
await AsyncStorage.getItem('userToken');
dispatch(loading(false));
dispatch(getToken(data));
} catch (err) {
dispatch(loading(false));
dispatch(error(err.message || 'ERROR'));
}
};
export const saveUserToken = data => async dispatch => {
try {
await AsyncStorage.setItem('userToken', '');
dispatch(loading(false));
dispatch(saveToken(data));
} catch (err) {
dispatch(loading(false));
dispatch(error(err.message || 'ERROR'));
}
};
export const removeUserToken = () => async dispatch => {
try {
await AsyncStorage.removeItem('userToken');
dispatch(loading(false));
dispatch(removeToken(data));
} catch (err) {
dispatch(loading(false));
dispatch(error(err.message || 'ERROR'));
}
};
import { fireStore } from '../../firebase';
import _ from 'lodash';
export const GET_TIMERS = 'GET_TIMERS';
export const GET_TIMERS_LOADING = 'GET_TIMERS_LOADING';
export const GET_TIMERS_ERROR = 'GET_TIMERS_ERROR';
export const getTimersAction = timers => ({
type: GET_TIMERS,
timers,
});
export const loadingAction = bool => ({
type: GET_TIMERS_LOADING,
isLoading: bool,
});
export const errorAction = error => ({
type: GET_TIMERS_ERROR,
error,
});
export const getTimers = () => async (dispatch, getState) => {
dispatch(loadingAction(true));
const { currentSelectedDeviceReducer } = getState();
const { selectedDeviceId } = currentSelectedDeviceReducer;
// console.log(selectedDeviceId);
try {
const allTimers = await fireStore
.collection('device')
.doc(selectedDeviceId)
.get();
const allTimersData = await allTimers.data();
console.log('allTimersData', allTimersData);
const allTimersDataArray = Object.entries(allTimersData).map(e => ({ [e[0]]: e[1] }));
// const allTimersDataflat = _.compact([allTimersData]);
// console.log('allTimersDataflat', allTimersDataflat);
dispatch(getTimersAction(allTimersDataArray));
dispatch(loadingAction(false));
} catch (error) {
dispatch(errorAction(error || error.message || 'Error'));
dispatch(loadingAction(false));
}
};
......@@ -3,6 +3,6 @@ import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import logger from 'redux-logger';
const middleware = __DEV__ === true ? applyMiddleware(thunk, logger) : applyMiddleware(thunk);
const middleware = __DEV__ === true ? [thunk, logger] : thunk;
export default (store = createStore(allReducers, middleware));
export default (store = createStore(allReducers, applyMiddleware(...middleware)));
import {
// GET_ALL_DEVICE_ID,
GET_ALL_DEVICE_INFO,
} from '../actions/allDataAction';
import { GET_ALL_DEVICE_INFO, GET_ALL_DEVICE_INFO_LOADING, GET_ALL_DEVICE_INFO_ERROR } from '../actions/allDataAction';
const initState = {
// allDeviceId: null,
allDeviceInfo: null,
allDeviceInfo: [],
isLoading: true,
error: null,
};
const allDataReducer = (state = initState, action) => {
switch (action.type) {
// case GET_ALL_DEVICE_ID:
// return { ...state, allDeviceId: action.allDeviceId };
case GET_ALL_DEVICE_INFO:
return { ...state, allDeviceInfo: action.allDeviceInfo };
case GET_ALL_DEVICE_INFO_LOADING:
return { ...state, isLoading: action.isLoading };
case GET_ALL_DEVICE_INFO_ERROR:
return { ...state, error: action.error };
default:
return state;
}
......
const initialState = {
token: {},
loading: true,
error: null,
};
const authReducer = (state = initialState, action) => {
switch (action.type) {
case 'GET_TOKEN':
return { ...state, token: action.token };
case 'SAVE_TOKEN':
return { ...state, token: action.token };
case 'REMOVE_TOKEN':
return { ...state, token: action.token };
case 'LOADING':
return { ...state, loading: action.isLoading };
case 'ERROR':
return { ...state, error: action.error };
default:
return state;
}
};
export default authReducer;
import { combineReducers } from 'redux';
// import authReducer from './authReducer';
import { reducer as form } from 'redux-form';
import allDataReducer from './allDataReducer';
import currentUserReducer from './currentUserReducer';
import currentSelectedDeviceReducer from './currentSelectedReducer';
import timersReducer from './timersReducer';
export default combineReducers({
// token: authReducer,
currentSelectedDeviceReducer,
currentUserReducer,
allDataReducer,
timersReducer,
form,
});
import { GET_TIMERS, GET_TIMERS_LOADING, GET_TIMERS_ERROR } from '../actions/timersAction';
const initState = {
timers: [],
isLoading: true,
error: null,
};
const timersReducer = (state = initState, action) => {
switch (action.type) {
case GET_TIMERS:
return { ...state, timers: action.timers };
case GET_TIMERS_LOADING:
return { ...state, isLoading: action.isLoading };
case GET_TIMERS_ERROR:
return { ...state, error: action.error };
default:
return state;
}
};
export default timersReducer;
......@@ -86,13 +86,13 @@ const LimitCurrent = [
class SmartMeterDetailScreen extends Component {
static navigationOptions = ({ navigation }) => {
const deviceName = navigation.getParam('deviceName', '');
const deviceName = navigation.getParam('name', '');
return {
title: deviceName,
headerLeft: (
<HeaderButtons HeaderButtonComponent={IoniconsHeaderButton}>
<Item title="back" iconName="ios-arrow-back" onPress={() => navigation.goBack()} />
<Item title="back" iconName="ios-arrow-back" onPress={() => navigation.popToTop()} />
</HeaderButtons>
),
headerRight: (
......@@ -121,6 +121,7 @@ class SmartMeterDetailScreen extends Component {
sb: this.expandState(),
data: this.props.allDeviceInfo[0],
};
renderCurrent(item, index) {
return (
<Card
......@@ -171,7 +172,7 @@ class SmartMeterDetailScreen extends Component {
renderMCBLink(item, index) {
const sb = this.state.sb;
return (
<View>
<View key={`MBCLink${index}`}>
<Row
style={{ padding: 7 }}
onPress={() =>
......@@ -193,7 +194,10 @@ class SmartMeterDetailScreen extends Component {
}
renderSubbreaker(item) {
return (
<View style={[theme.containerWithPadding, { backgroundColor: 'rgba(216,216,216,0.1)' }]}>
<View
key={`Subbreker${item}`}
style={[theme.containerWithPadding, { backgroundColor: 'rgba(216,216,216,0.1)' }]}
>
<Row>
<Left>
<View>
......@@ -279,7 +283,7 @@ class SmartMeterDetailScreen extends Component {
}
}}
numColumns={3}
keyExtractor={(item, index) => index}
keyExtractor={(item, index) => index.toString()}
style={{ paddingTop: 20 }}
/>
{/* MCB Link */}
......
......@@ -9,37 +9,7 @@ import { isIphoneX } from '../../../utils/isPhoneX';
import { getAllDeviceInfo } from '../../../reduxStore/actions/allDataAction';
import { setCurrentSelected } from '../../../reduxStore/actions/currentSelectedAction';
import { connect } from 'react-redux';
let Data = [
// {
// deviceName: 'Device 1',
// description: 'Lorem ipsum dolorsit amet,consectetur adipiscing elit. Cras sagitti.',
// img: 'https://www.tunnelbear.com/static/img/android@2x.b83f4df.png',
// isOnline: true,
// isOn: true,
// },
// {
// deviceName: 'Device 2',
// description: 'Lorem ipsum dolorsit amet,consectetur adipiscing elit. Cras sagitti.',
// img: 'https://www.tunnelbear.com/static/img/android@2x.b83f4df.png',
// isOnline: false,
// isOn: true,
// },
// {
// deviceName: 'Device 3',
// description: 'Lorem ipsum dolorsit amet,consectetur adipiscing elit. Cras sagitti.',
// img: 'https://www.tunnelbear.com/static/img/android@2x.b83f4df.png',
// isOnline: true,
// isOn: false,
// },
// {
// deviceName: 'Device 4',
// description: 'Lorem ipsum dolorsit amet,consectetur adipiscing elit. Cras sagitti.',
// img: 'https://www.tunnelbear.com/static/img/android@2x.b83f4df.png',
// isOnline: false,
// isOn: false,
// },
];
import { getTimers } from '../../../reduxStore/actions/timersAction';
class SmartMeterScreen extends Component {
static navigationOptions = ({ navigation }) => ({
......@@ -57,67 +27,64 @@ class SmartMeterScreen extends Component {
});
state = {
initData: this.props.allDeviceInfo,
data: this.props.allDeviceInfo,
data: [],
isLoading: true,
};
static getDerivedStateFromProps = (nextProps, prevState) => {
if (prevState.data !== nextProps.allDeviceInfo) {
return {
data: nextProps.allDeviceInfo,
};
} else null;
_isMounted = false;
componentDidMount = () => {
this._isMounted = true;
this.getData();
};
componentDidMount = async () => {
await this.props.getAllDeviceInfo();
renderItem = ({ item, index }) => {
// console.log('item', index, item);
console.log(item['0'].details);
return (
<MeterCard
name={item['0'].details.name || 'Untitled'}
description={item['0'].details.description || ''}
img={item['0'].details.img || null}
isOnline={item['0'].details.isOnline || false}
isOn={item['0'].details.isOn || false}
onPressEachCard={async () => {
await this.props.setCurrentSelected(item.deviceId || null);
this.props.getTimers();
this.props.navigation.navigate('SmartMeterDetail', { name: item['0'].details.name || '' });
}}
/>
);
};
componentDidUpdate = (prevProps, prevState) => {
if (prevState.data !== this.state.data) {
this.setState({ isLoading: false });
}
getData = () => {
this._isMounted = false;
this.props.getAllDeviceInfo();
};
render() {
console.log(this.state);
let { allDeviceInfo, getAllDeviceInfo, setCurrentSelected } = this.props;
const { isLoading } = this.state;
let { allDeviceInfo, isLoading } = this.props;
return (
<FlatList
refreshing={isLoading}
onRefresh={getAllDeviceInfo}
onRefresh={this.getData}
style={[theme.container, theme.containerWithPadding]}
contentContainerStyle={{ paddingBottom: isIphoneX() ? 90 : 55 }} //iPhoneX BottomSpace = 34
data={this.state.initData}
extraData={this.state.data}
data={allDeviceInfo}
extraData={allDeviceInfo}
keyExtractor={(item, index) => `Card${index}`}
ListEmptyComponent={() => (
<View>
<Text style={[theme.normalText, { marginTop: 20 }]}>
{isLoading ? '' : 'No Device Connected'}
{isLoading ? '' : this._isMounted ? 'No Device Connected' : ''}
</Text>
</View>
)}
ListHeaderComponent={() => (
<Text style={[theme.smallTitle, theme.textDark, { marginBottom: 10 }]}>Smart meter</Text>
)}
renderItem={({ item, index }) => (
<MeterCard
// key={`mastercard${index}`}
name={item.name || 'Untitled'}
description={item.description || ''}
img={item.img || null}
isOnline={item.isOnline || false}
isOn={item.isOn || false}
onPressEachCard={() => {
setCurrentSelected(item.deviceId);
this.props.navigation.navigate('SmartMeterDetail', { name: item.name });
}}
/>
)}
renderItem={this.renderItem}
/>
);
}
......@@ -125,11 +92,13 @@ class SmartMeterScreen extends Component {
const mapStateToProps = state => ({
allDeviceInfo: state.allDataReducer.allDeviceInfo,
isLoading: state.allDataReducer.isLoading,
});
const mapDispatchToProps = {
getAllDeviceInfo,
setCurrentSelected,
getTimers,
};
export default connect(
......
......@@ -25,6 +25,7 @@ import { isIphoneX } from '../../../utils/isPhoneX';
import FadeDimBG from '../../../components/FadeDimBG';
import SlideUpModal from '../../../components/SlideUpModal';
import { connect } from 'react-redux';
import { getTimers } from '../../../reduxStore/actions/timersAction';
// mock data
const MultipleMockData = [
......@@ -203,23 +204,6 @@ class TimerScreen extends Component {
search: '',
};
// renderTimerFab = () => {
// return (
// <Fab
// containerStyle={{
// bottom: '15%',
// // right: '50%', // centerFAB
// // marginRight: -28,
// }}
// style={{ backgroundColor: color.primary }}
// position="bottomRight"
// onPress={() => this.setState({ isVisible: true })}
// >
// <Icon name="add" />
// </Fab>
// );
// };
autoCloseSwipeRow = swipeInstance => {
if (this.currentlyOpenSwipe && this.currentlyOpenSwipe !== swipeInstance) {
this.currentlyOpenSwipe.close();
......@@ -257,9 +241,14 @@ class TimerScreen extends Component {
this.setState({ search });
};
// componentDidMount = () => {
// this.props.getTimers();
// };
componentDidUpdate = (prevProps, prevState) => {
prevState !== this.state && console.log(this.state);
prevProps !== this.props && console.log(this.props);
if (prevProps.timers !== this.props.timers) {
console.log('timers =>', this.props.timers || '');
}
};
render() {
......@@ -287,7 +276,7 @@ class TimerScreen extends Component {
{/* List Timer */}
<FlatList
contentContainerStyle={{ paddingBottom: isIphoneX() ? 90 : 55 }}
data={MultipleMockData[0].timer}
data={this.props.timers}
ListEmptyComponent={() => (
<View>
<Text style={[theme.normalText, theme.mt2]}>No Subbreaker</Text>
......@@ -543,9 +532,19 @@ class TimerScreen extends Component {
const mapStateToProps = state => ({
allDeviceInfo: state.allDataReducer.allDeviceInfo,
timers: state.timersReducer.timers,
isLoading: state.timersReducer.isLoading,
selectedDeviceId: state.currentSelectedDeviceReducer.selectedDeviceId,
});
export default connect(mapStateToProps)(TimerScreen);
const mapDispatchToProps = {
getTimers,
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(TimerScreen);
const pickerStyle = {
inputIOS: {
......
......@@ -5,7 +5,6 @@ import logo from '../../assets/images/logo2.png';
import { width } from '../../constants/Layout';
import app from '../../firebase';
import { connect } from 'react-redux';
import { getAllDeviceInfo } from '../../reduxStore/actions/allDataAction';
import { getCurrentUser } from '../../reduxStore/actions/cerrentUserAction';
class AuthLoadingScreen extends Component {
......@@ -13,10 +12,14 @@ class AuthLoadingScreen extends Component {
header: null,
};
constructor(props) {
super(props);
// constructor(props) {
// super(props);
// this._bootstrapAsync();
// }
componentDidMount = () => {
this._bootstrapAsync();
}
};
state = {
isShowImg: true,
......@@ -36,10 +39,10 @@ class AuthLoadingScreen extends Component {
const alreadyLaunched = await AsyncStorage.getItem('alreadyLaunched');
const RememberedLogin = await AsyncStorage.getItem('RememberedLogin');
app.auth().onAuthStateChanged(async user => {
app.auth().onAuthStateChanged(user => {
if (user) {
await this.props.getCurrentUser();
await this.props.getAllDeviceInfo();
this.props.getCurrentUser(user);
this.props.navigation.navigate(RememberedLogin ? 'Main' : 'Login');
} else {
this.props.navigation.navigate(alreadyLaunched ? 'Login' : 'Onboarding');
......@@ -47,38 +50,6 @@ class AuthLoadingScreen extends Component {
});
};
// componentDidMount = async () => {
// this.showLogoThenIndicator();
// // Preload data from an external API
// // Preload data using AsyncStorage
// const alreadyLaunched = await AsyncStorage.getItem('alreadyLaunched');
// const RememberedLogin = await AsyncStorage.getItem('RememberedLogin');
// app.auth().onAuthStateChanged(async user => {
// if (user) {
// this.props.getCurrentUser && (await this.props.getCurrentUser());
// this.setState({ authentication: true });
// this.props.navigation.navigate(RememberedLogin ? 'Main' : 'Login');
// } else {
// this.setState({ authentication: false });
// this.props.navigation.navigate(alreadyLaunched ? 'Login' : 'Onboarding');
// }
// });
// };
// componentDidUpdate = async (prevProps, prevState) => {
// if (prevState.authentication !== this.state.authentication) {
// this.props.getCurrentUser && (await this.props.getCurrentUser());
// this.props.navigation.navigate(
// this.state.RememberedLogin
// ? 'Main'
// : this.state.authentication || this.state.alreadyLaunched
// ? 'Login'
// : 'Onboarding'
// );
// }
// };
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
......@@ -100,7 +71,6 @@ class AuthLoadingScreen extends Component {
const mapDispatchToProps = {
getCurrentUser,
getAllDeviceInfo,
};
export default connect(
......
......@@ -4491,6 +4491,16 @@ lodash.clone@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.clone/-/lodash.clone-4.5.0.tgz#195870450f5a13192478df4bc3d23d2dea1907b6"
integrity sha1-GVhwRQ9aExkkeN9Lw9I9LeoZB7Y=
lodash.defaults@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
integrity sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=
lodash.flatten@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f"
integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=
lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
......@@ -4521,7 +4531,7 @@ lodash@4.17.11:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.6.1:
lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.6.1:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment