Fix problem with deeplinkingUrl still being set when preferences window closes.

This commit is contained in:
David Meza
2017-10-23 18:54:17 -05:00
parent c624a9a009
commit ce08b73617
2 changed files with 11 additions and 5 deletions

View File

@@ -23,15 +23,15 @@ const MainPage = createReactClass({
onTeamConfigChange: PropTypes.func.isRequired,
initialIndex: PropTypes.number.isRequired,
useSpellChecker: PropTypes.bool.isRequired,
onSelectSpellCheckerLocale: PropTypes.func.isRequired
onSelectSpellCheckerLocale: PropTypes.func.isRequired,
deeplinkingUrl: PropTypes.string
},
getInitialState() {
const deeplinkingUrl = remote.getCurrentWindow().deeplinkingUrl;
let key = this.props.initialIndex;
if (deeplinkingUrl !== null) {
if (this.props.deeplinkingUrl !== null) {
for (var i = 0; i < this.props.teams.length; i++) {
if (deeplinkingUrl.includes(this.props.teams[i].url)) {
if (this.props.deeplinkingUrl.includes(this.props.teams[i].url)) {
key = i;
break;
}
@@ -274,7 +274,7 @@ const MainPage = createReactClass({
var isActive = self.state.key === index;
let teamUrl = team.url;
const deeplinkingUrl = remote.getCurrentWindow().deeplinkingUrl;
const deeplinkingUrl = this.props.deeplinkingUrl;
if (deeplinkingUrl !== null && deeplinkingUrl.includes(teamUrl)) {
teamUrl = deeplinkingUrl;
}

View File

@@ -102,6 +102,11 @@ function handleSelectSpellCheckerLocale(locale) {
const parsedURL = url.parse(window.location.href, true);
const initialIndex = parsedURL.query.index ? parseInt(parsedURL.query.index, 10) : 0;
let deeplinkingUrl = null;
if (!parsedURL.query.index || parsedURL.query.index === null) {
deeplinkingUrl = remote.getCurrentWindow().deeplinkingUrl;
}
ReactDOM.render(
<MainPage
teams={AppConfig.data.teams}
@@ -110,6 +115,7 @@ ReactDOM.render(
onTeamConfigChange={teamConfigChange}
useSpellChecker={AppConfig.data.useSpellChecker}
onSelectSpellCheckerLocale={handleSelectSpellCheckerLocale}
deeplinkingUrl={deeplinkingUrl}
/>,
document.getElementById('content')
);