Add broken URI handling
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -1,9 +1,35 @@
|
||||
const getFlashListItemHeight = (numColumns: number) => {
|
||||
const A = 500;
|
||||
const B = 300;
|
||||
const C = 1;
|
||||
const height = A - B * Math.log(numColumns + C);
|
||||
return Math.max(Math.round(height), 0);
|
||||
switch (numColumns) {
|
||||
case 1: {
|
||||
return 350;
|
||||
}
|
||||
case 2: {
|
||||
return 180;
|
||||
}
|
||||
case 3: {
|
||||
return 120;
|
||||
}
|
||||
case 4: {
|
||||
return 90;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export { getFlashListItemHeight };
|
||||
const getFontAwesome5IconSize = (numColumns: number) => {
|
||||
switch (numColumns) {
|
||||
case 1: {
|
||||
return 40;
|
||||
}
|
||||
case 2: {
|
||||
return 30;
|
||||
}
|
||||
case 3: {
|
||||
return 20;
|
||||
}
|
||||
case 4: {
|
||||
return 14;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export { getFlashListItemHeight, getFontAwesome5IconSize };
|
||||
|
@@ -11,7 +11,7 @@ const allowedGifMimeTypes = ['image/gif'];
|
||||
|
||||
const allowedMimeTypes = [...allowedImageMimeTypes, ...allowedGifMimeTypes];
|
||||
|
||||
const getMemeType = (mimeType: string) => {
|
||||
const getMemeType = (mimeType: string): MEME_TYPE | undefined => {
|
||||
switch (mimeType) {
|
||||
case 'image/bmp':
|
||||
case 'image/jpeg':
|
||||
|
@@ -8,7 +8,7 @@ export {
|
||||
} from './color';
|
||||
export { packageName, appName, fileProvider, noOp } from './constants';
|
||||
export { multipleIdQuery } from './database';
|
||||
export { getFlashListItemHeight } from './dimensions';
|
||||
export { getFlashListItemHeight, getFontAwesome5IconSize } from './dimensions';
|
||||
export {
|
||||
allowedImageMimeTypes,
|
||||
allowedGifMimeTypes,
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user