From 9936f6c9217b72a3fcfe556e82a31b7bbaf5e4d7 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Fri, 11 Feb 2022 21:30:45 +0100 Subject: [PATCH] Try to fix toot id not found --- package.json | 2 +- src/screens/Tabs/Shared/Toot.tsx | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 17bf8d9c..86b48048 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "native": "220206", "major": 3, "minor": 4, - "patch": 2, + "patch": 3, "expo": "44.0.0" }, "description": "tooot app for Mastodon", diff --git a/src/screens/Tabs/Shared/Toot.tsx b/src/screens/Tabs/Shared/Toot.tsx index 990ddb96..c36aa9ac 100644 --- a/src/screens/Tabs/Shared/Toot.tsx +++ b/src/screens/Tabs/Shared/Toot.tsx @@ -35,29 +35,30 @@ const TabSharedToot: React.FC> = ({ ? // @ts-ignore result.data.pages.flatMap(d => [...d.body]) : [] - setItemsLength(flattenData.length) // Auto go back when toot page is empty if (flattenData.length === 0) { navigation.goBack() } + setItemsLength(flattenData.length) if (!scrolled.current) { scrolled.current = true const pointer = flattenData.findIndex(({ id }) => id === toot.id) + if (pointer === -1) return try { - pointer < flattenData.length && - setTimeout(() => { - flRef.current?.scrollToIndex({ - index: pointer, - viewOffset: 100 - }) - }, 500) + setTimeout(() => { + flRef.current?.scrollToIndex({ + index: pointer, + viewOffset: 100 + }) + }, 500) } catch (err) { if (Math.random() < 0.1) { Sentry.Native.setContext('Scroll to Index', { type: 'original', index: pointer, itemsLength: flattenData.length, - flattenData + id: toot.id, + flattenData: flattenData.map(({ id }) => id) }) Sentry.Native.captureException(err) } @@ -87,7 +88,8 @@ const TabSharedToot: React.FC> = ({ Sentry.Native.setContext('Scroll to Index', { type: 'onScrollToIndexFailed', index: error.index, - itemsLength + itemsLength, + id: toot.id }) Sentry.Native.captureException(err) }