Skip to content

Commit 0df3419

Browse files
fix(store-devtools): correctly import state when feature is set to true (#3855)
Closes #3636
1 parent 3a5e5d8 commit 0df3419

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

modules/store-devtools/spec/config.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,30 @@ describe('StoreDevtoolsOptions', () => {
109109
},
110110
});
111111
});
112+
113+
it('import "true" is updated to "custom"', () => {
114+
// setting import to true results in an error while importing a persisted state into the devtools
115+
// the imported state only contains the new state without the actions (and config)
116+
// while testing this, the imported state also wasn't correct and contained the initial state values
117+
const config = createConfig({
118+
features: {
119+
import: true,
120+
},
121+
});
122+
expect(config).toEqual({
123+
maxAge: false,
124+
monitor: noMonitor,
125+
actionSanitizer: undefined,
126+
stateSanitizer: undefined,
127+
name: DEFAULT_NAME,
128+
serialize: false,
129+
logOnly: false,
130+
autoPause: false,
131+
features: {
132+
import: 'custom',
133+
},
134+
trace: false,
135+
traceLimit: 75,
136+
});
137+
});
112138
});

modules/store-devtools/src/config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,15 @@ export function createConfig(
172172
const logOnly = options.logOnly
173173
? { pause: true, export: true, test: true }
174174
: false;
175-
const features = options.features || logOnly || DEFAULT_OPTIONS.features;
175+
const features: NonNullable<Partial<StoreDevtoolsConfig['features']>> =
176+
options.features ||
177+
logOnly ||
178+
(DEFAULT_OPTIONS.features as NonNullable<
179+
Partial<StoreDevtoolsConfig['features']>
180+
>);
181+
if (features.import === true) {
182+
features.import = 'custom';
183+
}
176184
const config = Object.assign({}, DEFAULT_OPTIONS, { features }, options);
177185

178186
if (config.maxAge && config.maxAge < 2) {

projects/example-app/src/app/app.module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ import { AppComponent } from '@example-app/core/containers';
6262
*/
6363
StoreDevtoolsModule.instrument({
6464
name: 'NgRx Book Store App',
65-
6665
// In a production build you would want to disable the Store Devtools
6766
// logOnly: !isDevMode(),
6867
}),

0 commit comments

Comments
 (0)