add dz_only

This commit is contained in:
xmcp
2019-06-24 20:37:33 +08:00
parent 034d753cc9
commit 5d54147c7d
2 changed files with 13 additions and 2 deletions

View File

@@ -171,6 +171,7 @@ class FlowSidebar extends PureComponent {
replies: props.replies, replies: props.replies,
loading_status: 'done', loading_status: 'done',
error_msg: null, error_msg: null,
dz_only: false,
}; };
this.color_picker=props.color_picker; this.color_picker=props.color_picker;
this.syncState=props.sync_state||(()=>{}); this.syncState=props.sync_state||(()=>{});
@@ -284,6 +285,12 @@ class FlowSidebar extends PureComponent {
} }
} }
toggle_dz_only() {
this.setState((prevState)=>({
dz_only: !prevState.dz_only,
}));
}
show_reply_bar(name,event) { show_reply_bar(name,event) {
if(this.reply_ref.current && !event.target.closest('a')) { if(this.reply_ref.current && !event.target.closest('a')) {
let text=this.reply_ref.current.get(); let text=this.reply_ref.current.get();
@@ -303,6 +310,8 @@ class FlowSidebar extends PureComponent {
let show_pid=load_single_meta(this.props.show_sidebar,this.props.token,this.props.parents.concat([this.state.info.pid])); let show_pid=load_single_meta(this.props.show_sidebar,this.props.token,this.props.parents.concat([this.state.info.pid]));
let replies_to_show=this.state.dz_only ? this.state.replies.filter((r)=>r.islz) : this.state.replies;
return ( return (
<div className="flow-item-row sidebar-flow-item"> <div className="flow-item-row sidebar-flow-item">
<div className="box box-tip"> <div className="box box-tip">
@@ -313,6 +322,8 @@ class FlowSidebar extends PureComponent {
</span> </span>
} }
<a onClick={this.load_replies.bind(this)}>刷新回复</a> <a onClick={this.load_replies.bind(this)}>刷新回复</a>
&nbsp;/&nbsp;
<a onClick={this.toggle_dz_only.bind(this)}>{this.state.dz_only ? '查看全部' : '只看洞主'}</a>
{!!this.props.token && {!!this.props.token &&
<span> <span>
&nbsp;/&nbsp; &nbsp;/&nbsp;
@@ -344,7 +355,7 @@ class FlowSidebar extends PureComponent {
{parseInt(this.state.info.reply)-this.state.replies.length} 条回复被删除 {parseInt(this.state.info.reply)-this.state.replies.length} 条回复被删除
</div> </div>
} }
{this.state.replies.map((reply)=>( {replies_to_show.map((reply)=>(
<LazyLoad key={reply.cid} offset={1500} height="5em" overflow={true} once={true}> <LazyLoad key={reply.cid} offset={1500} height="5em" overflow={true} once={true}>
<ClickHandler callback={(e)=>{this.show_reply_bar(reply.name,e);}}> <ClickHandler callback={(e)=>{this.show_reply_bar(reply.name,e);}}>
<Reply <Reply

View File

@@ -82,7 +82,7 @@ export const API={
.then(get_json) .then(get_json)
.then((json)=>{ .then((json)=>{
if(json.code!==0) { if(json.code!==0) {
if(json.msg && json.msg==='已经关注过') {} if(json.msg && json.msg==='已经关注过') {}
else { else {
if(json.msg) alert(json.msg); if(json.msg) alert(json.msg);
throw new Error(JSON.stringify(json)); throw new Error(JSON.stringify(json));