From 8e93492ae399aac1838cd4370ab94f73f45bf253 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Tue, 29 Dec 2020 12:33:22 +0100 Subject: [PATCH] Fixed https://sentry.io/organizations/xmflsct/issues/2117728637/ --- src/components/ParseContent.tsx | 26 ++++++++----------- .../Timelines/Timeline/Shared/Emojis.tsx | 2 +- .../Shared/HeaderDefault/ActionsAccount.tsx | 2 +- src/screens/Shared/Account.tsx | 2 +- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/components/ParseContent.tsx b/src/components/ParseContent.tsx index 63ef7c25..df74d7b0 100644 --- a/src/components/ParseContent.tsx +++ b/src/components/ParseContent.tsx @@ -54,21 +54,19 @@ const renderNode = ({ ) } else if (classes.includes('mention') && mentions) { + const accountIndex = mentions.findIndex(mention => mention.url === href) return ( { - const username = href.split(new RegExp(/@(.*)/)) - const usernameIndex = mentions.findIndex( - m => m.username === username[1] - ) - navigation.push('Screen-Shared-Account', { - account: mentions[usernameIndex] - }) + accountIndex !== -1 && + navigation.push('Screen-Shared-Account', { + account: mentions[accountIndex] + }) }} > {node.children[0].data} @@ -97,13 +95,11 @@ const renderNode = ({ } > {!shouldBeTag ? ( - <> - {' '} - + ) : null} {content || (showFullLink ? href : domain[1])} diff --git a/src/components/Timelines/Timeline/Shared/Emojis.tsx b/src/components/Timelines/Timeline/Shared/Emojis.tsx index 0f17c443..2028ab6b 100644 --- a/src/components/Timelines/Timeline/Shared/Emojis.tsx +++ b/src/components/Timelines/Timeline/Shared/Emojis.tsx @@ -3,7 +3,7 @@ import { Image, StyleSheet, Text } from 'react-native' import { useTheme } from '@utils/styles/ThemeManager' import { StyleConstants } from '@utils/styles/constants' -const regexEmoji = new RegExp(/(:[a-z0-9_]+:)/) +const regexEmoji = new RegExp(/(:[A-Za-z0-9_]+:)/) export interface Props { content: string diff --git a/src/components/Timelines/Timeline/Shared/HeaderDefault/ActionsAccount.tsx b/src/components/Timelines/Timeline/Shared/HeaderDefault/ActionsAccount.tsx index b0c85413..aa00ab7f 100644 --- a/src/components/Timelines/Timeline/Shared/HeaderDefault/ActionsAccount.tsx +++ b/src/components/Timelines/Timeline/Shared/HeaderDefault/ActionsAccount.tsx @@ -57,7 +57,7 @@ const fireMutation = async ({ export interface Props { queryKey?: QueryKey.Timeline - account: Mastodon.Account + account: Pick setBottomSheetVisible: React.Dispatch> } diff --git a/src/screens/Shared/Account.tsx b/src/screens/Shared/Account.tsx index b9e7b2bc..0d119af2 100644 --- a/src/screens/Shared/Account.tsx +++ b/src/screens/Shared/Account.tsx @@ -20,7 +20,7 @@ import layoutAnimation from '@root/utils/styles/layoutAnimation' export interface Props { route: { params: { - account: Mastodon.Account + account: Pick } } navigation: any