Add broken URI handling

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2023-07-26 16:10:45 +03:00
parent 083e798fdf
commit acba17462f
17 changed files with 370 additions and 91 deletions

View File

@@ -5,6 +5,7 @@ import Share from 'react-native-share';
import Clipboard from '@react-native-clipboard/clipboard';
import { Meme } from '../database';
import { ROUTE, RootStackParamList } from '../types';
import { noOp } from './constants';
const favoriteMeme = (realm: Realm, meme: Meme) => {
realm.write(() => {
@@ -23,7 +24,9 @@ const shareMeme = async (meme: Meme) => {
});
};
const copyMeme = (meme: Meme) => {
const copyMeme = async (meme: Meme) => {
const exists = await FileSystem.exists(meme.uri);
if (!exists) throw new Error('File does not exist');
Clipboard.setURI(meme.uri);
};
@@ -35,7 +38,7 @@ const editMeme = (
};
const deleteMeme = async (realm: Realm, meme: Meme) => {
await FileSystem.unlink(meme.uri);
await FileSystem.unlink(meme.uri).catch(noOp);
realm.write(() => {
for (const tag of meme.tags) {