forked from newthuhole/hole_thu_frontend
fix
This commit is contained in:
43
src/App.js
43
src/App.js
@@ -7,6 +7,8 @@ import {TokenCtx} from './UserAction';
|
|||||||
import {load_config,bgimg_style} from './Config';
|
import {load_config,bgimg_style} from './Config';
|
||||||
import {listen_darkmode} from './infrastructure/functions';
|
import {listen_darkmode} from './infrastructure/functions';
|
||||||
|
|
||||||
|
const MAX_SIDEBAR_STACK_SIZE=10;
|
||||||
|
|
||||||
function DeprecatedAlert(props) {
|
function DeprecatedAlert(props) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -47,32 +49,25 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show_sidebar(title,content,mode='push') {
|
show_sidebar(title,content,mode='push') {
|
||||||
if(mode==='push') {
|
this.setState((prevState)=>{
|
||||||
this.setState((prevState)=>({
|
let ns=prevState.sidebar_stack.slice();
|
||||||
sidebar_stack: prevState.sidebar_stack.concat([[title,content]]),
|
if(mode==='push') {
|
||||||
}));
|
if(ns.length>MAX_SIDEBAR_STACK_SIZE)
|
||||||
} else if(mode==='pop') {
|
ns.splice(1,1);
|
||||||
this.setState((prevState)=>{
|
ns=ns.concat([[title,content]]);
|
||||||
let ns=prevState.sidebar_stack.slice();
|
} else if(mode==='pop') {
|
||||||
ns.pop();
|
ns.pop();
|
||||||
return {
|
} else if(mode==='replace') {
|
||||||
sidebar_stack: ns,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
} else if(mode==='replace') {
|
|
||||||
this.setState((prevState)=>{
|
|
||||||
let ns=prevState.sidebar_stack.slice();
|
|
||||||
ns.pop();
|
ns.pop();
|
||||||
return {
|
ns=ns.concat([[title,content]]);
|
||||||
sidebar_stack: ns.concat([[title,content]]),
|
} else if(mode==='clear') {
|
||||||
};
|
ns=[[null,null]];
|
||||||
});
|
} else
|
||||||
} else if(mode==='clear') {
|
throw new Error('bad show_sidebar mode');
|
||||||
this.setState({
|
return {
|
||||||
sidebar_stack: [[null,null]],
|
sidebar_stack: ns,
|
||||||
});
|
};
|
||||||
} else
|
});
|
||||||
throw new Error('bad show_sidebar mode');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set_mode(mode,search_text) {
|
set_mode(mode,search_text) {
|
||||||
|
|||||||
10
src/Flows.js
10
src/Flows.js
@@ -21,7 +21,7 @@ window.LATEST_POST_ID=parseInt(localStorage['_LATEST_POST_ID'],10)||0;
|
|||||||
|
|
||||||
const DZ_NAME='洞主';
|
const DZ_NAME='洞主';
|
||||||
|
|
||||||
function load_single_meta(show_sidebar,token,parents) {
|
function load_single_meta(show_sidebar,token) {
|
||||||
return (pid)=>{
|
return (pid)=>{
|
||||||
let color_picker=new ColorPicker();
|
let color_picker=new ColorPicker();
|
||||||
let title_elem='树洞 #'+pid;
|
let title_elem='树洞 #'+pid;
|
||||||
@@ -47,7 +47,7 @@ function load_single_meta(show_sidebar,token,parents) {
|
|||||||
<FlowSidebar key={+new Date()}
|
<FlowSidebar key={+new Date()}
|
||||||
info={single.data} replies={replies.data} attention={replies.attention}
|
info={single.data} replies={replies.data} attention={replies.attention}
|
||||||
token={token} show_sidebar={show_sidebar} color_picker={color_picker}
|
token={token} show_sidebar={show_sidebar} color_picker={color_picker}
|
||||||
deletion_detect={localStorage['DELETION_DETECT']==='on'} parents={parents}
|
deletion_detect={localStorage['DELETION_DETECT']==='on'}
|
||||||
/>,
|
/>,
|
||||||
'replace'
|
'replace'
|
||||||
)
|
)
|
||||||
@@ -57,7 +57,7 @@ function load_single_meta(show_sidebar,token,parents) {
|
|||||||
show_sidebar(
|
show_sidebar(
|
||||||
title_elem,
|
title_elem,
|
||||||
<div className="box box-tip">
|
<div className="box box-tip">
|
||||||
<p><a onClick={()=>load_single_meta(show_sidebar,token,parents)(pid)}>重新加载</a></p>
|
<p><a onClick={()=>load_single_meta(show_sidebar,token)(pid)}>重新加载</a></p>
|
||||||
<p>{''+e}</p>
|
<p>{''+e}</p>
|
||||||
</div>,
|
</div>,
|
||||||
'replace'
|
'replace'
|
||||||
@@ -335,7 +335,7 @@ class FlowSidebar extends PureComponent {
|
|||||||
if(this.state.loading_status==='loading')
|
if(this.state.loading_status==='loading')
|
||||||
return (<p className="box box-tip">加载中……</p>);
|
return (<p className="box box-tip">加载中……</p>);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
let replies_to_show=this.state.filter_name ? this.state.replies.filter((r)=>r.name===this.state.filter_name) : this.state.replies.slice();
|
let replies_to_show=this.state.filter_name ? this.state.replies.filter((r)=>r.name===this.state.filter_name) : this.state.replies.slice();
|
||||||
if(this.state.rev) replies_to_show.reverse();
|
if(this.state.rev) replies_to_show.reverse();
|
||||||
@@ -496,7 +496,7 @@ class FlowItemRow extends PureComponent {
|
|||||||
<FlowSidebar key={+new Date()}
|
<FlowSidebar key={+new Date()}
|
||||||
info={this.state.info} replies={this.state.replies} attention={this.state.attention} sync_state={this.setState.bind(this)}
|
info={this.state.info} replies={this.state.replies} attention={this.state.attention} sync_state={this.setState.bind(this)}
|
||||||
token={this.props.token} show_sidebar={this.props.show_sidebar} color_picker={this.color_picker}
|
token={this.props.token} show_sidebar={this.props.show_sidebar} color_picker={this.color_picker}
|
||||||
deletion_detect={this.props.deletion_detect} parents={[]}
|
deletion_detect={this.props.deletion_detect}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user