Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Hot fixes 0.0.10 #323

Merged
merged 7 commits into from
Nov 26, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"versionFlag": "private-beta-rc",
"requiredServerVersion": "0.0.10",

"productionMode": true
"productionMode": false
}
14 changes: 9 additions & 5 deletions src/components/input/GlassButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import { StyleSheet, Text, TouchableOpacity } from 'react-native';
import Styles, { Colors, Fonts } from '../../styles/Styles';

const GlassButton = ({ children, onPress, buttonText, style, disabled, fontSize = 19 }) => (
<TouchableOpacity onPress={onPress} disabled={disabled} style={{
...styles.container,
...style,
backgroundColor: disabled ? Colors.purple2 : Colors.purple1,
}}>
<TouchableOpacity
onPress={onPress}
disabled={disabled}
style={{
...styles.container,
...style,
backgroundColor: disabled ? `${Colors.lightGrey}60` : Colors.purple1,
shadowOpacity: disabled ? 0 : 0.5,
}}>
{children == null ? (
<Text style={{
...Fonts.bold(fontSize, Colors.white),
Expand Down
1 change: 0 additions & 1 deletion src/components/other/DebugUrlsMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ const DebugUrlsMenu = () => {
</>
)}
</View>

);
};

Expand Down
11 changes: 11 additions & 0 deletions src/components/viewSlider/ViewSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ const ViewSlider = ({ children, onViewIndexChanged = () => {} }, ref) => {
</Text>
</TouchableOpacity>
)}
{currentViewIndex === 0 && (
<TouchableOpacity
style={{ ...Styles.center, position: 'absolute', bottom: 0, width: '100%' }}
onPress={() => setCurrentViewIndex(1)}
hitSlop={{ top: 30, bottom: 30, left: 30, right: 30 }}
>
<Text style={{ marginBottom: 10, ...Fonts.bold(13, Colors.lightGrey) }}>
I dont have an account
</Text>
</TouchableOpacity>
)}
{currentViewIndex > 1 && currentViewIndex < children.length - 1 && (
<DotIndicator
currentIndex={currentViewIndex - 1}
Expand Down
11 changes: 9 additions & 2 deletions src/screens/Onboarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { AntDesign, FontAwesome5, MaterialCommunityIcons, MaterialIcons } from '
import { openCamera, openPicker } from 'react-native-image-crop-picker';
import { useActionSheet } from '@expo/react-native-action-sheet';
import { PERMISSIONS, request, requestNotifications, RESULTS } from 'react-native-permissions';
import BackgroundGeolocation from 'react-native-background-geolocation';
import DropyLogo from '../assets/svgs/dropy_logo_grey.svg';
import Styles, { Colors, Fonts } from '../styles/Styles';
import OnboardingLines from '../assets/svgs/onboarding_lines.svg';
Expand Down Expand Up @@ -223,7 +222,10 @@ export default function Onboarding({ navigation }) {

try {
const userInfos = await API.login(email, password);
setUser(userInfos);
// Fix #322 permissions granting messing with states -> sockets not initializing
setTimeout(() => {
setUser(userInfos);
}, 1000);
} catch (error) {
setLoading(false);
if (error.response.status === 404) {
Expand Down Expand Up @@ -383,13 +385,15 @@ export default function Onboarding({ navigation }) {
onEdited={setEmail}
isEmail
defaultValue={email}
autoComplete='email'
/>
<FormInput
placeholder='Password'
inputStyle={{ backgroundColor: Colors.lighterGrey }}
isPassword
onEdited={setPassword}
defaultValue={password}
autoComplete='password'
/>
</View>
<LoadingGlassButton
Expand Down Expand Up @@ -463,6 +467,7 @@ export default function Onboarding({ navigation }) {
inputStyle={{ backgroundColor: Colors.lighterGrey }}
isEmail
defaultValue={email}
autoComplete='email'
/>
<FormInput
ref={passwordInputRef}
Expand All @@ -471,6 +476,7 @@ export default function Onboarding({ navigation }) {
inputStyle={{ backgroundColor: Colors.lighterGrey }}
isPassword
defaultValue={password}
autoComplete='password-new'
/>
<FormInput
ref={passwordConfirmationInputRef}
Expand All @@ -479,6 +485,7 @@ export default function Onboarding({ navigation }) {
inputStyle={{ backgroundColor: Colors.lighterGrey }}
isPassword
defaultValue={passwordConfirmation}
autoComplete='password-new'
/>
</View>
<LoadingGlassButton
Expand Down
27 changes: 20 additions & 7 deletions src/screens/SettingScreen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-undef */
import React, { useContext, useEffect, useState } from 'react';
import React, { useContext, useEffect, useRef, useState } from 'react';
import {
Linking,
SafeAreaView,
Expand All @@ -12,6 +11,7 @@ import {
} from 'react-native';
import { responsiveWidth } from 'react-native-responsive-dimensions';
import { AntDesign, Feather, Ionicons } from '@expo/vector-icons';
import KeyboardSpacer from 'react-native-keyboard-spacer';
import AppInfo from '../../app.json';
import Styles, { Colors, Fonts } from '../styles/Styles';
import { BackgroundGeolocationContext } from '../states/BackgroundGolocationContextProvider';
Expand All @@ -32,14 +32,19 @@ const SettingsScreen = ({ navigation }) => {
const { sendAlert } = useOverlay();

const [notificationsSettings, setNotificationsSettings] = useState(null);
const notificatinsSettingsRef = useRef(null);

useEffect(() => {
fetchNotificationsSettings();
return () => {
if (notificatinsSettingsRef.current != null)
postNotificationsSettings(notificatinsSettingsRef.current);
};
celian-rib marked this conversation as resolved.
Show resolved Hide resolved
}, []);

useEffect(() => {
if (notificationsSettings)
postNotificationsSettings();
if (notificationsSettings != null)
notificatinsSettingsRef.current = notificationsSettings;
}, [notificationsSettings]);

const fetchNotificationsSettings = async () => {
Expand All @@ -57,9 +62,10 @@ const SettingsScreen = ({ navigation }) => {
}
};

const postNotificationsSettings = async () => {
const postNotificationsSettings = async (settings) => {
console.log('postNotificationsSettings', settings);
try {
await API.postNotificationsSettings(notificationsSettings);
await API.postNotificationsSettings(settings);
} catch (error) {
sendAlert({
title: 'Notifications settings not updated',
Expand All @@ -71,6 +77,7 @@ const SettingsScreen = ({ navigation }) => {
};

const logout = async () => {
await postNotificationsSettings(notificatinsSettingsRef.current);
await API.logout();
navigation.reset({
index: 0,
Expand Down Expand Up @@ -173,6 +180,7 @@ const SettingsScreen = ({ navigation }) => {

<View style={styles.spacer} />

{/* eslint-disable-next-line no-undef */}
<TouchableOpacity onLongPress={() => (user.isDeveloper || __DEV__) && setDeveloperMode((old) => !old)} activeOpacity={1}>
<View style={styles.infoTextContainer}>
<Ionicons name='git-branch' size={19} color={Colors.darkGrey} />
Expand All @@ -195,7 +203,12 @@ const SettingsScreen = ({ navigation }) => {
</TouchableOpacity>

<DebugText marginBottom={20}>DEV MODE</DebugText>
{(developerMode || customUrls) && <DebugUrlsMenu /> }
{(developerMode || customUrls) && (
<>
<DebugUrlsMenu />
<KeyboardSpacer />
</>
)}
</ScrollView>
</SafeAreaView>
);
Expand Down
11 changes: 8 additions & 3 deletions src/screens/Splash.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Storage from '../utils/storage';
const Splash = ({ navigation, route }) => {
const { cancelAutoLogin = false } = route.params ?? {};

const { setUser, user } = useCurrentUser();
const { setUser, user, customUrls } = useCurrentUser();

const { sendAlert } = useOverlay();

Expand All @@ -26,14 +26,18 @@ const Splash = ({ navigation, route }) => {
handleLoginSuccess();
}, [user]);

const navigateToOnboarding = () => navigation.reset({ index: 0, routes: [{ name: 'Onboarding' }] });
const navigateToOnboarding = () => {
Storage.removeItem('@auth_tokens');
navigation.reset({ index: 0, routes: [{ name: 'Onboarding' }] });
};

const launch = async () => {
const ready = await appIsReady();
console.log(`Splash launch : app is ready -> ${ready}`);

if (!ready) {
navigateToOnboarding();
if (customUrls != null)
navigateToOnboarding();
return;
}

Expand Down Expand Up @@ -61,6 +65,7 @@ const Splash = ({ navigation, route }) => {

const appIsReady = async () => {
try {
await API.loadCustomUrl();
const isCompatibleWithServer = await API.serverVersionIsCompatible();

if (!isCompatibleWithServer) {
Expand Down
5 changes: 4 additions & 1 deletion src/services/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ const getHeaders = () => axios.defaults.headers.common;

const loadCustomUrl = async () => {
const customUrls = await Storage.getItem('@custom_urls');
if (customUrls != null)
if (customUrls != null) {
console.log('Using custom urls', customUrls);
axios.defaults.baseURL = customUrls.api ?? API_BASE_URL;
}
};

const register = async (displayName, email, password, newsLetter) => {
Expand Down Expand Up @@ -231,6 +233,7 @@ const API = {
logout,
getNotificationsSettings,
postNotificationsSettings,
loadCustomUrl,
};

export default API;
4 changes: 2 additions & 2 deletions src/states/UserContextProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ const UserProvider = ({ children }) => {
}, [user]);

useEffect(() => {
loadStoredIPs();
loadCustomUrls();
}, []);

const loadStoredIPs = async () => {
const loadCustomUrls = async () => {
const customUrls = await Storage.getItem('@custom_urls');
if (!customUrls)
return;
Expand Down