Fix crashes

This commit is contained in:
Zhiyuan Zheng 2022-01-31 00:31:57 +01:00
parent bd49caa52a
commit 60f0a838cc
5 changed files with 35 additions and 12379 deletions

File diff suppressed because one or more lines are too long

View File

@ -72,7 +72,7 @@ const Timeline: React.FC<Props> = ({
}) })
const flattenData = data?.pages const flattenData = data?.pages
? data.pages.flatMap(page => [...page.body]) ? data.pages?.flatMap(page => [...page.body])
: [] : []
const ItemSeparatorComponent = useCallback( const ItemSeparatorComponent = useCallback(

View File

@ -108,10 +108,10 @@ const TimelineAttachment = React.memo(
) )
default: default:
if ( if (
attachment.preview_url.endsWith('.jpg') || attachment.preview_url?.endsWith('.jpg') ||
attachment.preview_url.endsWith('.jpeg') || attachment.preview_url?.endsWith('.jpeg') ||
attachment.preview_url.endsWith('.png') || attachment.preview_url?.endsWith('.png') ||
attachment.preview_url.endsWith('.gif') || attachment.preview_url?.endsWith('.gif') ||
attachment.remote_url?.endsWith('.jpg') || attachment.remote_url?.endsWith('.jpg') ||
attachment.remote_url?.endsWith('.jpeg') || attachment.remote_url?.endsWith('.jpeg') ||
attachment.remote_url?.endsWith('.png') || attachment.remote_url?.endsWith('.png') ||

View File

@ -333,7 +333,7 @@ const ScreenCompose: React.FC<RootStackScreenProps<'Screen-Compose'>> = ({
] ]
) )
} else { } else {
Sentry.Native.captureException(error) Sentry.Native.captureMessage('Compose posting', error)
haptics('Error') haptics('Error')
composeDispatch({ type: 'posting', payload: false }) composeDispatch({ type: 'posting', payload: false })
Alert.alert(t('heading.right.alert.default.title'), undefined, [ Alert.alert(t('heading.right.alert.default.title'), undefined, [

View File

@ -42,34 +42,38 @@ const ComposeEditAttachmentSubmit: React.FC<Props> = ({ index }) => {
) { ) {
formData.append( formData.append(
'focus', 'focus',
`${theAttachment.meta?.focus?.x || 0},${-theAttachment.meta?.focus `${theAttachment.meta?.focus?.x || 0},${
?.y || 0}` -theAttachment.meta?.focus?.y || 0
}`
) )
} }
apiInstance<Mastodon.Attachment>({ theAttachment?.id &&
method: 'put', apiInstance<Mastodon.Attachment>({
url: `media/${theAttachment.id}`, method: 'put',
body: formData url: `media/${theAttachment.id}`,
}) body: formData
.then(() => {
haptics('Success')
navigation.goBack()
})
.catch(() => {
setIsSubmitting(false)
haptics('Error')
Alert.alert(
t('content.editAttachment.header.right.failed.title'),
undefined,
[
{
text: t('content.editAttachment.header.right.failed.button'),
style: 'cancel'
}
]
)
}) })
.then(() => {
haptics('Success')
navigation.goBack()
})
.catch(() => {
setIsSubmitting(false)
haptics('Error')
Alert.alert(
t('content.editAttachment.header.right.failed.title'),
undefined,
[
{
text: t(
'content.editAttachment.header.right.failed.button'
),
style: 'cancel'
}
]
)
})
}} }}
/> />
) )