|
|
@ -24,6 +24,7 @@ import { TokenCtx, ReplyForm } from './UserAction'; |
|
|
|
import { API } from './flows_api'; |
|
|
|
import { API } from './flows_api'; |
|
|
|
import { cache } from './cache'; |
|
|
|
import { cache } from './cache'; |
|
|
|
import { save_attentions } from './Attention' |
|
|
|
import { save_attentions } from './Attention' |
|
|
|
|
|
|
|
import Poll from 'react-polls'; |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
const IMAGE_BASE = 'https://thimg.yecdn.com/'; |
|
|
|
const IMAGE_BASE = 'https://thimg.yecdn.com/'; |
|
|
@ -159,7 +160,7 @@ class FlowItem extends PureComponent { |
|
|
|
this.state = { |
|
|
|
this.state = { |
|
|
|
hot_score: props.info.hot_score || 0, |
|
|
|
hot_score: props.info.hot_score || 0, |
|
|
|
cw: props.info.cw || '', |
|
|
|
cw: props.info.cw || '', |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
copy_link(event) { |
|
|
|
copy_link(event) { |
|
|
@ -199,7 +200,8 @@ class FlowItem extends PureComponent { |
|
|
|
render() { |
|
|
|
render() { |
|
|
|
const { |
|
|
|
const { |
|
|
|
info, is_quote, cached, attention, can_del, do_filter_name, do_delete, |
|
|
|
info, is_quote, cached, attention, can_del, do_filter_name, do_delete, |
|
|
|
do_edit_cw, do_edit_score, timestamp, img_clickable, color_picker, show_pid |
|
|
|
do_edit_cw, do_edit_score, timestamp, img_clickable, color_picker, |
|
|
|
|
|
|
|
show_pid, do_vote |
|
|
|
} = this.props; |
|
|
|
} = this.props; |
|
|
|
const { cw, hot_score } = this.state; |
|
|
|
const { cw, hot_score } = this.state; |
|
|
|
return ( |
|
|
|
return ( |
|
|
@ -348,6 +350,19 @@ class FlowItem extends PureComponent { |
|
|
|
)} |
|
|
|
)} |
|
|
|
{/*{info.type==='audio' && <AudioWidget src={AUDIO_BASE+info.url} />}*/} |
|
|
|
{/*{info.type==='audio' && <AudioWidget src={AUDIO_BASE+info.url} />}*/} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
{ info.poll && ( |
|
|
|
|
|
|
|
<div className={!do_vote ? "box-poll disabled" : "box-poll"}> |
|
|
|
|
|
|
|
<Poll |
|
|
|
|
|
|
|
key={+new Date()} |
|
|
|
|
|
|
|
question={""} |
|
|
|
|
|
|
|
answers={info.poll.answers} |
|
|
|
|
|
|
|
onVote={do_vote || (() => {})} |
|
|
|
|
|
|
|
customStyles={{'theme': 'cyan'}} |
|
|
|
|
|
|
|
noStorage={true} |
|
|
|
|
|
|
|
vote={info.poll.vote} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
)} |
|
|
|
{!!(attention && info.variant.latest_reply) && ( |
|
|
|
{!!(attention && info.variant.latest_reply) && ( |
|
|
|
<p className="box-footer"> |
|
|
|
<p className="box-footer"> |
|
|
|
最新回复{' '} |
|
|
|
最新回复{' '} |
|
|
@ -458,21 +473,16 @@ class FlowSidebar extends PureComponent { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
toggle_attention() { |
|
|
|
toggle_attention() { |
|
|
|
this.setState({ |
|
|
|
|
|
|
|
loading_status: 'loading', |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
const prev_info = this.state.info; |
|
|
|
const prev_info = this.state.info; |
|
|
|
const pid = prev_info.pid; |
|
|
|
const pid = prev_info.pid; |
|
|
|
API.set_attention(pid, !this.state.attention, this.props.token) |
|
|
|
API.set_attention(pid, !this.state.attention, this.props.token) |
|
|
|
.then((json) => { |
|
|
|
.then((json) => { |
|
|
|
this.setState({ |
|
|
|
this.setState({ |
|
|
|
loading_status: 'done', |
|
|
|
|
|
|
|
attention: json.attention, |
|
|
|
attention: json.attention, |
|
|
|
info: Object.assign({}, prev_info, { |
|
|
|
info: Object.assign({}, prev_info, { |
|
|
|
likenum: ''+json.likenum, |
|
|
|
likenum: ''+json.likenum, |
|
|
|
}), |
|
|
|
}), |
|
|
|
}); |
|
|
|
}); |
|
|
|
console.log(json); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let saved_attentions = window.saved_attentions; |
|
|
|
let saved_attentions = window.saved_attentions; |
|
|
|
if (json.attention && !saved_attentions.includes(pid)) { |
|
|
|
if (json.attention && !saved_attentions.includes(pid)) { |
|
|
@ -500,6 +510,28 @@ 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; |
|
|
|
|
|
|
|
this.setState( |
|
|
|
|
|
|
|
(prev, props) => ({ |
|
|
|
|
|
|
|
info: Object.assign({}, prev.info, { poll: json.data }), |
|
|
|
|
|
|
|
loading_status: 'done', |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
() => { |
|
|
|
|
|
|
|
this.syncState({ |
|
|
|
|
|
|
|
info: this.state.info, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
report() { |
|
|
|
report() { |
|
|
|
let reason = prompt(`举报 #${this.state.info.pid} 的理由:`); |
|
|
|
let reason = prompt(`举报 #${this.state.info.pid} 的理由:`); |
|
|
|
if (reason !== null) { |
|
|
|
if (reason !== null) { |
|
|
@ -543,7 +575,6 @@ class FlowSidebar extends PureComponent { |
|
|
|
|
|
|
|
|
|
|
|
make_do_delete(token, on_complete=null) { |
|
|
|
make_do_delete(token, on_complete=null) { |
|
|
|
const do_delete = (type, id) => { |
|
|
|
const do_delete = (type, id) => { |
|
|
|
console.log('del', type, id, token); |
|
|
|
|
|
|
|
let note = prompt(`将删除${type}=${id}, 备注:`, '(无)'); |
|
|
|
let note = prompt(`将删除${type}=${id}, 备注:`, '(无)'); |
|
|
|
if (note !== null) { |
|
|
|
if (note !== null) { |
|
|
|
API.del(type, id, note, token) |
|
|
|
API.del(type, id, note, token) |
|
|
@ -562,7 +593,6 @@ class FlowSidebar extends PureComponent { |
|
|
|
|
|
|
|
|
|
|
|
make_do_edit_cw(token) { |
|
|
|
make_do_edit_cw(token) { |
|
|
|
const do_edit_cw = (cw, id) => { |
|
|
|
const do_edit_cw = (cw, id) => { |
|
|
|
console.log('edit cw', cw); |
|
|
|
|
|
|
|
API.update_cw(cw, id, token) |
|
|
|
API.update_cw(cw, id, token) |
|
|
|
.then((json) => { |
|
|
|
.then((json) => { |
|
|
|
alert('已更新\n刷新列表显示新版本'); |
|
|
|
alert('已更新\n刷新列表显示新版本'); |
|
|
@ -577,7 +607,6 @@ class FlowSidebar extends PureComponent { |
|
|
|
|
|
|
|
|
|
|
|
make_do_edit_score(token) { |
|
|
|
make_do_edit_score(token) { |
|
|
|
const do_edit_score = (score, id) => { |
|
|
|
const do_edit_score = (score, id) => { |
|
|
|
console.log('edit score', score); |
|
|
|
|
|
|
|
API.update_score(score, id, token) |
|
|
|
API.update_score(score, id, token) |
|
|
|
.then((json) => { |
|
|
|
.then((json) => { |
|
|
|
console.log('已更新'); |
|
|
|
console.log('已更新'); |
|
|
@ -636,6 +665,7 @@ class FlowSidebar extends PureComponent { |
|
|
|
do_delete={this.make_do_delete(this.props.token, ()=>{window.location.reload();})} |
|
|
|
do_delete={this.make_do_delete(this.props.token, ()=>{window.location.reload();})} |
|
|
|
do_edit_cw={this.make_do_edit_cw(this.props.token)} |
|
|
|
do_edit_cw={this.make_do_edit_cw(this.props.token)} |
|
|
|
do_edit_score={this.make_do_edit_score(this.props.token)} |
|
|
|
do_edit_score={this.make_do_edit_score(this.props.token)} |
|
|
|
|
|
|
|
do_vote={this.do_vote.bind(this)} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</ClickHandler> |
|
|
|
</ClickHandler> |
|
|
|
); |
|
|
|
); |
|
|
|