Skip to content

Commit

Permalink
adding ability to maintain lo state on purge (#15042)
Browse files Browse the repository at this point in the history
  • Loading branch information
IDCs authored Dec 20, 2023
1 parent d2f7cda commit c5f9edb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/extensions/file_based_loadorder/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable */

import { IExtensionContext } from '../../types/IExtensionContext';
import { ILoadOrderGameInfo, ILoadOrderGameInfoExt, IValidationResult, LoadOrder,
LoadOrderSerializationError, LoadOrderValidationError } from './types/types';
Expand Down Expand Up @@ -190,8 +192,14 @@ function genDidDeploy(api: types.IExtensionApi) {
}

function genDidPurge(api: types.IExtensionApi) {
return async (profileId: string, deployment: IDeployment) =>
genDeploymentEvent(api, profileId);
return async (profileId: string, deployment: IDeployment) => {
const gameId = selectors.profileById(api.getState(), profileId)?.gameId;
const gameEntry: ILoadOrderGameInfo = findGameEntry(gameId);
if (gameEntry?.clearStateOnPurge === false) {
return Promise.resolve();
}
return genDeploymentEvent(api, profileId);
}
}

export default function init(context: IExtensionContext) {
Expand Down
7 changes: 7 additions & 0 deletions src/extensions/file_based_loadorder/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ export interface ILoadOrderGameInfo {
*/
toggleableEntries?: boolean;

/**
* Defaults to true unless specified otherwise.
* The load order will get cleared upon purge by default.
* Set this to false if you want to preserve the load order.
*/
clearStateOnPurge?: boolean;

/**
* Extension developers are able to provide usage instructions to be displayed
* in the load order page alongside the load order panel.
Expand Down

0 comments on commit c5f9edb

Please sign in to comment.