diff --git a/src/App.js b/src/App.js
index 85058a5..d2863be 100644
--- a/src/App.js
+++ b/src/App.js
@@ -7,6 +7,8 @@ import {TokenCtx} from './UserAction';
import {load_config,bgimg_style} from './Config';
import {listen_darkmode} from './infrastructure/functions';
+const MAX_SIDEBAR_STACK_SIZE=10;
+
function DeprecatedAlert(props) {
return null;
}
@@ -47,32 +49,25 @@ class App extends Component {
}
show_sidebar(title,content,mode='push') {
- if(mode==='push') {
- this.setState((prevState)=>({
- sidebar_stack: prevState.sidebar_stack.concat([[title,content]]),
- }));
- } else if(mode==='pop') {
- this.setState((prevState)=>{
- let ns=prevState.sidebar_stack.slice();
+ this.setState((prevState)=>{
+ let ns=prevState.sidebar_stack.slice();
+ if(mode==='push') {
+ if(ns.length>MAX_SIDEBAR_STACK_SIZE)
+ ns.splice(1,1);
+ ns=ns.concat([[title,content]]);
+ } else if(mode==='pop') {
ns.pop();
- return {
- sidebar_stack: ns,
- };
- });
- } else if(mode==='replace') {
- this.setState((prevState)=>{
- let ns=prevState.sidebar_stack.slice();
+ } else if(mode==='replace') {
ns.pop();
- return {
- sidebar_stack: ns.concat([[title,content]]),
- };
- });
- } else if(mode==='clear') {
- this.setState({
- sidebar_stack: [[null,null]],
- });
- } else
- throw new Error('bad show_sidebar mode');
+ ns=ns.concat([[title,content]]);
+ } else if(mode==='clear') {
+ ns=[[null,null]];
+ } else
+ throw new Error('bad show_sidebar mode');
+ return {
+ sidebar_stack: ns,
+ };
+ });
}
set_mode(mode,search_text) {
diff --git a/src/Flows.js b/src/Flows.js
index a0ffbc3..8d39d2f 100644
--- a/src/Flows.js
+++ b/src/Flows.js
@@ -21,7 +21,7 @@ window.LATEST_POST_ID=parseInt(localStorage['_LATEST_POST_ID'],10)||0;
const DZ_NAME='洞主';
-function load_single_meta(show_sidebar,token,parents) {
+function load_single_meta(show_sidebar,token) {
return (pid)=>{
let color_picker=new ColorPicker();
let title_elem='树洞 #'+pid;
@@ -47,7 +47,7 @@ function load_single_meta(show_sidebar,token,parents) {
load_single_meta(show_sidebar,token,parents)(pid)}>重新加载
+load_single_meta(show_sidebar,token)(pid)}>重新加载
{''+e}
加载中……
); - 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(); if(this.state.rev) replies_to_show.reverse(); @@ -496,7 +496,7 @@ class FlowItemRow extends PureComponent {