Skip to content

Commit

Permalink
Merge pull request #17013 from Nexus-Mods/16889-bugfix-mod-combine
Browse files Browse the repository at this point in the history
suppressed mod combine action during collection install
  • Loading branch information
insomnious committed Jan 21, 2025
1 parent e15a8ed commit 547a756
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/extensions/mod_management/views/ModList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ interface IConnectedProps extends IModProps {
downloadPath: string;
showDropzone: boolean;
autoInstall: boolean;
// some mod actions are not allowed while installing dependencies/collections
// e.g. combining a mod with other patch mods while the collection is still installing.
suppressModActions: boolean;
}

interface IActionProps {
Expand Down Expand Up @@ -1473,19 +1476,27 @@ class ModList extends ComponentEx<IProps, IComponentState> {
}

private canBeCombined = (modIds: string[]) => {
const { t, mods } = this.props;
const { t, mods, suppressModActions } = this.props;

const notInstalled = modIds.find(modId => mods[modId] === undefined);
if (notInstalled !== undefined) {
return t('You can only combine installed mods') ;
}

if (suppressModActions) {
return t('Try again after installing dependencies');
}

return true;
}

private combine = (modIds: string[]) => {
const { gameMode } = this.props;
const { gameMode, suppressModActions } = this.props;
const { api } = this.context;

if (suppressModActions) {
api.showErrorNotification('Try again after installing dependencies', 'Mod actions are currently disabled', { allowReport: false });
return;
}
return combineMods(api, gameMode, modIds);
}

Expand Down Expand Up @@ -1530,10 +1541,20 @@ class ModList extends ComponentEx<IProps, IComponentState> {

const empty = {};

const shouldSuppressModActions = (state: IState): boolean => {
const suppressOnActivities = ['conflicts', 'installing_dependencies', 'deployment', 'purging'];
const isActivityRunning = (activity: string) =>
getSafe(state, ['session', 'base', 'activity', 'mods'], []).includes(activity) // purge/deploy
|| getSafe(state, ['session', 'base', 'activity', activity], []).length > 0; // installing_dependencies
const suppressingActivities = suppressOnActivities.filter(activity => isActivityRunning(activity));
const suppressing = suppressingActivities.length > 0;
return suppressing;
}

function mapStateToProps(state: IState): IConnectedProps {
const profile = selectors.activeProfile(state);
const gameMode = selectors.activeGameId(state);

const suppressModActions = shouldSuppressModActions(state);
return {
mods: getSafe(state, ['persistent', 'mods', gameMode], empty),
modState: getSafe(profile, ['modState'], empty),
Expand All @@ -1545,6 +1566,7 @@ function mapStateToProps(state: IState): IConnectedProps {
downloadPath: selectors.downloadPath(state),
showDropzone: state.settings.mods.showDropzone,
autoInstall: state.settings.automation.install,
suppressModActions,
};
}

Expand Down

0 comments on commit 547a756

Please sign in to comment.