diff --git a/patches/expo-av+13.0.2.patch b/patches/expo-av+13.0.2.patch new file mode 100644 index 00000000..72bf082a --- /dev/null +++ b/patches/expo-av+13.0.2.patch @@ -0,0 +1,14 @@ +diff --git a/node_modules/expo-av/ios/EXAV/EXAudioSessionManager.m b/node_modules/expo-av/ios/EXAV/EXAudioSessionManager.m +index 81dce13..8664b90 100644 +--- a/node_modules/expo-av/ios/EXAV/EXAudioSessionManager.m ++++ b/node_modules/expo-av/ios/EXAV/EXAudioSessionManager.m +@@ -168,9 +168,6 @@ - (void)moduleDidBackground:(id)backgroundingModule + // compact doesn't work, that's why we need the `|| !pointer` above + // http://www.openradar.me/15396578 + [_foregroundedModules compact]; +- +- // Any possible failures are silent +- [self _updateSessionConfiguration]; + } + + - (void)moduleDidForeground:(id)module diff --git a/src/api/general.ts b/src/api/general.ts index 29e49158..09eb3966 100644 --- a/src/api/general.ts +++ b/src/api/general.ts @@ -1,6 +1,5 @@ import axios from 'axios' -import handleError, { ctx } from './handleError' -import { userAgent } from './helpers' +import { ctx, handleError, userAgent } from './helpers' export type Params = { method: 'get' | 'post' | 'put' | 'delete' diff --git a/src/api/handleError.ts b/src/api/handleError.ts deleted file mode 100644 index efbff696..00000000 --- a/src/api/handleError.ts +++ /dev/null @@ -1,31 +0,0 @@ -import chalk from 'chalk' - -export const ctx = new chalk.Instance({ level: 3 }) - -const handleError = (error: any) => { - if (error?.response) { - // The request was made and the server responded with a status code - // that falls out of the range of 2xx - console.error( - ctx.bold(' API '), - ctx.bold('response'), - error.response.status, - error?.response.data?.error || error?.response.message || 'Unknown error' - ) - return Promise.reject({ - status: error?.response.status, - message: error?.response.data?.error || error?.response.message || 'Unknown error' - }) - } else if (error?.request) { - // The request was made but no response was received - // `error.request` is an instance of XMLHttpRequest in the browser and an instance of - // http.ClientRequest in node.js - console.error(ctx.bold(' API '), ctx.bold('request'), error) - return Promise.reject() - } else { - console.error(ctx.bold(' API '), ctx.bold('internal'), error?.message) - return Promise.reject() - } -} - -export default handleError diff --git a/src/api/helpers/index.ts b/src/api/helpers/index.ts index 799b7d11..2f057967 100644 --- a/src/api/helpers/index.ts +++ b/src/api/helpers/index.ts @@ -1,6 +1,36 @@ -import Constants from "expo-constants" -import { Platform } from "react-native" +import chalk from 'chalk' +import Constants from 'expo-constants' +import { Platform } from 'react-native' -const userAgent = { 'User-Agent': `tooot/${Constants.expoConfig?.version} ${Platform.OS}/${Platform.Version}` } +const userAgent = { + 'User-Agent': `tooot/${Constants.expoConfig?.version} ${Platform.OS}/${Platform.Version}` +} -export { userAgent } \ No newline at end of file +const ctx = new chalk.Instance({ level: 3 }) +const handleError = (error: any) => { + if (error?.response) { + // The request was made and the server responded with a status code + // that falls out of the range of 2xx + console.error( + ctx.bold(' API '), + ctx.bold('response'), + error.response.status, + error?.response.data?.error || error?.response.message || 'Unknown error' + ) + return Promise.reject({ + status: error?.response.status, + message: error?.response.data?.error || error?.response.message || 'Unknown error' + }) + } else if (error?.request) { + // The request was made but no response was received + // `error.request` is an instance of XMLHttpRequest in the browser and an instance of + // http.ClientRequest in node.js + console.error(ctx.bold(' API '), ctx.bold('request'), error) + return Promise.reject() + } else { + console.error(ctx.bold(' API '), ctx.bold('internal'), error?.message) + return Promise.reject() + } +} + +export { ctx, handleError, userAgent } diff --git a/src/api/instance.ts b/src/api/instance.ts index 0126e4b1..270f88df 100644 --- a/src/api/instance.ts +++ b/src/api/instance.ts @@ -1,8 +1,7 @@ import { RootState } from '@root/store' import axios, { AxiosRequestConfig } from 'axios' import li from 'li' -import handleError, { ctx } from './handleError' -import { userAgent } from './helpers' +import { ctx, handleError, userAgent } from './helpers' export type Params = { method: 'get' | 'post' | 'put' | 'delete' | 'patch' diff --git a/src/api/tooot.ts b/src/api/tooot.ts index 94f2bb98..bfe6d8e3 100644 --- a/src/api/tooot.ts +++ b/src/api/tooot.ts @@ -1,8 +1,7 @@ import * as Sentry from '@sentry/react-native' import { mapEnvironment } from '@utils/checkEnvironment' import axios from 'axios' -import handleError, { ctx } from './handleError' -import { userAgent } from './helpers' +import { ctx, handleError, userAgent } from './helpers' export type Params = { method: 'get' | 'post' | 'put' | 'delete' @@ -57,14 +56,12 @@ const apiTooot = async ({ }) }) .catch(error => { - Sentry.setExtras({ - API: 'tooot', - request: { url, params, body }, - ...(error?.response && { response: error.response }) - }) - Sentry.captureMessage('API error', { - contexts: { errorObject: error } + Sentry.setContext('API request', { url, params, body }) + Sentry.setContext('Error response', { + ...(error?.response && { response: error.response?._response }) }) + Sentry.setContext('Error object', { error }) + Sentry.captureMessage('API error') return handleError(error) }) diff --git a/src/components/Account.tsx b/src/components/Account.tsx index a65827dd..b2c7a058 100644 --- a/src/components/Account.tsx +++ b/src/components/Account.tsx @@ -5,22 +5,17 @@ import { TabLocalStackParamList } from '@utils/navigation/navigators' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React, { PropsWithChildren } from 'react' -import { Pressable, View } from 'react-native' +import { Pressable, PressableProps, View } from 'react-native' import GracefullyImage from './GracefullyImage' +import Icon from './Icon' import CustomText from './Text' export interface Props { account: Mastodon.Account - Component?: typeof View | typeof Pressable - props?: {} + props?: PressableProps } -const ComponentAccount: React.FC = ({ - account, - Component, - props, - children -}) => { +const ComponentAccount: React.FC = ({ account, props, children }) => { const { colors } = useTheme() const navigation = useNavigation>() @@ -28,50 +23,62 @@ const ComponentAccount: React.FC = ({ props = { onPress: () => navigation.push('Tab-Shared-Account', { account }) } } - return React.createElement( - Component || Pressable, - { - ...props, - style: { + return ( + + + + + + + + + @{account.acct} + + + + {props.onPress && !props.disabled ? ( + + ) : ( + children || null + )} + } - }, - - - - - - - - @{account.acct} - - - , - children + /> ) } diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 80049c5d..62ba3490 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -1,15 +1,8 @@ import Icon from '@components/Icon' import { StyleConstants } from '@utils/styles/constants' -import layoutAnimation from '@utils/styles/layoutAnimation' import { useTheme } from '@utils/styles/ThemeManager' -import React, { useEffect, useMemo, useRef, useState } from 'react' -import { - AccessibilityProps, - Pressable, - StyleProp, - View, - ViewStyle -} from 'react-native' +import React, { useMemo, useState } from 'react' +import { AccessibilityProps, Pressable, StyleProp, View, ViewStyle } from 'react-native' import { Flow } from 'react-native-animated-spinkit' import CustomText from './Text' @@ -57,15 +50,6 @@ const Button: React.FC = ({ }) => { const { colors, theme } = useTheme() - const mounted = useRef(false) - useEffect(() => { - if (mounted.current) { - layoutAnimation() - } else { - mounted.current = true - } - }, [content, loading, disabled]) - const loadingSpinkit = useMemo( () => ( @@ -120,8 +104,7 @@ const Button: React.FC = ({ = ({ borderColor: mainColor, backgroundColor: colorBackground, paddingVertical: StyleConstants.Spacing[spacing], - paddingHorizontal: - StyleConstants.Spacing[spacing] + StyleConstants.Spacing.XS, + paddingHorizontal: StyleConstants.Spacing[spacing] + StyleConstants.Spacing.XS, width: round && layoutHeight ? layoutHeight : undefined }, customStyle ]} {...(round && { - onLayout: ({ nativeEvent }) => - setLayoutHeight(nativeEvent.layout.height) + onLayout: ({ nativeEvent }) => setLayoutHeight(nativeEvent.layout.height) })} testID='base' onPress={onPress} diff --git a/src/components/Timeline/Shared/Attachment/Video.tsx b/src/components/Timeline/Shared/Attachment/Video.tsx index 2b8594ce..c868210f 100644 --- a/src/components/Timeline/Shared/Attachment/Video.tsx +++ b/src/components/Timeline/Shared/Attachment/Video.tsx @@ -26,7 +26,6 @@ const AttachmentVideo: React.FC = ({ const videoPlayer = useRef