mirror of
https://github.com/tooot-app/app
synced 2025-04-09 16:11:03 +02:00
Fix visual bugs
Somehow the `onError` of `react-native-fast-image` doesn't work anymore as expected. Maybe because the underlying `SDWebImage` is being patched to other versions.
This commit is contained in:
parent
bb02fadc16
commit
dab2ca060d
@ -53,26 +53,17 @@ const GracefullyImage = ({
|
|||||||
}: Props) => {
|
}: Props) => {
|
||||||
const { reduceMotionEnabled } = useAccessibility()
|
const { reduceMotionEnabled } = useAccessibility()
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
const [originalFailed, setOriginalFailed] = useState(false)
|
|
||||||
const [imageLoaded, setImageLoaded] = useState(false)
|
const [imageLoaded, setImageLoaded] = useState(false)
|
||||||
|
|
||||||
const source = originalFailed
|
const source = {
|
||||||
? { uri: uri.remote || undefined }
|
|
||||||
: {
|
|
||||||
uri: reduceMotionEnabled && uri.static ? uri.static : uri.original
|
uri: reduceMotionEnabled && uri.static ? uri.static : uri.original
|
||||||
}
|
}
|
||||||
|
|
||||||
const onLoad = () => {
|
const onLoad = () => {
|
||||||
setImageLoaded(true)
|
setImageLoaded(true)
|
||||||
if (setImageDimensions && source.uri) {
|
if (setImageDimensions && source.uri) {
|
||||||
Image.getSize(source.uri, (width, height) => setImageDimensions({ width, height }))
|
Image.getSize(source.uri, (width, height) => setImageDimensions({ width, height }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const onError = () => {
|
|
||||||
if (!originalFailed) {
|
|
||||||
setOriginalFailed(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const blurhashView = useMemo(() => {
|
const blurhashView = useMemo(() => {
|
||||||
if (hidden || !imageLoaded) {
|
if (hidden || !imageLoaded) {
|
||||||
@ -101,10 +92,11 @@ const GracefullyImage = ({
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<FastImage
|
<FastImage
|
||||||
source={source}
|
source={{
|
||||||
|
uri: reduceMotionEnabled && uri.static ? uri.static : uri.original
|
||||||
|
}}
|
||||||
style={[{ flex: 1 }, imageStyle]}
|
style={[{ flex: 1 }, imageStyle]}
|
||||||
onLoad={onLoad}
|
onLoad={onLoad}
|
||||||
onError={onError}
|
|
||||||
/>
|
/>
|
||||||
{blurhashView}
|
{blurhashView}
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
@ -13,6 +13,8 @@ import { useQueryClient } from '@tanstack/react-query'
|
|||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
import { checkInstanceFeature } from '@utils/slices/instancesSlice'
|
import { checkInstanceFeature } from '@utils/slices/instancesSlice'
|
||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
|
import { View } from 'react-native'
|
||||||
|
import { useRoute } from '@react-navigation/native'
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
id: Mastodon.Account['id']
|
id: Mastodon.Account['id']
|
||||||
@ -122,9 +124,12 @@ const RelationshipOutgoing: React.FC<Props> = ({ id }: Props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { name } = useRoute()
|
||||||
|
const isPageNotifications = name === 'Tab-Notifications-Root'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
{canFollowNotify && query.data?.following ? (
|
{!isPageNotifications && canFollowNotify && query.data?.following ? (
|
||||||
<Button
|
<Button
|
||||||
type='icon'
|
type='icon'
|
||||||
content={query.data.notifying ? 'BellOff' : 'Bell'}
|
content={query.data.notifying ? 'BellOff' : 'Bell'}
|
||||||
@ -151,7 +156,7 @@ const RelationshipOutgoing: React.FC<Props> = ({ id }: Props) => {
|
|||||||
loading={query.isLoading || mutation.isLoading}
|
loading={query.isLoading || mutation.isLoading}
|
||||||
disabled={query.isError || query.data?.blocked_by}
|
disabled={query.isError || query.data?.blocked_by}
|
||||||
/>
|
/>
|
||||||
</>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import GracefullyImage from '@components/GracefullyImage'
|
import GracefullyImage from '@components/GracefullyImage'
|
||||||
import navigationRef from '@helpers/navigationRef'
|
import navigationRef from '@helpers/navigationRef'
|
||||||
import { getInstanceActive } from '@utils/slices/instancesSlice'
|
import { getInstanceActive } from '@utils/slices/instancesSlice'
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Dimensions, Image, Pressable } from 'react-native'
|
import { Dimensions, Image } from 'react-native'
|
||||||
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
|
|
||||||
@ -12,13 +11,14 @@ export interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const AccountHeader: React.FC<Props> = ({ account }) => {
|
const AccountHeader: React.FC<Props> = ({ account }) => {
|
||||||
const { colors } = useTheme()
|
|
||||||
const topInset = useSafeAreaInsets().top
|
const topInset = useSafeAreaInsets().top
|
||||||
|
|
||||||
useSelector(getInstanceActive)
|
useSelector(getInstanceActive)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<GracefullyImage
|
||||||
|
uri={{ original: account?.header, static: account?.header_static }}
|
||||||
|
style={{ height: Dimensions.get('window').width / 3 + topInset }}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (account) {
|
if (account) {
|
||||||
Image.getSize(account.header, (width, height) =>
|
Image.getSize(account.header, (width, height) =>
|
||||||
@ -30,15 +30,7 @@ const AccountHeader: React.FC<Props> = ({ account }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
|
||||||
<GracefullyImage
|
|
||||||
uri={{ original: account?.header, static: account?.header_static }}
|
|
||||||
style={{
|
|
||||||
height: Dimensions.get('window').width / 3 + topInset,
|
|
||||||
backgroundColor: colors.disabled
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</Pressable>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,7 @@ export interface Props {
|
|||||||
account: Mastodon.Account | undefined
|
account: Mastodon.Account | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const AccountInformation = React.memo(
|
const AccountInformation: React.FC<Props> = ({ account }) => {
|
||||||
({ account }: Props) => {
|
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
|
|
||||||
const { name } = useRoute()
|
const { name } = useRoute()
|
||||||
@ -50,18 +49,7 @@ const AccountInformation = React.memo(
|
|||||||
</Placeholder>
|
</Placeholder>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
(prev, next) => {
|
|
||||||
let skipUpdate = true
|
|
||||||
if (prev.account?.id !== next.account?.id) {
|
|
||||||
skipUpdate = false
|
|
||||||
}
|
|
||||||
if (prev.account?.acct === next.account?.acct) {
|
|
||||||
skipUpdate = false
|
|
||||||
}
|
|
||||||
return skipUpdate
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
base: {
|
base: {
|
||||||
|
@ -6,7 +6,6 @@ import { TabLocalStackParamList } from '@utils/navigation/navigators'
|
|||||||
import { getInstanceActive } from '@utils/slices/instancesSlice'
|
import { getInstanceActive } from '@utils/slices/instancesSlice'
|
||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Pressable } from 'react-native'
|
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
@ -18,7 +17,15 @@ const AccountInformationAvatar: React.FC<Props> = ({ account, myInfo }) => {
|
|||||||
const navigation = useNavigation<StackNavigationProp<TabLocalStackParamList>>()
|
const navigation = useNavigation<StackNavigationProp<TabLocalStackParamList>>()
|
||||||
useSelector(getInstanceActive)
|
useSelector(getInstanceActive)
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<GracefullyImage
|
||||||
|
key={account?.avatar}
|
||||||
|
style={{
|
||||||
|
borderRadius: 8,
|
||||||
|
overflow: 'hidden',
|
||||||
|
width: StyleConstants.Avatar.L,
|
||||||
|
height: StyleConstants.Avatar.L
|
||||||
|
}}
|
||||||
|
uri={{ original: account?.avatar, static: account?.avatar_static }}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (account) {
|
if (account) {
|
||||||
if (myInfo) {
|
if (myInfo) {
|
||||||
@ -33,19 +40,7 @@ const AccountInformationAvatar: React.FC<Props> = ({ account, myInfo }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
style={{
|
|
||||||
borderRadius: 8,
|
|
||||||
overflow: 'hidden',
|
|
||||||
width: StyleConstants.Avatar.L,
|
|
||||||
height: StyleConstants.Avatar.L
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<GracefullyImage
|
|
||||||
key={account?.avatar}
|
|
||||||
style={{ flex: 1 }}
|
|
||||||
uri={{ original: account?.avatar, static: account?.avatar_static }}
|
|
||||||
/>
|
/>
|
||||||
</Pressable>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user