1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Improve handling unknown attachment format

This commit is contained in:
Zhiyuan Zheng
2021-04-01 01:11:12 +02:00
parent 0644c51a7a
commit 965bab4822
3 changed files with 67 additions and 24 deletions

View File

@ -274,12 +274,6 @@ const styles = StyleSheet.create({
...StyleConstants.FontStyle.M, ...StyleConstants.FontStyle.M,
marginRight: StyleConstants.Spacing.M marginRight: StyleConstants.Spacing.M
}, },
privateInstance: {
...StyleConstants.FontStyle.S,
fontWeight: StyleConstants.Font.Weight.Bold,
marginLeft: StyleConstants.Spacing.Global.PagePadding,
marginTop: StyleConstants.Spacing.XS
},
instanceStats: { instanceStats: {
flex: 1, flex: 1,
flexDirection: 'row' flexDirection: 'row'

View File

@ -95,15 +95,46 @@ const TimelineAttachment = React.memo(
/> />
) )
default: default:
return ( if (
<AttachmentUnsupported attachment.preview_url.endsWith('.jpg') ||
key={index} attachment.preview_url.endsWith('.jpeg') ||
total={status.media_attachments.length} attachment.preview_url.endsWith('.png') ||
index={index} attachment.preview_url.endsWith('.gif') ||
sensitiveShown={sensitiveShown} attachment.remote_url?.endsWith('.jpg') ||
attachment={attachment} attachment.remote_url?.endsWith('.jpeg') ||
/> attachment.remote_url?.endsWith('.png') ||
) attachment.remote_url?.endsWith('.gif')
) {
imageUrls.push({
id: attachment.id,
url: attachment.url,
remote_url: attachment.remote_url,
blurhash: attachment.blurhash,
width: attachment.meta?.original?.width,
height: attachment.meta?.original?.height
})
return (
<AttachmentImage
key={index}
total={status.media_attachments.length}
index={index}
sensitiveShown={sensitiveShown}
// @ts-ignore
image={attachment}
navigateToImagesViewer={navigateToImagesViewer}
/>
)
} else {
return (
<AttachmentUnsupported
key={index}
total={status.media_attachments.length}
index={index}
sensitiveShown={sensitiveShown}
attachment={attachment}
/>
)
}
} }
}), }),
[sensitiveShown] [sensitiveShown]

View File

@ -81,25 +81,35 @@ const TabSharedSearch: React.FC<SharedSearchProp> = ({
components={{ bold: <Text style={styles.emptyFontBold} /> }} components={{ bold: <Text style={styles.emptyFontBold} /> }}
/> />
</Text> </Text>
<Text style={[styles.emptyAdvanced, { color: theme.primaryDefault }]}> <Text
style={[styles.emptyAdvanced, { color: theme.primaryDefault }]}
>
{t('shared.search.empty.advanced.header')} {t('shared.search.empty.advanced.header')}
</Text> </Text>
<Text style={[styles.emptyAdvanced, { color: theme.primaryDefault }]}> <Text
style={[styles.emptyAdvanced, { color: theme.primaryDefault }]}
>
<Text style={{ color: theme.secondary }}>@username@domain</Text> <Text style={{ color: theme.secondary }}>@username@domain</Text>
{' '} {' '}
{t('shared.search.empty.advanced.example.account')} {t('shared.search.empty.advanced.example.account')}
</Text> </Text>
<Text style={[styles.emptyAdvanced, { color: theme.primaryDefault }]}> <Text
style={[styles.emptyAdvanced, { color: theme.primaryDefault }]}
>
<Text style={{ color: theme.secondary }}>#example</Text> <Text style={{ color: theme.secondary }}>#example</Text>
{' '} {' '}
{t('shared.search.empty.advanced.example.hashtag')} {t('shared.search.empty.advanced.example.hashtag')}
</Text> </Text>
<Text style={[styles.emptyAdvanced, { color: theme.primaryDefault }]}> <Text
style={[styles.emptyAdvanced, { color: theme.primaryDefault }]}
>
<Text style={{ color: theme.secondary }}>URL</Text> <Text style={{ color: theme.secondary }}>URL</Text>
{' '} {' '}
{t('shared.search.empty.advanced.example.statusLink')} {t('shared.search.empty.advanced.example.statusLink')}
</Text> </Text>
<Text style={[styles.emptyAdvanced, { color: theme.primaryDefault }]}> <Text
style={[styles.emptyAdvanced, { color: theme.primaryDefault }]}
>
<Text style={{ color: theme.secondary }}>URL</Text> <Text style={{ color: theme.secondary }}>URL</Text>
{' '} {' '}
{t('shared.search.empty.advanced.example.accountLink')} {t('shared.search.empty.advanced.example.accountLink')}
@ -113,9 +123,14 @@ const TabSharedSearch: React.FC<SharedSearchProp> = ({
const sectionHeader = useCallback( const sectionHeader = useCallback(
({ section: { translation } }) => ( ({ section: { translation } }) => (
<View <View
style={[styles.sectionHeader, { backgroundColor: theme.backgroundDefault }]} style={[
styles.sectionHeader,
{ backgroundColor: theme.backgroundDefault }
]}
> >
<Text style={[styles.sectionHeaderText, { color: theme.primaryDefault }]}> <Text
style={[styles.sectionHeaderText, { color: theme.primaryDefault }]}
>
{translation} {translation}
</Text> </Text>
</View> </View>
@ -126,11 +141,14 @@ const TabSharedSearch: React.FC<SharedSearchProp> = ({
({ section: { data, translation } }) => ({ section: { data, translation } }) =>
!data.length ? ( !data.length ? (
<View <View
style={[styles.sectionFooter, { backgroundColor: theme.backgroundDefault }]} style={[
styles.sectionFooter,
{ backgroundColor: theme.backgroundDefault }
]}
> >
<Text style={[styles.sectionFooterText, { color: theme.secondary }]}> <Text style={[styles.sectionFooterText, { color: theme.secondary }]}>
<Trans <Trans
i18nKey='sharedSearch:content.notFound' i18nKey='screenTabs:shared.search.notFound'
values={{ searchTerm: text, type: translation }} values={{ searchTerm: text, type: translation }}
components={{ bold: <Text style={styles.emptyFontBold} /> }} components={{ bold: <Text style={styles.emptyFontBold} /> }}
/> />