fixed crash on empty message

This commit is contained in:
Roland Osborne 2022-10-21 10:41:19 -07:00
parent a045156b64
commit 23e1c2aa9c
4 changed files with 15 additions and 12 deletions

View File

@ -136,8 +136,16 @@ export function useUploadContext() {
async function upload(entry, update, complete) {
if (!entry.files?.length) {
entry.success(entry.assets);
complete();
try {
await entry.success(entry.assets);
complete();
}
catch (err) {
console.log(err);
entry.failure();
entry.error = true;
update();
}
}
else {
const file = entry.files.shift();

View File

@ -9,13 +9,9 @@ export function ImageFile({ path, setPosition, remove }) {
const { state, actions } = useImageFile();
useEffect(() => {
Image.getSize(path, actions.setInfo);
}, [path]);
return (
<TouchableOpacity activeOpacity={1} onLongPress={remove}>
<Image source={{ uri: path }} style={{ width: 92 * state.ratio, height: 92, marginRight: 16 }} resizeMode={'cover'} />
<Image source={{ uri: path }} onLoad={actions.loaded} style={{ width: 92 * state.ratio, height: 92, marginRight: 16 }} resizeMode={'cover'} />
</TouchableOpacity>
);
}

View File

@ -12,7 +12,8 @@ export function useImageFile() {
}
const actions = {
setInfo: (width, height) => {
loaded: (e) => {
const { width, height } = e.nativeEvent.source;
updateState({ ratio: width / height });
},
};

View File

@ -83,7 +83,7 @@ export function useTopicItem(item, hosting, remove) {
}
}
let prased, message, assets, fontSize, fontColor;
let parsed, message, assets, fontSize, fontColor;
try {
parsed = JSON.parse(data);
message = parsed.text;
@ -104,9 +104,7 @@ export function useTopicItem(item, hosting, remove) {
fontColor = Colors.text;
}
}
catch (err) {
console.log("empty message");
}
catch (err) { }
let timestamp;