Skip to content

Commit

Permalink
Fix bug where "Add rom path" always appeared empty, made build settin…
Browse files Browse the repository at this point in the history
…gs copied whenever bulid is launched
  • Loading branch information
anther committed Oct 3, 2018
1 parent 4dc878a commit 621ad2d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 30 deletions.
67 changes: 38 additions & 29 deletions app/actions/builds.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,37 +134,45 @@ const saveBuild = (build: Build) => (dispatch, getState) => {
builds: currentBuilds
}
});
if (build.executablePath()) {
const addRom = path => {
dispatch(addRomPath(path));
};
const allowAnalytics = set => {
dispatch(updateAllowDolphinAnalytics(set));
};
const updateSearchRomSetting = set => {
dispatch(updateSearchRomSubdirectories(set));
};
DolphinConfigurationUpdater.copyInitialSettingsFromBuild(
build.executablePath(),
addRom,
allowAnalytics,
updateSearchRomSetting
)
.then(() => {
dispatch({
type: COPIED_BUILD_SETTINGS,
payload: {
builds: currentBuilds
}
});
dispatch(startReplayBrowser());
})
.catch(error => {
console.error(error);
});
}

dispatch(copyBuildSettings(build));

};

const copyBuildSettings = (build: Build) => (dispatch, getState) => {
const state = getState();
const currentBuilds = { ...state.builds.builds };
if (build.executablePath()) {
const addRom = path => {
dispatch(addRomPath(path));
};
const allowAnalytics = set => {
dispatch(updateAllowDolphinAnalytics(set));
};
const updateSearchRomSetting = set => {
dispatch(updateSearchRomSubdirectories(set));
};
DolphinConfigurationUpdater.copyInitialSettingsFromBuild(
build.executablePath(),
addRom,
allowAnalytics,
updateSearchRomSetting
)
.then(() => {
dispatch({
type: COPIED_BUILD_SETTINGS,
payload: {
builds: currentBuilds
}
});
dispatch(startReplayBrowser());
})
.catch(error => {
console.error(error);
});
}
}

export const setBuildPath = (
build: Build,
path,
Expand Down Expand Up @@ -211,6 +219,7 @@ const syncBuildsWithServer = () => (dispatch, getState) => {

export const mergeInitialSettingsIntoBuild = (build) => (dispatch, getState) => {
const state = getState();
dispatch(copyBuildSettings(build));
dispatch({
type: MERGE_SETTINGS_INTO_BUILD_BEGIN
});
Expand Down
2 changes: 1 addition & 1 deletion app/components/DolphinSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class DolphinSettings extends Component {
</div>
<div className="input-field">
<Button
className={`btn-small ${romPaths.length > 0 ? 'set' : 'not_set'}`}
className={`btn-small ${_.size(romPaths) > 0 ? 'set' : 'not_set'}`}
disabled={selectingRomPath}
onClick={this.onSelectRomPathClick}
>
Expand Down

0 comments on commit 621ad2d

Please sign in to comment.