Skip to content

Commit

Permalink
fix(store-devtools): correctly import state when feature is set to tr…
Browse files Browse the repository at this point in the history
…ue (#3855)

Closes #3636
  • Loading branch information
timdeschryver authored Apr 24, 2023
1 parent 3a5e5d8 commit 0df3419
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
26 changes: 26 additions & 0 deletions modules/store-devtools/spec/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,30 @@ describe('StoreDevtoolsOptions', () => {
},
});
});

it('import "true" is updated to "custom"', () => {
// setting import to true results in an error while importing a persisted state into the devtools
// the imported state only contains the new state without the actions (and config)
// while testing this, the imported state also wasn't correct and contained the initial state values
const config = createConfig({
features: {
import: true,
},
});
expect(config).toEqual({
maxAge: false,
monitor: noMonitor,
actionSanitizer: undefined,
stateSanitizer: undefined,
name: DEFAULT_NAME,
serialize: false,
logOnly: false,
autoPause: false,
features: {
import: 'custom',
},
trace: false,
traceLimit: 75,
});
});
});
10 changes: 9 additions & 1 deletion modules/store-devtools/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,15 @@ export function createConfig(
const logOnly = options.logOnly
? { pause: true, export: true, test: true }
: false;
const features = options.features || logOnly || DEFAULT_OPTIONS.features;
const features: NonNullable<Partial<StoreDevtoolsConfig['features']>> =
options.features ||
logOnly ||
(DEFAULT_OPTIONS.features as NonNullable<
Partial<StoreDevtoolsConfig['features']>
>);
if (features.import === true) {
features.import = 'custom';
}
const config = Object.assign({}, DEFAULT_OPTIONS, { features }, options);

if (config.maxAge && config.maxAge < 2) {
Expand Down
1 change: 0 additions & 1 deletion projects/example-app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ import { AppComponent } from '@example-app/core/containers';
*/
StoreDevtoolsModule.instrument({
name: 'NgRx Book Store App',

// In a production build you would want to disable the Store Devtools
// logOnly: !isDevMode(),
}),
Expand Down

0 comments on commit 0df3419

Please sign in to comment.