mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
fixed crash on empty message
This commit is contained in:
parent
a045156b64
commit
23e1c2aa9c
@ -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();
|
||||
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
@ -12,7 +12,8 @@ export function useImageFile() {
|
||||
}
|
||||
|
||||
const actions = {
|
||||
setInfo: (width, height) => {
|
||||
loaded: (e) => {
|
||||
const { width, height } = e.nativeEvent.source;
|
||||
updateState({ ratio: width / height });
|
||||
},
|
||||
};
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user