Skip to content

Commit

Permalink
performance
Browse files Browse the repository at this point in the history
  • Loading branch information
SagivOnoApps committed Jun 21, 2020
1 parent 02a2c31 commit c981f8f
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 34 deletions.
6 changes: 3 additions & 3 deletions src/components/Drawer/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createDrawerNavigator, } from '@react-navigation/drawer';
import AsyncStorage from '@react-native-community/async-storage';
import { CardStyleInterpolators, createStackNavigator } from '@react-navigation/stack';
import { useSelector } from 'react-redux';
import { NavigationProp, RouteProp } from '@react-navigation/native';
import ScanHome from '../Main/ScanHome';
import DrawerContent from './DrawerContent';
import ExposuresHistory from '../Main/ExposuresHistory/ExposuresHistory';
Expand All @@ -19,15 +20,14 @@ import ShareLocations from '../ShareLocations/ShareLocations';
import { LocaleReducer, ExposuresReducer, Store, Exposure } from '../../types';
import MapModal from '../Main/MapModal';
import { INIT_ROUTE_NAME } from '../../constants/Constants';
import { NavigationProp, RouteProp } from '@react-navigation/native';

const Stack = createStackNavigator();

const DEFAULT_SCREEN = 'ScanHome';

interface DrawerStackProps {
navigation: NavigationProp<any,'DrawerStack'>,
route: RouteProp<any,'DrawerStack'>
navigation: NavigationProp<any, 'DrawerStack'>,
route: RouteProp<any, 'DrawerStack'>
}

const DrawerStack = ({ navigation, route }: DrawerStackProps) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ const Loading: FunctionComponent<Props> = (
const onBoardingCompletedActions = async () => {
try {
// don't init config second time
await ResetMessaging(false);
ResetMessaging(false);

await purgeSamplesDB();
await clusterLocationsOnAppUpdate();
await startForegroundTimer();
startForegroundTimer();

const dbSick = new IntersectionSickDatabase();

Expand Down
50 changes: 31 additions & 19 deletions src/components/Main/ExposuresHistory/ExposuresHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const ExposuresHistory = (
const [lineAnimWidth] = useState(new Animated.Value(0));
const [listTranslateAnim] = useState(new Animated.Value(isRTL ? SCREEN_WIDTH : 0));
const [firstLoad, setFirstLoad] = useState(true);

useEffect(() => {
// didn't layout yet
if (tabsLayout?.[tabIndex]) {
Expand All @@ -68,7 +68,7 @@ const ExposuresHistory = (
return (
<View style={styles.container}>
<HeaderButton type="back" onPress={navigation.goBack} />

{showEditBtn && (
<TouchableOpacity
hitSlop={HIT_SLOP}
Expand All @@ -94,29 +94,42 @@ const ExposuresHistory = (
style={styles.tabTextContainer}
onPress={() => setTabIndex(0)}
>
<Text
bold={Boolean(!tabIndex)}
style={styles.tabText}
onLayout={({ nativeEvent: { layout } }) => setTabsLayout(state => ({ ...state, 0: layout }))}
<View style={{
width: SCREEN_WIDTH / 2,
alignItems: 'center',
justifyContent: 'center'
}}
>
{wasNotThere}
</Text>

<Text
bold={Boolean(!tabIndex)}
style={styles.tabText}
onLayout={({ nativeEvent: { layout } }) => setTabsLayout(state => ({ ...state, 0: layout }))}
>
{wasNotThere}
</Text>
</View>
</TouchableOpacity>
<TouchableOpacity
hitSlop={{ top: 10 }}
style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}
style={styles.tabTextContainer}
onPress={() => setTabIndex(0)}
>
<Text
bold={Boolean(tabIndex)}
style={styles.tabText}
onLayout={({ nativeEvent: { layout } }) => setTabsLayout(state => ({ ...state, 1: layout }))}
onPress={() => setTabIndex(1)}
<View style={{
alignItems: 'center',
justifyContent: 'center',
width: SCREEN_WIDTH / 2,
}}
>
{wasThere}
</Text>

<Text
bold={Boolean(tabIndex)}
style={styles.tabText}
onLayout={({ nativeEvent: { layout } }) => setTabsLayout(state => ({ ...state, 1: layout }))}
onPress={() => setTabIndex(1)}
>
{wasThere}
</Text>
</View>
</TouchableOpacity>
</View>
<Animated.View
Expand Down Expand Up @@ -211,8 +224,7 @@ const styles = StyleSheet.create({
},
tabText: {
fontSize: IS_SMALL_SCREEN ? 14 : 16,
width: SCREEN_WIDTH / 2,
paddingHorizontal: 10
paddingHorizontal: 10,
},
editButtonContainer: {
position: 'absolute',
Expand Down
9 changes: 2 additions & 7 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ import { Config } from '../types';
const env: 'com.hamagen.qa' | 'com.hamagen' = DeviceInfo.getBundleId();
// @ts-ignore
let config: Config = DefaultConfig[env] || DefaultConfig['com.hamagen.qa'];
let configFromServer = false;

export const initConfig = async () => new Promise(async (resolve) => {
try {
if (configFromServer) {
return config;
}

const configUrls = await axios.get(`https://gisweb.azureedge.net/get_config.json?r=${Math.random()}`, { headers: { 'Content-Type': 'application/json;charset=utf-8' } });
const data = await downloadAndVerifySigning(configUrls.data[env]);

config = data[env];
resolve();
configFromServer = true;
} catch (error) {
onError({ error });
resolve();
Expand Down
4 changes: 2 additions & 2 deletions src/constants/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ export const USAGE_ON_BOARDING = 'USAGE_ON_BOARDING';
export const USAGE_PRIVACY = 'USAGE_PRIVACY';

// BLE
export const USER_AGREE_TO_BLE = 'USER_AGREE_TO_BLE';
export const ENABLE_BLE = true;
export const SUBSCRIBED_TOPIC = 'SUBSCRIBED_TOPIC';
export const USER_AGREE_TO_BLE = 'USER_AGREE_TO_BLE';
export const SUBSCRIBED_TOPIC = 'SUBSCRIBED_TOPIC';
1 change: 0 additions & 1 deletion src/services/Tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const startForegroundTimer = async () => {
await checkBLESickPeople();
await checkGeoSickPeople();


BackgroundTimer.runBackgroundTimer(backgroundTimerFn, config().fetchMilliseconds);

await AsyncStorage.setItem(
Expand Down

0 comments on commit c981f8f

Please sign in to comment.