Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(store-devtools): correctly import state when feature is set to true #3855

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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