mirror of https://github.com/tooot-app/app
Fixed #397
This commit is contained in:
parent
bd970ec287
commit
52c44c600c
|
@ -76,9 +76,7 @@ const renderNode = ({
|
||||||
</CustomText>
|
</CustomText>
|
||||||
)
|
)
|
||||||
} else if (classes.includes('mention') && mentions) {
|
} else if (classes.includes('mention') && mentions) {
|
||||||
const accountIndex = mentions.findIndex(
|
const accountIndex = mentions.findIndex(mention => mention.url === href)
|
||||||
mention => mention.url === href
|
|
||||||
)
|
|
||||||
const differentAccount = routeParams?.account
|
const differentAccount = routeParams?.account
|
||||||
? routeParams.account.id !== mentions[accountIndex]?.id
|
? routeParams.account.id !== mentions[accountIndex]?.id
|
||||||
: true
|
: true
|
||||||
|
@ -86,8 +84,7 @@ const renderNode = ({
|
||||||
<CustomText
|
<CustomText
|
||||||
key={index}
|
key={index}
|
||||||
style={{
|
style={{
|
||||||
color:
|
color: accountIndex !== -1 ? colors.blue : colors.primaryDefault,
|
||||||
accountIndex !== -1 ? colors.blue : colors.primaryDefault,
|
|
||||||
fontSize: adaptedFontsize,
|
fontSize: adaptedFontsize,
|
||||||
lineHeight: adaptedLineheight
|
lineHeight: adaptedLineheight
|
||||||
}}
|
}}
|
||||||
|
@ -109,10 +106,8 @@ const renderNode = ({
|
||||||
} else {
|
} else {
|
||||||
const domain = href?.split(new RegExp(/:\/\/(.[^\/]+)/))
|
const domain = href?.split(new RegExp(/:\/\/(.[^\/]+)/))
|
||||||
// Need example here
|
// Need example here
|
||||||
const content =
|
const content = node.children && node.children[0] && node.children[0].data
|
||||||
node.children && node.children[0] && node.children[0].data
|
const shouldBeTag = tags && tags.filter(tag => `#${tag.name}` === content).length > 0
|
||||||
const shouldBeTag =
|
|
||||||
tags && tags.filter(tag => `#${tag.name}` === content).length > 0
|
|
||||||
return (
|
return (
|
||||||
<CustomText
|
<CustomText
|
||||||
key={index}
|
key={index}
|
||||||
|
@ -135,8 +130,7 @@ const renderNode = ({
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{(content && content !== href && content) ||
|
{(content && content !== href && content) || (showFullLink ? href : domain[1])}
|
||||||
(showFullLink ? href : domain[1])}
|
|
||||||
{!shouldBeTag ? (
|
{!shouldBeTag ? (
|
||||||
<Icon
|
<Icon
|
||||||
color={colors.blue}
|
color={colors.blue}
|
||||||
|
@ -205,8 +199,7 @@ const ParseHTML = React.memo(
|
||||||
adaptiveSize ? adaptiveFontsize : 0
|
adaptiveSize ? adaptiveFontsize : 0
|
||||||
)
|
)
|
||||||
|
|
||||||
const navigation =
|
const navigation = useNavigation<StackNavigationProp<TabLocalStackParamList>>()
|
||||||
useNavigation<StackNavigationProp<TabLocalStackParamList>>()
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { colors, theme } = useTheme()
|
const { colors, theme } = useTheme()
|
||||||
const { t, i18n } = useTranslation('componentParse')
|
const { t, i18n } = useTranslation('componentParse')
|
||||||
|
@ -254,7 +247,7 @@ const ParseHTML = React.memo(
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{ overflow: 'hidden' }}>
|
<View style={{ overflow: 'hidden' }}>
|
||||||
{typeof totalLines === 'number' ? (
|
{typeof totalLines === 'number' || numberOfLines === 1 ? (
|
||||||
<Pressable
|
<Pressable
|
||||||
accessibilityLabel={t('HTML.accessibilityHint')}
|
accessibilityLabel={t('HTML.accessibilityHint')}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
@ -296,10 +289,7 @@ const ParseHTML = React.memo(
|
||||||
<CustomText
|
<CustomText
|
||||||
children={children}
|
children={children}
|
||||||
onTextLayout={({ nativeEvent }) => {
|
onTextLayout={({ nativeEvent }) => {
|
||||||
if (
|
if (numberOfLines === 1 || nativeEvent.lines.length >= numberOfLines + 5) {
|
||||||
numberOfLines === 1 ||
|
|
||||||
nativeEvent.lines.length >= numberOfLines + 5
|
|
||||||
) {
|
|
||||||
setTotalLines(nativeEvent.lines.length)
|
setTotalLines(nativeEvent.lines.length)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
@ -307,11 +297,7 @@ const ParseHTML = React.memo(
|
||||||
height: numberOfLines === 1 && !expanded ? 0 : undefined
|
height: numberOfLines === 1 && !expanded ? 0 : undefined
|
||||||
}}
|
}}
|
||||||
numberOfLines={
|
numberOfLines={
|
||||||
typeof totalLines === 'number'
|
typeof totalLines === 'number' ? (expanded ? 999 : numberOfLines) : undefined
|
||||||
? expanded
|
|
||||||
? 999
|
|
||||||
: numberOfLines
|
|
||||||
: undefined
|
|
||||||
}
|
}
|
||||||
selectable={selectable}
|
selectable={selectable}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -9,18 +9,12 @@ export interface Props {
|
||||||
mentions?: Mastodon.Status['mentions']
|
mentions?: Mastodon.Status['mentions']
|
||||||
tags?: Mastodon.Status['tags']
|
tags?: Mastodon.Status['tags']
|
||||||
}
|
}
|
||||||
numberOfLines?: number
|
|
||||||
highlighted?: boolean
|
highlighted?: boolean
|
||||||
disableDetails?: boolean
|
disableDetails?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const TimelineContent = React.memo(
|
const TimelineContent = React.memo(
|
||||||
({
|
({ status, highlighted = false, disableDetails = false }: Props) => {
|
||||||
status,
|
|
||||||
numberOfLines,
|
|
||||||
highlighted = false,
|
|
||||||
disableDetails = false
|
|
||||||
}: Props) => {
|
|
||||||
const { t } = useTranslation('componentTimeline')
|
const { t } = useTranslation('componentTimeline')
|
||||||
const instanceAccount = useSelector(getInstanceAccount, () => true)
|
const instanceAccount = useSelector(getInstanceAccount, () => true)
|
||||||
|
|
||||||
|
@ -46,9 +40,7 @@ const TimelineContent = React.memo(
|
||||||
emojis={status.emojis}
|
emojis={status.emojis}
|
||||||
mentions={status.mentions}
|
mentions={status.mentions}
|
||||||
tags={status.tags}
|
tags={status.tags}
|
||||||
numberOfLines={
|
numberOfLines={instanceAccount.preferences['reading:expand:spoilers'] ? 999 : 1}
|
||||||
instanceAccount.preferences['reading:expand:spoilers'] ? 999 : 1
|
|
||||||
}
|
|
||||||
expandHint={t('shared.content.expandHint')}
|
expandHint={t('shared.content.expandHint')}
|
||||||
highlighted={highlighted}
|
highlighted={highlighted}
|
||||||
disableDetails={disableDetails}
|
disableDetails={disableDetails}
|
||||||
|
@ -62,7 +54,7 @@ const TimelineContent = React.memo(
|
||||||
emojis={status.emojis}
|
emojis={status.emojis}
|
||||||
mentions={status.mentions}
|
mentions={status.mentions}
|
||||||
tags={status.tags}
|
tags={status.tags}
|
||||||
numberOfLines={highlighted ? 999 : numberOfLines}
|
numberOfLines={highlighted ? 999 : undefined}
|
||||||
disableDetails={disableDetails}
|
disableDetails={disableDetails}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in New Issue