From e619677660c603708eef48491e0f95335633c37c Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Sat, 19 Feb 2022 17:09:34 +0100 Subject: [PATCH] Fix crashes --- package.json | 2 +- src/components/Timeline/Shared/Avatar.tsx | 2 +- src/screens/Tabs/Shared/Toot.tsx | 27 +++-------------------- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index f98d2ac2..d6d80c69 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "native": "220214", "major": 3, "minor": 5, - "patch": 2, + "patch": 3, "expo": "44.0.0" }, "description": "tooot app for Mastodon", diff --git a/src/components/Timeline/Shared/Avatar.tsx b/src/components/Timeline/Shared/Avatar.tsx index e6ddb0a1..228a77a6 100644 --- a/src/components/Timeline/Shared/Avatar.tsx +++ b/src/components/Timeline/Shared/Avatar.tsx @@ -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 diff --git a/src/screens/Tabs/Shared/Toot.tsx b/src/screens/Tabs/Shared/Toot.tsx index d8e20a15..fb1f4d1d 100644 --- a/src/screens/Tabs/Shared/Toot.tsx +++ b/src/screens/Tabs/Shared/Toot.tsx @@ -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> = ({ route: { @@ -45,25 +44,15 @@ const TabSharedToot: React.FC> = ({ 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> = ({ 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> = ({ }), 500 ) - } catch (err) { - if (Math.random() < 0.05) { - Sentry.Native.captureException(err) - } - } + } catch {} }, [itemsLength] )