[FIX] Command previews crashing when API returns an error (#2254)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
5b3be4ef0b
commit
e1153deb57
|
@ -541,12 +541,14 @@ class MessageBox extends Component {
|
||||||
setCommandPreview = async(command, name, params) => {
|
setCommandPreview = async(command, name, params) => {
|
||||||
const { rid } = this.props;
|
const { rid } = this.props;
|
||||||
try {
|
try {
|
||||||
const { preview } = await RocketChat.getCommandPreview(name, rid, params);
|
const { success, preview } = await RocketChat.getCommandPreview(name, rid, params);
|
||||||
this.setState({ commandPreview: preview.items, showCommandPreview: true, command });
|
if (success) {
|
||||||
|
return this.setState({ commandPreview: preview?.items, showCommandPreview: true, command });
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.setState({ commandPreview: [], showCommandPreview: true, command: {} });
|
|
||||||
log(e);
|
log(e);
|
||||||
}
|
}
|
||||||
|
this.setState({ commandPreview: [], showCommandPreview: true, command: {} });
|
||||||
}
|
}
|
||||||
|
|
||||||
setInput = (text) => {
|
setInput = (text) => {
|
||||||
|
|
Loading…
Reference in New Issue