Improve handling unknown attachment format

This commit is contained in:
Zhiyuan Zheng 2021-04-01 01:11:12 +02:00
parent 0644c51a7a
commit 965bab4822
No known key found for this signature in database
GPG Key ID: 078A93AB607D85E0
3 changed files with 67 additions and 24 deletions

View File

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

View File

@ -95,15 +95,46 @@ const TimelineAttachment = React.memo(
/>
)
default:
return (
<AttachmentUnsupported
key={index}
total={status.media_attachments.length}
index={index}
sensitiveShown={sensitiveShown}
attachment={attachment}
/>
)
if (
attachment.preview_url.endsWith('.jpg') ||
attachment.preview_url.endsWith('.jpeg') ||
attachment.preview_url.endsWith('.png') ||
attachment.preview_url.endsWith('.gif') ||
attachment.remote_url?.endsWith('.jpg') ||
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]

View File

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