Fix warnings and errors

This commit is contained in:
xmflsct 2023-01-09 22:28:53 +01:00
parent b9c4b139f5
commit a4e97ccb1c
6 changed files with 25 additions and 22 deletions

View File

@ -55,14 +55,9 @@ const GracefullyImage = ({
const { colors } = useTheme()
const [imageLoaded, setImageLoaded] = useState(false)
const [currentUri, setCurrentUri] = useState<string | undefined>(uri.original || uri.remote)
const source = {
uri: reduceMotionEnabled && uri.static ? uri.static : uri.original
}
const onLoad = () => {
setImageLoaded(true)
if (setImageDimensions && source.uri) {
Image.getSize(source.uri, (width, height) => setImageDimensions({ width, height }))
}
uri: reduceMotionEnabled && uri.static ? uri.static : currentUri
}
const blurhashView = () => {
@ -92,11 +87,19 @@ const GracefullyImage = ({
/>
) : null}
<FastImage
source={{
uri: reduceMotionEnabled && uri.static ? uri.static : uri.original
}}
source={source}
style={[{ flex: 1 }, imageStyle]}
onLoad={onLoad}
onLoad={() => {
setImageLoaded(true)
if (setImageDimensions && source.uri) {
Image.getSize(source.uri, (width, height) => setImageDimensions({ width, height }))
}
}}
onError={() => {
if (uri.original && uri.original === currentUri && uri.remote) {
setCurrentUri(uri.remote)
}
}}
/>
{blurhashView()}
</Pressable>

View File

@ -126,7 +126,7 @@ const TimelineNotifications: React.FC<Props> = ({ notification, queryKey }) => {
}
if (filterResults?.length && !filterRevealed) {
return !filterResults.filter(result => result.filter_action === 'hide').length ? (
return !filterResults.filter(result => result.filter_action === 'hide')?.length ? (
<Pressable onPress={() => setFilterRevealed(!filterRevealed)}>
<TimelineFiltered filterResults={filterResults} />
</Pressable>

View File

@ -144,7 +144,7 @@ const TimelineRefresh: React.FC<Props> = ({
>(queryKey)?.pages[0]
prevActive.current = true
prevStatusId.current = firstPage?.body[0].id
prevStatusId.current = firstPage?.body[0]?.id
await queryFunctionTimeline({
queryKey,
@ -182,7 +182,7 @@ const TimelineRefresh: React.FC<Props> = ({
flRef.current?.scrollToOffset({ offset: scrollY.value - 15, animated: true })
}
await new Promise(promise => setTimeout(promise, 32))
await new Promise(promise => setTimeout(promise, 64))
queryClient.setQueryData<
InfiniteData<
PagedResponse<(Mastodon.Status | Mastodon.Notification | Mastodon.Conversation)[]>

View File

@ -49,7 +49,7 @@ const TabMeProfileRoot: React.FC<
<ProfileAvatarHeader type='header' messageRef={messageRef} />
<MenuRow
title={t('screenTabs:me.profile.root.note.title')}
content={data?.source.note}
content={data?.source?.note}
loading={isFetching}
iconBack='ChevronRight'
onPress={() => {

View File

@ -18,7 +18,7 @@ const AccountInformationAccount: React.FC = () => {
const [acct] = useAccountStorage.string('auth.account.acct')
const domain = getAccountStorage.string('auth.account.domain')
const localInstance = account?.acct.includes('@') ? account?.acct.includes(`@${domain}`) : true
const localInstance = account?.acct?.includes('@') ? account?.acct?.includes(`@${domain}`) : true
if (account || pageMe) {
return (

View File

@ -182,7 +182,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
},
{
enabled:
query.isFetched &&
(toot._remote ? true : query.isFetched) &&
['public', 'unlisted'].includes(toot.visibility) &&
match?.domain !== getAccountStorage.string('auth.domain'),
staleTime: 0,
@ -193,12 +193,12 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
return
}
if ((query.data?.pages[0].body.length || 0) < data.length) {
if ((query.data?.pages[0].body.length || 0) - 1 <= data.length) {
queryClient.cancelQueries(queryKey.local)
queryClient.setQueryData<{
pages: { body: Mastodon.Status[] }[]
}>(queryKey.local, old => {
if (!old) return old
if (!old) return { pages: [{ body: [toot] }] }
setHasRemoteContent(true)
return {
@ -355,7 +355,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
`h ${ARC}`
}
strokeWidth={1}
stroke={colors.red}
stroke={colors.border}
strokeOpacity={0.6}
/>
</Svg>
@ -375,7 +375,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
}
})
: null}
<CustomText
{/* <CustomText
children={query.data?.pages[0].body[index - 1]?._level}
style={{ position: 'absolute', top: 4, left: 4, color: colors.red }}
/>
@ -386,7 +386,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
<CustomText
children={query.data?.pages[0].body[index + 1]?._level}
style={{ position: 'absolute', top: 36, left: 4, color: colors.green }}
/>
/> */}
</View>
)
}}