Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

minor improvements to link preview

ammarahm-ed0394432da017
diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/linkpreview.js b/apps/mobile/src/views/Editor/tiny/toolbar/linkpreview.js
index aa6dc765b..9c7b1116a 100644
--- a/apps/mobile/src/views/Editor/tiny/toolbar/linkpreview.js
+++ b/apps/mobile/src/views/Editor/tiny/toolbar/linkpreview.js
@@ -1,14 +1,14 @@
-import { getLinkPreview } from 'link-preview-js';
-import React, { useEffect, useState } from 'react';
-import { Image, ScrollView, TouchableOpacity, View } from 'react-native';
+import {getLinkPreview} from 'link-preview-js';
+import React, {useEffect, useState} from 'react';
+import {Image, ScrollView, TouchableOpacity, View} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { ActionIcon } from '../../../../components/ActionIcon';
+import {ActionIcon} from '../../../../components/ActionIcon';
import Heading from '../../../../components/Typography/Heading';
import Paragraph from '../../../../components/Typography/Paragraph';
-import { useTracked } from '../../../../provider';
-import { openLinkInBrowser } from '../../../../utils/functions';
-import { SIZE } from '../../../../utils/SizeUtils';
-import { INPUT_MODE, properties, reFocusEditor } from './constants';
+import {useTracked} from '../../../../provider';
+import {openLinkInBrowser} from '../../../../utils/functions';
+import {SIZE} from '../../../../utils/SizeUtils';
+import {INPUT_MODE, properties, reFocusEditor} from './constants';
let prevLink = {};
let prevHeight = 50;
@@ -21,9 +21,8 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
useEffect(() => {
console.log('previewing', value);
if (value && prevLink.value !== value) {
-
getLinkPreview(value)
- .then((r) => {
+ .then(r => {
if (r.contentType?.includes('text/html')) {
prevLink = {
value: value,
@@ -31,12 +30,12 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
title: r.title,
description: r.description,
image: r.images[0],
- favicon: r.favicons[0],
+ favicon: r.favicons[0]
};
setLink(prevLink);
}
})
- .catch((e) => console.log);
+ .catch(e => console.log);
}
}, [value]);
@@ -50,9 +49,9 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
marginVertical: 5,
borderWidth: 1,
borderColor: colors.nav,
- backgroundColor: colors.nav,
+ backgroundColor: colors.nav
}}
- resizeMode="center"
+ resizeMode="contain"
source={{uri: imageLink}}
/>
) : faviconLink ? (
@@ -62,12 +61,12 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
backgroundColor: colors.nav,
borderWidth: 1,
marginVertical: 5,
- borderRadius: 5,
+ borderRadius: 5
}}>
<Image
style={{
width: height,
- height: height,
+ height: height
}}
resizeMode="center"
source={{uri: faviconLink}}
@@ -82,7 +81,7 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
justifyContent: 'center',
alignItems: 'center',
backgroundColor: colors.shade,
- borderRadius: 5,
+ borderRadius: 5
}}>
<Icon size={height - 4} color={colors.accent} name="web" />
</View>
@@ -91,8 +90,8 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
const openLink = () => {
openLinkInBrowser(value, colors)
- .catch((e) => {})
- .then(async (r) => {
+ .catch(e => {})
+ .then(async r => {
console.log('closed browser now');
await reFocusEditor();
});
@@ -101,17 +100,17 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
const renderText = (name, title, description) => {
return (
<View
- onLayout={(e) => {
+ onLayout={e => {
prevHeight = e.nativeEvent.layout.height;
e.nativeEvent && setHeight(prevHeight);
}}
style={{
- flex: 1,
+ flex: 1
}}>
<TouchableOpacity onPress={openLink} activeOpacity={1}>
<ScrollView
style={{
- marginRight: 10,
+ marginRight: 10
}}
horizontal
showsHorizontalScrollIndicator={false}>
@@ -142,7 +141,7 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
<View
style={{
flexDirection: 'row',
- alignItems: 'center',
+ alignItems: 'center'
}}>
<ActionIcon
onPress={() => {
@@ -150,10 +149,10 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
}}
customStyle={{
width: 40,
- marginHorizontal: 10,
- height: 40,
+ marginRight: 10,
+ height: 40
}}
- name="delete"
+ name="link-off"
size={SIZE.xl}
color={colors.pri}
/>
@@ -165,8 +164,7 @@ const LinkPreview = ({setMode, value, onSubmit}) => {
}}
customStyle={{
width: 40,
- marginHorizontal: 10,
- height: 40,
+ height: 40
}}
name="pencil"
size={SIZE.xl}