Allow setting default stream tab

This commit is contained in:
Chi Vinh Le
2017-07-20 02:16:19 +07:00
parent 673f0cd232
commit baa4808364
3 changed files with 15 additions and 6 deletions
@@ -37,10 +37,18 @@ class Stream extends React.Component {
this.setState({keepCommentBox: true});
}
if (next.activeStreamTab !== 'all') {
const slotPlugins = this.getSlotComponents('streamTabs', next).map((c) => c.talkPluginName);
if (slotPlugins.indexOf(next.activeStreamTab) === -1) {
next.setActiveStreamTab('all');
this.fallbackAllTab(next);
}
componentDidMount() {
this.fallbackAllTab();
}
fallbackAllTab(props = this.props) {
if (props.activeStreamTab !== 'all') {
const slotPlugins = this.getSlotComponents('streamTabs', props).map((c) => c.talkPluginName);
if (slotPlugins.indexOf(props.activeStreamTab) === -1) {
props.setActiveStreamTab('all');
}
}
}
@@ -21,7 +21,7 @@ const initialState = {
assetUrl: getQueryVariable('asset_url') || '',
commentId: getQueryVariable('comment_id') || '',
commentClassNames: [],
activeTab: 'all',
activeTab: process.env.TALK_DEFAULT_STEAM_TAB,
previousTab: '',
};
+2 -1
View File
@@ -109,7 +109,8 @@ const config = {
}),
new webpack.EnvironmentPlugin({
'TALK_PLUGINS_JSON': '{}',
'TALK_THREADING_LEVEL': '3'
'TALK_THREADING_LEVEL': '3',
'TALK_DEFAULT_STEAM_TAB': 'all',
})
],
resolveLoader: {