mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
fix link preview with null image asset causing crash
This commit is contained in:
@@ -4,7 +4,7 @@ import { getStyle } from './functions';
|
||||
|
||||
|
||||
export const Photo = ({src, style = {}}) => {
|
||||
return (
|
||||
return src ?(
|
||||
<Image
|
||||
source={{uri: src}}
|
||||
resizeMode="cover"
|
||||
@@ -15,5 +15,5 @@ export const Photo = ({src, style = {}}) => {
|
||||
...getStyle(style)
|
||||
}}
|
||||
/>
|
||||
);
|
||||
) : null
|
||||
};
|
||||
@@ -34,12 +34,14 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
|
||||
};
|
||||
setLink(prevLink);
|
||||
})
|
||||
.catch(e => console.log);
|
||||
.catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
}, [value]);
|
||||
|
||||
const renderImage = (imageLink, faviconLink) => {
|
||||
return imageLink ? (
|
||||
const renderImage = image => {
|
||||
return image ? (
|
||||
<Image
|
||||
style={{
|
||||
width: 35,
|
||||
@@ -52,26 +54,8 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
|
||||
marginRight: 5
|
||||
}}
|
||||
resizeMode="contain"
|
||||
source={{uri: imageLink}}
|
||||
source={{uri: image}}
|
||||
/>
|
||||
) : faviconLink ? (
|
||||
<View
|
||||
style={{
|
||||
borderColor: colors.nav,
|
||||
backgroundColor: colors.nav,
|
||||
borderWidth: 1,
|
||||
marginVertical: 5,
|
||||
borderRadius: 5
|
||||
}}>
|
||||
<Image
|
||||
style={{
|
||||
width: 35,
|
||||
height: 35
|
||||
}}
|
||||
resizeMode="center"
|
||||
source={{uri: faviconLink}}
|
||||
/>
|
||||
</View>
|
||||
) : (
|
||||
<View
|
||||
style={{
|
||||
@@ -80,7 +64,7 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
|
||||
marginVertical: 5,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: colors.shade,
|
||||
backgroundColor: colors.nav,
|
||||
borderRadius: 5
|
||||
}}>
|
||||
<Icon size={35} color={colors.accent} name="web" />
|
||||
@@ -163,7 +147,7 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
|
||||
width: '100%',
|
||||
alignItems: 'center'
|
||||
}}>
|
||||
{renderImage(link.image, link.favicon)}
|
||||
{renderImage(link.image)}
|
||||
{renderText(link.name, link.title, link.description)}
|
||||
|
||||
<View
|
||||
|
||||
Reference in New Issue
Block a user