1
0
mirror of https://github.com/tooot-app/app synced 2025-02-01 11:06:56 +01:00

Try to capture more debug info

This commit is contained in:
Zhiyuan Zheng 2022-02-13 19:34:05 +01:00
parent 7163ce7d77
commit 5ab988585b

View File

@ -45,6 +45,13 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
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 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 { try {
setTimeout(() => { setTimeout(() => {
flRef.current?.scrollToIndex({ flRef.current?.scrollToIndex({
@ -54,13 +61,6 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
}, 500) }, 500)
} catch (err) { } catch (err) {
if (Math.random() < 0.1) { if (Math.random() < 0.1) {
Sentry.Native.setContext('Scroll to Index', {
type: 'original',
index: pointer,
itemsLength: flattenData.length,
id: toot.id,
flattenData: flattenData.map(({ id }) => id)
})
Sentry.Native.captureException(err) Sentry.Native.captureException(err)
} }
} }
@ -74,6 +74,12 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
error => { error => {
const offset = error.averageItemLength * error.index const offset = error.averageItemLength * error.index
flRef.current?.scrollToOffset({ offset }) flRef.current?.scrollToOffset({ offset })
Sentry.Native.setContext('Scroll to Index', {
type: 'onScrollToIndexFailed',
index: error.index,
itemsLength,
id: toot.id
})
try { try {
error.index < itemsLength && error.index < itemsLength &&
setTimeout( setTimeout(
@ -86,12 +92,6 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
) )
} catch (err) { } catch (err) {
if (Math.random() < 0.1) { if (Math.random() < 0.1) {
Sentry.Native.setContext('Scroll to Index', {
type: 'onScrollToIndexFailed',
index: error.index,
itemsLength,
id: toot.id
})
Sentry.Native.captureException(err) Sentry.Native.captureException(err)
} }
} }