forked from newthuhole/hole_thu_frontend
add latest reply time
This commit is contained in:
@@ -115,7 +115,7 @@
|
|||||||
font-family: 'Consolas', 'Courier', monospace;
|
font-family: 'Consolas', 'Courier', monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
.box-header {
|
.box-header, .box-footer {
|
||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
18
src/Flows.js
18
src/Flows.js
@@ -127,6 +127,9 @@ class FlowItem extends PureComponent {
|
|||||||
}
|
}
|
||||||
{props.info.type==='audio' && <AudioWidget src={AUDIO_BASE+props.info.url} />}
|
{props.info.type==='audio' && <AudioWidget src={AUDIO_BASE+props.info.url} />}
|
||||||
</div>
|
</div>
|
||||||
|
{!!(props.attention && props.info.variant.latest_reply) &&
|
||||||
|
<p className="box-footer">最新回复 <Time stamp={props.info.variant.latest_reply} /></p>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -154,14 +157,14 @@ class FlowSidebar extends PureComponent {
|
|||||||
return {
|
return {
|
||||||
replies: prev.replies.map((reply)=>{
|
replies: prev.replies.map((reply)=>{
|
||||||
if(reply.cid===cid)
|
if(reply.cid===cid)
|
||||||
return Object.assign({},reply,{variant: variant});
|
return Object.assign({},reply,{variant: Object.assign({},reply.variant,variant)});
|
||||||
else
|
else
|
||||||
return reply;
|
return reply;
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
else
|
else
|
||||||
return {
|
return {
|
||||||
info: Object.assign({},prev.info,{variant: variant}),
|
info: Object.assign({},prev.info,{variant: Object.assign({},prev.info.variant,variant)}),
|
||||||
}
|
}
|
||||||
},function() {
|
},function() {
|
||||||
this.syncState({
|
this.syncState({
|
||||||
@@ -192,6 +195,8 @@ class FlowSidebar extends PureComponent {
|
|||||||
attention: this.state.attention,
|
attention: this.state.attention,
|
||||||
info: this.state.info,
|
info: this.state.info,
|
||||||
});
|
});
|
||||||
|
if(this.state.replies.length)
|
||||||
|
this.set_variant(null,{latest_reply: Math.max.apply(null,this.state.replies.map((r)=>parseInt(r.timestamp)))});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((e)=>{
|
.catch((e)=>{
|
||||||
@@ -349,9 +354,12 @@ class FlowItemRow extends PureComponent {
|
|||||||
.then((json)=>{
|
.then((json)=>{
|
||||||
this.setState((prev,props)=>({
|
this.setState((prev,props)=>({
|
||||||
replies: json.data,
|
replies: json.data,
|
||||||
info: update_count ? Object.assign({}, prev.info, {
|
info: Object.assign({}, prev.info, {
|
||||||
reply: ''+json.data.length,
|
reply: update_count ? ''+json.data.length : prev.info.reply,
|
||||||
}) : prev.info,
|
variant: json.data.length ? {
|
||||||
|
latest_reply: Math.max.apply(null,json.data.map((r)=>parseInt(r.timestamp))),
|
||||||
|
} : {},
|
||||||
|
}),
|
||||||
attention: !!json.attention,
|
attention: !!json.attention,
|
||||||
reply_status: 'done',
|
reply_status: 'done',
|
||||||
}),callback);
|
}),callback);
|
||||||
|
|||||||
Reference in New Issue
Block a user