Merge pull request #221 from tooot-app/main

Try to fix toot id not found
This commit is contained in:
xmflsct 2022-02-11 21:38:33 +01:00 committed by GitHub
commit a457e9e78e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View File

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

View File

@ -35,29 +35,30 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
? // @ts-ignore ? // @ts-ignore
result.data.pages.flatMap(d => [...d.body]) result.data.pages.flatMap(d => [...d.body])
: [] : []
setItemsLength(flattenData.length)
// Auto go back when toot page is empty // Auto go back when toot page is empty
if (flattenData.length === 0) { if (flattenData.length === 0) {
navigation.goBack() navigation.goBack()
} }
setItemsLength(flattenData.length)
if (!scrolled.current) { if (!scrolled.current) {
scrolled.current = true scrolled.current = true
const pointer = flattenData.findIndex(({ id }) => id === toot.id) const pointer = flattenData.findIndex(({ id }) => id === toot.id)
if (pointer === -1) return
try { try {
pointer < flattenData.length && setTimeout(() => {
setTimeout(() => { flRef.current?.scrollToIndex({
flRef.current?.scrollToIndex({ index: pointer,
index: pointer, viewOffset: 100
viewOffset: 100 })
}) }, 500)
}, 500)
} catch (err) { } catch (err) {
if (Math.random() < 0.1) { if (Math.random() < 0.1) {
Sentry.Native.setContext('Scroll to Index', { Sentry.Native.setContext('Scroll to Index', {
type: 'original', type: 'original',
index: pointer, index: pointer,
itemsLength: flattenData.length, itemsLength: flattenData.length,
flattenData id: toot.id,
flattenData: flattenData.map(({ id }) => id)
}) })
Sentry.Native.captureException(err) Sentry.Native.captureException(err)
} }
@ -87,7 +88,8 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
Sentry.Native.setContext('Scroll to Index', { Sentry.Native.setContext('Scroll to Index', {
type: 'onScrollToIndexFailed', type: 'onScrollToIndexFailed',
index: error.index, index: error.index,
itemsLength itemsLength,
id: toot.id
}) })
Sentry.Native.captureException(err) Sentry.Native.captureException(err)
} }