Fixed initial errors
This commit is contained in:
@ -32,12 +32,12 @@ const SignInScreen = ({onSignIn}: {onSignIn: () => void}) => {
|
||||
});
|
||||
console.log(
|
||||
credential.user, credential.email, credential.fullName?.givenName,
|
||||
credential.fullName?.familyName, pushToken
|
||||
credential.fullName?.familyName, pushToken.data
|
||||
);
|
||||
|
||||
const initialDataResponse = await getInitialDataByAppleId(credential.user);
|
||||
|
||||
console.log(initialDataResponse);
|
||||
console.log("InitialData response: ", initialDataResponse);
|
||||
if (initialDataResponse.status === 404 || !initialDataResponse.ok) {
|
||||
if (!credential.user || !credential.email ||
|
||||
!credential.fullName?.givenName || !credential.fullName?.familyName ||
|
||||
@ -56,7 +56,7 @@ const SignInScreen = ({onSignIn}: {onSignIn: () => void}) => {
|
||||
const user: User = await createUser(
|
||||
credential.user,
|
||||
credential.email,
|
||||
credential.fullName?.givenName + credential.fullName?.familyName,
|
||||
credential.fullName?.givenName + ' ' + credential.fullName?.familyName,
|
||||
pushToken.data
|
||||
) as User;
|
||||
await saveUser(user);
|
||||
|
@ -13,7 +13,7 @@ type RelationshipProps = {
|
||||
pfpUrl: string | null;
|
||||
};
|
||||
|
||||
const Relationship: React.FC<RelationshipProps> = ({ pfpUrl }) => {
|
||||
const RelationshipView: React.FC<RelationshipProps> = ({ pfpUrl }) => {
|
||||
const [status, setStatus] = useState<RelationshipData | null>(null);
|
||||
const [user, setUser] = useState<User | null>(null);
|
||||
const [showRequestRelationship, setShowRequestRelationship] = useState(false);
|
||||
@ -253,7 +253,7 @@ const Relationship: React.FC<RelationshipProps> = ({ pfpUrl }) => {
|
||||
</ThemedView>
|
||||
);
|
||||
};
|
||||
export default Relationship;
|
||||
export default RelationshipView;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
@ -121,7 +121,7 @@ export const updateCountdown = async (updatedFields: Partial<any>) => {
|
||||
};
|
||||
export const saveRelationshipData = async (relationshipData: RelationshipData) => {
|
||||
try {
|
||||
await SecureStore.setItemAsync('partner', JSON.stringify(relationshipData.Partner));
|
||||
await SecureStore.setItemAsync('partner', JSON.stringify(relationshipData.partner));
|
||||
await SecureStore.setItemAsync('relationship', JSON.stringify(relationshipData.relationship));
|
||||
} catch (error) {
|
||||
console.error('Error saving partner & relationship to SecureStore:', error);
|
||||
@ -130,13 +130,16 @@ export const saveRelationshipData = async (relationshipData: RelationshipData) =
|
||||
export const saveInitialData = async (initialData: InitialData) => {
|
||||
try {
|
||||
await SecureStore.setItemAsync('user', JSON.stringify(initialData.user));
|
||||
await SecureStore.setItemAsync(
|
||||
'relationship', JSON.stringify(initialData.relationshipData.relationship)
|
||||
);
|
||||
await SecureStore.setItemAsync(
|
||||
'partner', JSON.stringify(initialData.relationshipData.Partner)
|
||||
);
|
||||
await SecureStore.setItemAsync('countdown', JSON.stringify(initialData.countdown));
|
||||
if (initialData.relationshipData) {
|
||||
await SecureStore.setItemAsync(
|
||||
'relationship', JSON.stringify(initialData.relationshipData.relationship)
|
||||
);
|
||||
await SecureStore.setItemAsync(
|
||||
'partner', JSON.stringify(initialData.relationshipData.partner)
|
||||
);
|
||||
if (initialData.countdown)
|
||||
await SecureStore.setItemAsync('countdown', JSON.stringify(initialData.countdown));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error saving initial data to SecureStore:', error);
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import React, { useState, useEffect, useRef, ErrorInfo } from 'react';
|
||||
import { Alert, Platform } from 'react-native';
|
||||
import * as Device from 'expo-device';
|
||||
import * as Notifications from 'expo-notifications';
|
||||
import Constants from 'expo-constants';
|
||||
import type { NotificationMessage } from '@/constants/Types';
|
||||
import { ThemedText } from '@/components/theme/Theme';
|
||||
|
||||
Notifications.setNotificationHandler({
|
||||
handleNotification: async () => ({
|
||||
@ -114,5 +115,33 @@ export const PushNotificationManager = ({children}: {children: React.ReactNode})
|
||||
Notifications.removeNotificationSubscription(responseListener.current);
|
||||
};
|
||||
}, []);
|
||||
return ( <> {children} </> );
|
||||
//return ( <> {children} </> );
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
{children}
|
||||
</ErrorBoundary>
|
||||
);
|
||||
};
|
||||
|
||||
class ErrorBoundary extends React.Component<{children: React.ReactNode}, {hasError: boolean}> {
|
||||
constructor(props: {children: React.ReactNode}) {
|
||||
super(props);
|
||||
this.state = { hasError: false };
|
||||
}
|
||||
|
||||
static getDerivedStateFromError(_: Error) {
|
||||
return { hasError: true };
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
||||
console.log('Error caught by ErrorBoundary:', error, errorInfo);
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.hasError) {
|
||||
return <ThemedText>Something went wrong.</ThemedText>;
|
||||
}
|
||||
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ const TextButton = ({ width, height, text, fontSize, onPress }: Props ) => {
|
||||
<ThemedText
|
||||
style={[
|
||||
{
|
||||
color: Colors[scheme].text,
|
||||
color: Colors[scheme].background,
|
||||
fontSize: fontSize ?? DEFAULT_FONT_SIZE
|
||||
}
|
||||
]}
|
||||
|
Reference in New Issue
Block a user