Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/singapore/2.12.1 #74

Open
wants to merge 3 commits into
base: singapore-client
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 18 additions & 59 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { Root } from "native-base";
import { Provider } from 'react-redux';
import configureStore from './app/store/configureStore'
import configureStore, {setBundlesTimer} from './app/store/configureStore'
import {autoLogin, setStore} from './app/helper/auth'
import NavigationService from './NavigationService';
import { getRemoteConfig } from './app/helper/remote-config';
import { AppState } from 'react-native';
import {setRemoteConfig, loadBundles, loadProducts} from './app/actions';
import {setRemoteConfig} from './app/actions';
import { PersistGate } from 'redux-persist/integration/react'
import analytics from "./app/helper/analytics";
import { initInstabug } from "./app/helper/instabug";
Expand Down Expand Up @@ -52,30 +52,8 @@ export default class App extends React.Component {
analytics.setCurrentScreen('OnBoarding');
}

componentDidMount = async() => {
this._setBundlesTimer();
componentDidMount() {
AppState.addEventListener('change', this._handleAppStateChange);
// TODO: Check login here then hide splashscreen
setTimeout(async () => {
const loginStatus = await autoLogin();

console.log('autologin', loginStatus);
if (!loginStatus.failed) {
console.log('User logged in, hide splash screen and redirect to home.')
NavigationService.navigate(screens.Home);
console.log('Hide splash screen...');
SplashScreen.hide();
} else {
if (!loginStatus.missingProfile) {
console.log('User not logged in, hide splash screen and redirect to login');
store.dispatch(actions.userLogout());
NavigationService.navigate(screens.OnBoarding);
console.log('Hide splash screen...');
SplashScreen.hide();
}
SplashScreen.hide();
}
}, 200)
}

componentWillUnmount() {
Expand All @@ -84,49 +62,30 @@ export default class App extends React.Component {

_handleAppStateChange = async (nextAppState) => {
// Get remote config when app enters foreground
if (this.state.appState.match(/inactive|background/) && nextAppState === 'active') {
getRemoteConfig(_getRemoteConfigCallback);
this._setBundlesTimer();
if (this.state.appState === 'active' && nextAppState.match(/inactive|background/)) {
SplashScreen.show();
setTimeout(async () => {
const loginStatus = await autoLogin();
console.log('autologin', loginStatus);
} else if (this.state.appState.match(/inactive|background/) && nextAppState === 'active') {
getRemoteConfig(_getRemoteConfigCallback);
setBundlesTimer()
const loginStatus = await autoLogin();
console.log('autologin', loginStatus);

if (!loginStatus.failed) {
NavigationService.navigate(screens.Home);
if (!loginStatus.failed) {
NavigationService.navigate(screens.Home);

} else {
if (!loginStatus.missingProfile) {
store.dispatch(actions.userLogout());
NavigationService.navigate(screens.OnBoarding);
}
} else {
if (!loginStatus.missingProfile) {
store.dispatch(actions.userLogout());
NavigationService.navigate(screens.OnBoarding);
}
}

SplashScreen.hide();
}, 200)
console.log('hide splash screen');
SplashScreen.hide();
}
this.setState({appState: nextAppState});
};

_reloadBundles() {
store.dispatch(loadBundles());
store.dispatch(loadProducts());
}

_setBundlesTimer() {
console.log('set bundles timer...');
if (typeof this.interval === 'undefined' || this.interval === 0) {
this.interval = setInterval(() => this._reloadBundles() , 5000);
}
}

_removeBundlesTimer() {
console.log('remove bundles timer...', this.interval);
if (this.interval) {
clearInterval(this.interval);
}
}

render() {
return (
<Provider store={store}>
Expand Down
11 changes: 9 additions & 2 deletions NavigationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ function setTopLevelNavigator(navigatorRef) {
_navigator = navigatorRef;
}

function navigate(routeName, params) {
console.log(_navigator);
function _navigate(routeName,params) {
_navigator.dispatch(
NavigationActions.navigate({
routeName,
Expand All @@ -18,6 +17,14 @@ function navigate(routeName, params) {
);
}

function navigate(routeName, params) {
if (!_navigator) {
setTimeout(() => navigate(routeName, params), 200)
} else {
_navigate(routeName, params);
}
}

// add other navigation functions that you need and export them

export default {
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ android {
applicationId "sg.redotter.otterdelight"
minSdkVersion 16
targetSdkVersion 26
versionCode 22
versionName "2.12.0"
versionCode 24
versionName "2.12.1"
ndk {
abiFilters "armeabi-v7a", "x86"
}
Expand Down
2 changes: 1 addition & 1 deletion app/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const rootReducer = (state, action) => {
console.log('root reducer', action, state);

if (action.type === ActionTypes.USER_LOGOUT) {
state = undefined
state = {}
}

switch (action.type) {
Expand Down
49 changes: 47 additions & 2 deletions app/store/configureStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,62 @@ import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
import api from '../middleware/api'
import rootReducer from '../reducers'
import {autoLogin} from "../helper/auth";
import NavigationService from "../../NavigationService";
import screens from "../helper/screens";
import SplashScreen from "react-native-splash-screen";
import {loadBundles, loadProducts} from "../actions";

const persistConfig = {
key: 'root',
storage: storage,
whitelist: ['pseudonyms', 'auth', 'profile', 'products', 'subscription', 'cards', 'bundles']
};

let interval;
let store;

const persistedReducer = persistReducer(persistConfig, rootReducer);

export const setBundlesTimer = () => {
console.log('set bundles timer...');
if (typeof interval === 'undefined' || interval === 0) {
interval = setInterval(() => reloadBundles(), 5000);
}
}

export const reloadBundles = () => {
store.dispatch(loadBundles());
store.dispatch(loadProducts());
}

export default () => {
let store = createStore(persistedReducer, applyMiddleware(thunk, api));
let persistor = persistStore(store);
store = createStore(persistedReducer, applyMiddleware(thunk, api));
let persistor = persistStore(store, {}, async () => {
console.log('------------------------------');
console.log('persist done...');


const loginStatus = await autoLogin();

console.log('autologin', loginStatus);
if (!loginStatus.failed) {
console.log('User logged in, hide splash screen and redirect to home.')
console.log('Hide splash screen...');
SplashScreen.hide();
NavigationService.navigate(screens.Home);
setBundlesTimer()
} else {
if (!loginStatus.missingProfile) {
console.log('User not logged in, hide splash screen and redirect to login');
// store.dispatch(actions.userLogout());
NavigationService.navigate(screens.OnBoarding);
console.log('Hide splash screen...');
SplashScreen.hide();
}
console.log('Hide Splash screen');
SplashScreen.hide();
}
});
return { store, persistor }
}
4 changes: 2 additions & 2 deletions ios/PanaceaReactNativeClient-tvOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.12.0</string>
<string>2.12.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>36</string>
<string>37</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
4 changes: 2 additions & 2 deletions ios/PanaceaReactNativeClient-tvOSTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>2.12.0</string>
<string>2.12.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>36</string>
<string>37</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions ios/PanaceaReactNativeClient.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,7 @@
CODE_SIGN_ENTITLEMENTS = PanaceaReactNativeClient/PanaceaReactNativeClient.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 36;
CURRENT_PROJECT_VERSION = 37;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = G4VMYY2CK5;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1660,7 +1660,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 36;
CURRENT_PROJECT_VERSION = 37;
DEVELOPMENT_TEAM = G4VMYY2CK5;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down
4 changes: 2 additions & 2 deletions ios/PanaceaReactNativeClient/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.12.0</string>
<string>2.12.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -44,7 +44,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>36</string>
<string>37</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down
4 changes: 2 additions & 2 deletions ios/PanaceaReactNativeClientTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>2.12.0</string>
<string>2.12.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>36</string>
<string>37</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "PanaceaReactNativeClient",
"version": "2.12.0",
"version": "2.12.1",
"private": true,
"devDependencies": {
"@babel/core": "^7.0.0",
Expand Down