[MM-22494] Fixed misuse of config.set (#1191)
This commit is contained in:
@@ -769,13 +769,13 @@ export default class MainPage extends React.Component {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onSave={(newTeam) => {
|
onSave={(newTeam) => {
|
||||||
this.props.teams.push(newTeam);
|
this.props.localTeams.push(newTeam);
|
||||||
this.setState({
|
this.props.onTeamConfigChange(this.props.localTeams, () => {
|
||||||
showNewTeamModal: false,
|
self.setState({
|
||||||
key: this.props.teams.length - 1,
|
showNewTeamModal: false,
|
||||||
|
key: this.props.teams.length - 1,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
this.render();
|
|
||||||
this.props.onTeamConfigChange(this.props.teams);
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -834,6 +834,7 @@ export default class MainPage extends React.Component {
|
|||||||
MainPage.propTypes = {
|
MainPage.propTypes = {
|
||||||
onBadgeChange: PropTypes.func.isRequired,
|
onBadgeChange: PropTypes.func.isRequired,
|
||||||
teams: PropTypes.array.isRequired,
|
teams: PropTypes.array.isRequired,
|
||||||
|
localTeams: PropTypes.array.isRequired,
|
||||||
onTeamConfigChange: PropTypes.func.isRequired,
|
onTeamConfigChange: PropTypes.func.isRequired,
|
||||||
initialIndex: PropTypes.number.isRequired,
|
initialIndex: PropTypes.number.isRequired,
|
||||||
useSpellChecker: PropTypes.bool.isRequired,
|
useSpellChecker: PropTypes.bool.isRequired,
|
||||||
|
@@ -26,14 +26,6 @@ const config = new Config(remote.app.getPath('userData') + '/config.json', remot
|
|||||||
|
|
||||||
const teams = config.teams;
|
const teams = config.teams;
|
||||||
|
|
||||||
// Make sure teams have an order
|
|
||||||
if (teams.every((team) => !team.order)) {
|
|
||||||
teams.forEach((team, index) => {
|
|
||||||
team.order = index;
|
|
||||||
});
|
|
||||||
teamConfigChange(teams);
|
|
||||||
}
|
|
||||||
|
|
||||||
remote.getCurrentWindow().removeAllListeners('focus');
|
remote.getCurrentWindow().removeAllListeners('focus');
|
||||||
|
|
||||||
if (teams.length === 0) {
|
if (teams.length === 0) {
|
||||||
@@ -140,8 +132,11 @@ function showBadge(sessionExpired, unreadCount, mentionCount) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function teamConfigChange(updatedTeams) {
|
function teamConfigChange(updatedTeams, callback) {
|
||||||
config.set('teams', updatedTeams);
|
config.set('teams', updatedTeams);
|
||||||
|
if (callback) {
|
||||||
|
config.once('update', callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSelectSpellCheckerLocale(locale) {
|
function handleSelectSpellCheckerLocale(locale) {
|
||||||
@@ -196,6 +191,7 @@ function openMenu() {
|
|||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<MainPage
|
<MainPage
|
||||||
teams={teams}
|
teams={teams}
|
||||||
|
localTeams={config.localTeams}
|
||||||
initialIndex={initialIndex}
|
initialIndex={initialIndex}
|
||||||
onBadgeChange={showBadge}
|
onBadgeChange={showBadge}
|
||||||
onTeamConfigChange={teamConfigChange}
|
onTeamConfigChange={teamConfigChange}
|
||||||
|
Reference in New Issue
Block a user