diff --git a/src/extensions/file_based_loadorder/index.ts b/src/extensions/file_based_loadorder/index.ts index 08823b720..1814e545a 100644 --- a/src/extensions/file_based_loadorder/index.ts +++ b/src/extensions/file_based_loadorder/index.ts @@ -1,3 +1,5 @@ +/* eslint-disable */ + import { IExtensionContext } from '../../types/IExtensionContext'; import { ILoadOrderGameInfo, ILoadOrderGameInfoExt, IValidationResult, LoadOrder, LoadOrderSerializationError, LoadOrderValidationError } from './types/types'; @@ -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) { diff --git a/src/extensions/file_based_loadorder/types/types.ts b/src/extensions/file_based_loadorder/types/types.ts index f8d12ba0d..6edf6914a 100644 --- a/src/extensions/file_based_loadorder/types/types.ts +++ b/src/extensions/file_based_loadorder/types/types.ts @@ -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.