Skip to content

Commit 9e8d542

Browse files
committed
overwrite dynamix state instead of merging config file
1 parent 7a05106 commit 9e8d542

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

api/src/store/modules/dynamix.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { PayloadAction } from '@reduxjs/toolkit';
22
import { createSlice } from '@reduxjs/toolkit';
3-
import { merge } from 'lodash-es';
43

54
import { type DynamixConfig } from '@app/core/types/ini.js';
65
import { loadDynamixConfigFile } from '@app/store/actions/load-dynamix-config-file.js';
@@ -29,7 +28,10 @@ export const dynamix = createSlice({
2928
});
3029

3130
builder.addCase(loadDynamixConfigFile.fulfilled, (state, action) => {
32-
Object.assign(state, action.payload, { status: FileLoadStatus.LOADED });
31+
return {
32+
...(action.payload as DynamixConfig),
33+
status: FileLoadStatus.LOADED,
34+
};
3335
});
3436

3537
builder.addCase(loadDynamixConfigFile.rejected, (state, action) => {

api/src/store/modules/emhttp.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { join } from 'path';
22

33
import type { PayloadAction } from '@reduxjs/toolkit';
44
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
5-
import { mergeWith } from 'lodash-es';
65

76
import type { RootState } from '@app/store/index.js';
87
import type { StateFileToIniParserMap } from '@app/store/types.js';
@@ -164,15 +163,6 @@ export const loadStateFiles = createAsyncThunk<
164163
return state;
165164
});
166165

167-
// Custom merge function that replaces arrays instead of merging them element-wise
168-
const mergeReplaceArrays = (object: any, source: any, ...rest: any[]) =>
169-
mergeWith(object, source, ...rest, (objValue: unknown, srcValue: unknown) => {
170-
if (Array.isArray(srcValue)) {
171-
return srcValue;
172-
}
173-
return undefined;
174-
});
175-
176166
export const emhttp = createSlice({
177167
name: 'emhttp',
178168
initialState,

0 commit comments

Comments
 (0)