mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-18 12:47:50 +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 = {}}) => {
|
export const Photo = ({src, style = {}}) => {
|
||||||
return (
|
return src ?(
|
||||||
<Image
|
<Image
|
||||||
source={{uri: src}}
|
source={{uri: src}}
|
||||||
resizeMode="cover"
|
resizeMode="cover"
|
||||||
@@ -15,5 +15,5 @@ export const Photo = ({src, style = {}}) => {
|
|||||||
...getStyle(style)
|
...getStyle(style)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
) : null
|
||||||
};
|
};
|
||||||
@@ -34,12 +34,14 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
|
|||||||
};
|
};
|
||||||
setLink(prevLink);
|
setLink(prevLink);
|
||||||
})
|
})
|
||||||
.catch(e => console.log);
|
.catch(e => {
|
||||||
|
console.log(e);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [value]);
|
}, [value]);
|
||||||
|
|
||||||
const renderImage = (imageLink, faviconLink) => {
|
const renderImage = image => {
|
||||||
return imageLink ? (
|
return image ? (
|
||||||
<Image
|
<Image
|
||||||
style={{
|
style={{
|
||||||
width: 35,
|
width: 35,
|
||||||
@@ -52,26 +54,8 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
|
|||||||
marginRight: 5
|
marginRight: 5
|
||||||
}}
|
}}
|
||||||
resizeMode="contain"
|
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
|
<View
|
||||||
style={{
|
style={{
|
||||||
@@ -80,7 +64,7 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
|
|||||||
marginVertical: 5,
|
marginVertical: 5,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
backgroundColor: colors.shade,
|
backgroundColor: colors.nav,
|
||||||
borderRadius: 5
|
borderRadius: 5
|
||||||
}}>
|
}}>
|
||||||
<Icon size={35} color={colors.accent} name="web" />
|
<Icon size={35} color={colors.accent} name="web" />
|
||||||
@@ -163,7 +147,7 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
|
|||||||
width: '100%',
|
width: '100%',
|
||||||
alignItems: 'center'
|
alignItems: 'center'
|
||||||
}}>
|
}}>
|
||||||
{renderImage(link.image, link.favicon)}
|
{renderImage(link.image)}
|
||||||
{renderText(link.name, link.title, link.description)}
|
{renderText(link.name, link.title, link.description)}
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
|||||||
Reference in New Issue
Block a user