Fix crashes

This commit is contained in:
Zhiyuan Zheng 2022-02-19 17:09:34 +01:00
parent a0321291aa
commit e619677660
3 changed files with 5 additions and 26 deletions

View File

@ -4,7 +4,7 @@
"native": "220214",
"major": 3,
"minor": 5,
"patch": 2,
"patch": 3,
"expo": "44.0.0"
},
"description": "tooot app for Mastodon",

View File

@ -37,7 +37,7 @@ const TimelineAvatar = React.memo(
})
})}
onPress={onPress}
uri={{ original: account.avatar, static: account.avatar_static }}
uri={{ original: account?.avatar, static: account?.avatar_static }}
dimension={{
width: StyleConstants.Avatar.M,
height: StyleConstants.Avatar.M

View File

@ -6,7 +6,6 @@ import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
import React, { useCallback, useEffect, useRef, useState } from 'react'
import { FlatList } from 'react-native'
import { InfiniteQueryObserver, useQueryClient } from 'react-query'
import * as Sentry from 'sentry-expo'
const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
route: {
@ -45,25 +44,15 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
scrolled.current = true
const pointer = flattenData.findIndex(({ id }) => id === toot.id)
if (pointer < 1) return
Sentry.Native.setContext('Scroll to Index', {
type: 'original',
index: pointer,
itemsLength: flattenData.length,
id: toot.id,
flattenData: flattenData.map(({ id }) => id)
})
try {
setTimeout(() => {
console.log('scrolling')
flRef.current?.scrollToIndex({
index: pointer,
viewOffset: 100
})
}, 500)
} catch (err) {
if (Math.random() < 0.05) {
Sentry.Native.captureException(err)
}
}
} catch {}
}
}
})
@ -74,12 +63,6 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
error => {
const offset = error.averageItemLength * error.index
flRef.current?.scrollToOffset({ offset })
Sentry.Native.setContext('Scroll to Index', {
type: 'onScrollToIndexFailed',
index: error.index,
itemsLength,
id: toot.id
})
try {
error.index < itemsLength &&
setTimeout(
@ -90,11 +73,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
}),
500
)
} catch (err) {
if (Math.random() < 0.05) {
Sentry.Native.captureException(err)
}
}
} catch {}
},
[itemsLength]
)