diff --git a/src/extensions/file_based_loadorder/index.ts b/src/extensions/file_based_loadorder/index.ts index 98c16001a..1370aba31 100644 --- a/src/extensions/file_based_loadorder/index.ts +++ b/src/extensions/file_based_loadorder/index.ts @@ -369,9 +369,13 @@ export default function init(context: IExtensionContext) { context.registerActionCheck('SET_FB_LOAD_ORDER', (state, action: any) => { const { profileId, loadOrder } = action.payload; + if (!loadOrder || !Array.isArray(loadOrder)) { + log('error', 'invalid load order', loadOrder); + } const profile = selectors.profileById(state, profileId); - if (updateSet && profile !== undefined) { - updateSet.init(profile.gameId, loadOrder.map((lo, idx) => ({ ...lo, index: idx }))); + const gameId = profile?.gameId ?? selectors.activeGameId(state); + if (updateSet && gameId) { + updateSet.init(gameId, (loadOrder ?? []).map((lo, idx) => ({ ...lo, index: idx }))); } return undefined; });