diff --git a/src/Flows.js b/src/Flows.js
index d7be3cd..1b61e82 100644
--- a/src/Flows.js
+++ b/src/Flows.js
@@ -54,67 +54,80 @@ function load_single_meta(show_sidebar,token) {
};
}
-function Reply(props) {
- return (
-
-
- #{props.info.cid}
-
-
-
-
+class Reply extends PureComponent {
+ constructor(props) {
+ super(props);
+ }
+
+ render() {
+ return (
+
+
+ #{this.props.info.cid}
+
+
+
+
+
-
- );
+ );
+ }
}
-function FlowItem(props) {
- function copy_link(event) {
+class FlowItem extends PureComponent {
+ constructor(props) {
+ super(props);
+ }
+
+ copy_link(event) {
event.preventDefault();
copy(
`${event.target.href}\n`+
- `${props.info.text}${props.info.type==='image'?' [图片]':props.info.type==='audio'?' [语音]':''}\n`+
- `(${format_time(new Date(props.info.timestamp*1000))} ${props.info.likenum}关注 ${props.info.reply}回复)\n`+
- props.replies.map((r)=>(r.text)).join('\n')
+ `${this.props.info.text}${this.props.info.type==='image'?' [图片]':this.props.info.type==='audio'?' [语音]':''}\n`+
+ `(${format_time(new Date(this.props.info.timestamp*1000))} ${this.props.info.likenum}关注 ${this.props.info.reply}回复)\n`+
+ this.props.replies.map((r)=>(r.text)).join('\n')
);
}
- return (
-
- {parseInt(props.info.pid,10)>window.LATEST_POST_ID &&
}
-
- {!!parseInt(props.info.likenum,10) &&
-
- {props.info.likenum}
-
-
- }
- {!!parseInt(props.info.reply,10) &&
-
- {props.info.reply}
-
-
- }
-
#{props.info.pid}
-
-
-
-
-
- {props.info.type==='image' &&
-
- {props.img_clickable ?
-
:
-
- }
-
- }
- {props.info.type==='audio' &&
}
+ render() {
+ let props=this.props;
+ return (
+
+ {parseInt(props.info.pid,10)>window.LATEST_POST_ID &&
}
+
+ {!!parseInt(props.info.likenum,10) &&
+
+ {props.info.likenum}
+
+
+ }
+ {!!parseInt(props.info.reply,10) &&
+
+ {props.info.reply}
+
+
+ }
+
#{props.info.pid}
+
+
+
+
+
+ {props.info.type==='image' &&
+
+ {props.img_clickable ?
+
:
+
+ }
+
+ }
+ {props.info.type==='audio' &&
}
+
-
- );
+ );
+ }
}
class FlowSidebar extends PureComponent {
@@ -131,6 +144,29 @@ class FlowSidebar extends PureComponent {
this.syncState=props.sync_state||(()=>{});
}
+ set_variant(cid,variant) {
+ this.setState((prev)=>{
+ if(cid)
+ return {
+ replies: prev.replies.map((reply)=>{
+ if(reply.cid===cid)
+ return Object.assign({},reply,{variant: variant});
+ else
+ return reply;
+ }),
+ };
+ else
+ return {
+ info: Object.assign({},prev.info,{variant: variant}),
+ }
+ },function() {
+ this.syncState({
+ info: this.state.info,
+ replies: this.state.replies,
+ });
+ });
+ }
+
load_replies(update_count=true) {
this.setState({
loading_status: 'loading',
@@ -251,7 +287,9 @@ class FlowSidebar extends PureComponent {
}
+ color_picker={this.color_picker} show_pid={this.show_pid} replies={this.state.replies}
+ set_variant={(variant)=>{this.set_variant(null,variant);}}
+ />
{(this.props.deletion_detect && parseInt(this.state.info.reply)>this.state.replies.length) &&
{parseInt(this.state.info.reply)-this.state.replies.length} 条回复被删除
@@ -259,7 +297,10 @@ class FlowSidebar extends PureComponent {
}
{this.state.replies.map((reply)=>(
-
+ {this.set_variant(reply.cid,variant);}}
+ />
))}
{!!this.props.token ?
@@ -280,6 +321,7 @@ class FlowItemRow extends PureComponent {
info: props.info,
attention: false,
};
+ this.state.info.variant={};
this.color_picker=new ColorPicker();
this.show_pid=load_single_meta(this.props.show_sidebar,this.props.token);
}
diff --git a/src/Title.css b/src/Title.css
index 1fe9d78..7d49956 100644
--- a/src/Title.css
+++ b/src/Title.css
@@ -12,9 +12,16 @@
.title {
font-size: 1.5em;
- line-height: 4em;
+ height: 4em;
+ padding-top: 1em;
text-align: center;
}
+.title .title-small {
+ opacity: .6;
+ padding-top: .5em;
+ font-size: .5em;
+ line-height: .5em;
+}
.control-bar {
display: flex;
diff --git a/src/Title.js b/src/Title.js
index a663f98..35b0a2a 100644
--- a/src/Title.js
+++ b/src/Title.js
@@ -156,13 +156,18 @@ export function Title(props) {
return (
-
- P大树洞
-
-
-
-
-
+
+
+ P大树洞
+
+
+
+
+
+
+ 非官方网页版 by @xmcp
+
+
diff --git a/src/flows_api.js b/src/flows_api.js
index 1903dcf..af1df1d 100644
--- a/src/flows_api.js
+++ b/src/flows_api.js
@@ -22,6 +22,7 @@ export const API={
})
.map((info)=>{
info._display_color=color_picker.get(info.name);
+ info.variant={};
return info;
});