mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 11:39:17 +00:00
fixed crash on empty message
This commit is contained in:
parent
a045156b64
commit
23e1c2aa9c
@ -136,9 +136,17 @@ export function useUploadContext() {
|
|||||||
|
|
||||||
async function upload(entry, update, complete) {
|
async function upload(entry, update, complete) {
|
||||||
if (!entry.files?.length) {
|
if (!entry.files?.length) {
|
||||||
entry.success(entry.assets);
|
try {
|
||||||
|
await entry.success(entry.assets);
|
||||||
complete();
|
complete();
|
||||||
}
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
entry.failure();
|
||||||
|
entry.error = true;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
const file = entry.files.shift();
|
const file = entry.files.shift();
|
||||||
entry.active = {};
|
entry.active = {};
|
||||||
|
@ -9,13 +9,9 @@ export function ImageFile({ path, setPosition, remove }) {
|
|||||||
|
|
||||||
const { state, actions } = useImageFile();
|
const { state, actions } = useImageFile();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
Image.getSize(path, actions.setInfo);
|
|
||||||
}, [path]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity activeOpacity={1} onLongPress={remove}>
|
<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>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,8 @@ export function useImageFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
setInfo: (width, height) => {
|
loaded: (e) => {
|
||||||
|
const { width, height } = e.nativeEvent.source;
|
||||||
updateState({ ratio: width / height });
|
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 {
|
try {
|
||||||
parsed = JSON.parse(data);
|
parsed = JSON.parse(data);
|
||||||
message = parsed.text;
|
message = parsed.text;
|
||||||
@ -104,9 +104,7 @@ export function useTopicItem(item, hosting, remove) {
|
|||||||
fontColor = Colors.text;
|
fontColor = Colors.text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) { }
|
||||||
console.log("empty message");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let timestamp;
|
let timestamp;
|
||||||
|
Loading…
Reference in New Issue
Block a user