mirror of https://github.com/vector-im/riot-web
switch RoomView:uploadFile to async to clean up then/catch handling
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
parent
f2102e283c
commit
4c3f811050
|
@ -908,18 +908,15 @@ module.exports = React.createClass({
|
||||||
this.setState({ draggingFile: false });
|
this.setState({ draggingFile: false });
|
||||||
},
|
},
|
||||||
|
|
||||||
uploadFile: function(file) {
|
uploadFile: async function(file) {
|
||||||
if (MatrixClientPeg.get().isGuest()) {
|
if (MatrixClientPeg.get().isGuest()) {
|
||||||
dis.dispatch({action: 'view_set_mxid'});
|
dis.dispatch({action: 'view_set_mxid'});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentMessages.sendContentToRoom(file, this.state.room.roomId, MatrixClientPeg.get()).then(() => {
|
try {
|
||||||
// Send message_sent callback, for things like _checkIfAlone because after all a file is still a message.
|
await ContentMessages.sendContentToRoom(file, this.state.room.roomId, MatrixClientPeg.get());
|
||||||
dis.dispatch({
|
} catch (error) {
|
||||||
action: 'message_sent',
|
|
||||||
});
|
|
||||||
}).catch((error) => {
|
|
||||||
if (error.name === "UnknownDeviceError") {
|
if (error.name === "UnknownDeviceError") {
|
||||||
// Let the status bar handle this
|
// Let the status bar handle this
|
||||||
return;
|
return;
|
||||||
|
@ -931,6 +928,14 @@ module.exports = React.createClass({
|
||||||
description: ((error && error.message)
|
description: ((error && error.message)
|
||||||
? error.message : _t("Server may be unavailable, overloaded, or the file too big")),
|
? error.message : _t("Server may be unavailable, overloaded, or the file too big")),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// bail early to avoid calling the dispatch below
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send message_sent callback, for things like _checkIfAlone because after all a file is still a message.
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'message_sent',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue