mirror of
https://github.com/tooot-app/app
synced 2025-04-15 18:57:39 +02:00
Try to fix RNFI crash
https://github.com/DylanVann/react-native-fast-image/pull/782
This commit is contained in:
parent
d7f1c87c9b
commit
0644c51a7a
@ -1,5 +1,5 @@
|
|||||||
# [tooot](https://tooot.app/) app for Mastodon
|
# [tooot](https://tooot.app/) app for Mastodon
|
||||||
|
|
||||||
[](LICENSE)   
|
[](LICENSE)    [](https://crowdin.tooot.app/project/tooot)
|
||||||
|
|
||||||
  
|
  
|
||||||
|
@ -83,7 +83,8 @@
|
|||||||
"redux-persist": "^6.0.0",
|
"redux-persist": "^6.0.0",
|
||||||
"rn-placeholder": "^3.0.3",
|
"rn-placeholder": "^3.0.3",
|
||||||
"sentry-expo": "^3.0.5",
|
"sentry-expo": "^3.0.5",
|
||||||
"tslib": "^2.1.0"
|
"tslib": "^2.1.0",
|
||||||
|
"valid-url": "^1.0.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "~7.13.10",
|
"@babel/core": "~7.13.10",
|
||||||
@ -103,6 +104,7 @@
|
|||||||
"@types/react-redux": "^7.1.16",
|
"@types/react-redux": "^7.1.16",
|
||||||
"@types/react-test-renderer": "^17.0.1",
|
"@types/react-test-renderer": "^17.0.1",
|
||||||
"@types/react-timeago": "^4.1.2",
|
"@types/react-timeago": "^4.1.2",
|
||||||
|
"@types/valid-url": "^1.0.3",
|
||||||
"@welldone-software/why-did-you-render": "^6.1.1",
|
"@welldone-software/why-did-you-render": "^6.1.1",
|
||||||
"babel-jest": "~26.6.3",
|
"babel-jest": "~26.6.3",
|
||||||
"babel-plugin-module-resolver": "^4.1.0",
|
"babel-plugin-module-resolver": "^4.1.0",
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { StyleConstants } from '@utils/styles/constants'
|
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import React, { useCallback, useMemo, useRef, useState } from 'react'
|
import React, { useCallback, useMemo, useRef, useState } from 'react'
|
||||||
import {
|
import {
|
||||||
|
@ -7,6 +7,7 @@ import React, { useMemo } from 'react'
|
|||||||
import { StyleSheet, Text } from 'react-native'
|
import { StyleSheet, Text } from 'react-native'
|
||||||
import FastImage from 'react-native-fast-image'
|
import FastImage from 'react-native-fast-image'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
|
import validUrl from 'valid-url'
|
||||||
|
|
||||||
const regexEmoji = new RegExp(/(:[A-Za-z0-9_]+:)/)
|
const regexEmoji = new RegExp(/(:[A-Za-z0-9_]+:)/)
|
||||||
|
|
||||||
@ -67,25 +68,30 @@ const ParseEmojis = React.memo(
|
|||||||
const emojiIndex = emojis.findIndex(emoji => {
|
const emojiIndex = emojis.findIndex(emoji => {
|
||||||
return emojiShortcode === `:${emoji.shortcode}:`
|
return emojiShortcode === `:${emoji.shortcode}:`
|
||||||
})
|
})
|
||||||
return emojiIndex === -1 ? (
|
if (emojiIndex === -1) {
|
||||||
<Text key={i}>{emojiShortcode}</Text>
|
return <Text>{emojiShortcode}</Text>
|
||||||
) : (
|
} else {
|
||||||
<Text key={i}>
|
if (i === 0) {
|
||||||
{/* When emoji starts a paragraph, lineHeight will break */}
|
return <Text key={emojiShortcode}> </Text>
|
||||||
{i === 0 ? <Text> </Text> : null}
|
} else {
|
||||||
<FastImage
|
const uri = reduceMotionEnabled
|
||||||
key={adaptiveFontsize}
|
|
||||||
source={{
|
|
||||||
uri: reduceMotionEnabled
|
|
||||||
? emojis[emojiIndex].static_url
|
? emojis[emojiIndex].static_url
|
||||||
: emojis[emojiIndex].url
|
: emojis[emojiIndex].url
|
||||||
}}
|
if (validUrl.isHttpsUri(uri)) {
|
||||||
|
return (
|
||||||
|
<FastImage
|
||||||
|
key={emojiShortcode}
|
||||||
|
source={{ uri }}
|
||||||
style={styles.image}
|
style={styles.image}
|
||||||
/>
|
/>
|
||||||
</Text>
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return <Text key={i}>{str}</Text>
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return <Text key={str}>{str}</Text>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
) : (
|
) : (
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import analytics from '@components/analytics'
|
import analytics from '@components/analytics'
|
||||||
import haptics from '@components/haptics'
|
import haptics from '@components/haptics'
|
||||||
|
import { useAccessibility } from '@utils/accessibility/AccessibilityManager'
|
||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import React, { useCallback, useContext, useMemo } from 'react'
|
import React, { useCallback, useContext, useMemo } from 'react'
|
||||||
import { Pressable, SectionList, StyleSheet, Text, View } from 'react-native'
|
import { Pressable, SectionList, StyleSheet, Text, View } from 'react-native'
|
||||||
import ComposeContext from '../../utils/createContext'
|
|
||||||
import updateText from '../../updateText'
|
|
||||||
import FastImage from 'react-native-fast-image'
|
import FastImage from 'react-native-fast-image'
|
||||||
import { useAccessibility } from '@utils/accessibility/AccessibilityManager'
|
import validUrl from 'valid-url'
|
||||||
|
import updateText from '../../updateText'
|
||||||
|
import ComposeContext from '../../utils/createContext'
|
||||||
|
|
||||||
const SingleEmoji = ({ emoji }: { emoji: Mastodon.Emoji }) => {
|
const SingleEmoji = ({ emoji }: { emoji: Mastodon.Emoji }) => {
|
||||||
const { reduceMotionEnabled } = useAccessibility()
|
const { reduceMotionEnabled } = useAccessibility()
|
||||||
@ -21,21 +22,21 @@ const SingleEmoji = ({ emoji }: { emoji: Mastodon.Emoji }) => {
|
|||||||
newText: `:${emoji.shortcode}:`,
|
newText: `:${emoji.shortcode}:`,
|
||||||
type: 'emoji'
|
type: 'emoji'
|
||||||
})
|
})
|
||||||
// composeDispatch({
|
|
||||||
// type: 'emoji',
|
|
||||||
// payload: { ...composeState.emoji, active: false }
|
|
||||||
// })
|
|
||||||
haptics('Light')
|
haptics('Light')
|
||||||
}, [composeState])
|
}, [composeState])
|
||||||
const children = useMemo(
|
const children = useMemo(() => {
|
||||||
() => (
|
const uri = reduceMotionEnabled ? emoji.static_url : emoji.url
|
||||||
|
if (validUrl.isHttpsUri(uri)) {
|
||||||
|
return (
|
||||||
<FastImage
|
<FastImage
|
||||||
source={{ uri: reduceMotionEnabled ? emoji.static_url : emoji.url }}
|
source={{ uri: reduceMotionEnabled ? emoji.static_url : emoji.url }}
|
||||||
style={styles.emoji}
|
style={styles.emoji}
|
||||||
/>
|
/>
|
||||||
),
|
|
||||||
[]
|
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
return (
|
return (
|
||||||
<Pressable key={emoji.shortcode} onPress={onPress} children={children} />
|
<Pressable key={emoji.shortcode} onPress={onPress} children={children} />
|
||||||
)
|
)
|
||||||
|
10
yarn.lock
10
yarn.lock
@ -2798,6 +2798,11 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.0.tgz#7036640b4e21cc2f259ae826ce843d277dad8cff"
|
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.0.tgz#7036640b4e21cc2f259ae826ce843d277dad8cff"
|
||||||
integrity sha512-RJJrrySY7A8havqpGObOB4W92QXKJo63/jFLLgpvOtsGUqbQZ9Sbgl35KMm1DjC6j7AvmmU2bIno+3IyEaemaw==
|
integrity sha512-RJJrrySY7A8havqpGObOB4W92QXKJo63/jFLLgpvOtsGUqbQZ9Sbgl35KMm1DjC6j7AvmmU2bIno+3IyEaemaw==
|
||||||
|
|
||||||
|
"@types/valid-url@^1.0.3":
|
||||||
|
version "1.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/valid-url/-/valid-url-1.0.3.tgz#a124389fb953559c7f889795a98620e91adb3687"
|
||||||
|
integrity sha512-+33x29mg+ecU88ODdWpqaie2upIuRkhujVLA7TuJjM823cNMbeggfI6NhxewaRaRF8dy+g33e4uIg/m5Mb3xDQ==
|
||||||
|
|
||||||
"@types/yargs-parser@*":
|
"@types/yargs-parser@*":
|
||||||
version "20.2.0"
|
version "20.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-20.2.0.tgz#dd3e6699ba3237f0348cd085e4698780204842f9"
|
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-20.2.0.tgz#dd3e6699ba3237f0348cd085e4698780204842f9"
|
||||||
@ -10463,6 +10468,11 @@ v8-to-istanbul@^7.0.0:
|
|||||||
convert-source-map "^1.6.0"
|
convert-source-map "^1.6.0"
|
||||||
source-map "^0.7.3"
|
source-map "^0.7.3"
|
||||||
|
|
||||||
|
valid-url@^1.0.9:
|
||||||
|
version "1.0.9"
|
||||||
|
resolved "https://registry.yarnpkg.com/valid-url/-/valid-url-1.0.9.tgz#1c14479b40f1397a75782f115e4086447433a200"
|
||||||
|
integrity sha1-HBRHm0DxOXp1eC8RXkCGRHQzogA=
|
||||||
|
|
||||||
validate-npm-package-license@^3.0.1:
|
validate-npm-package-license@^3.0.1:
|
||||||
version "3.0.4"
|
version "3.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a"
|
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user