Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suppressed mod combine action during collection install #17013

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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