diff --git a/src/Flows.js b/src/Flows.js index ed58d0b..15eb668 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -511,6 +511,10 @@ class FlowSidebar extends PureComponent { } do_vote(vote) { + this.setState({ + loading_status: 'loading', + error_msg: null, + }); API.add_vote(vote, this.state.info.pid, this.props.token) .then((json) => { if (json.code !== 0) return; @@ -518,6 +522,7 @@ class FlowSidebar extends PureComponent { this.setState( (prev, props) => ({ info: Object.assign({}, prev.info, { poll: json.data }), + loading_status: 'done', }), () => { this.syncState({ @@ -525,6 +530,13 @@ class FlowSidebar extends PureComponent { }); }, ); + }) + .catch((e) => { + console.error(e); + this.setState({ + loading_status: 'done', + error_msg: '' + e, + }); }); } @@ -739,7 +751,7 @@ class FlowSidebar extends PureComponent { {!this.state.rev && main_thread_elem} {!!this.state.error_msg && (
-

回复加载失败

+

加载失败

{this.state.error_msg}

)}