monkey-front-core 0.0.299 → 0.0.301

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,7 +24,7 @@ import { datadogRum } from '@datadog/browser-rum';
24
24
  import * as i1$5 from '@angular/service-worker';
25
25
  import { ServiceWorkerModule } from '@angular/service-worker';
26
26
  import { initialize } from 'launchdarkly-js-client-sdk';
27
- import { createAction, props, createReducer, on } from '@ngrx/store';
27
+ import { createAction, props, INIT, UPDATE, createReducer, on } from '@ngrx/store';
28
28
  import { createEntityAdapter } from '@ngrx/entity';
29
29
 
30
30
  class AlertsComponent {
@@ -5445,6 +5445,48 @@ var index$2 = /*#__PURE__*/Object.freeze({
5445
5445
  monkeyecxStorage: monkeyecxStorage_actions
5446
5446
  });
5447
5447
 
5448
+ const seederReducer = (keys) => {
5449
+ return (reducer) => {
5450
+ return (state, action) => {
5451
+ const handledState = reducer(state, action);
5452
+ if (action.type === INIT || action.type === UPDATE) {
5453
+ const storageValue = localStorage.getItem('state');
5454
+ if (storageValue) {
5455
+ try {
5456
+ const handled = {
5457
+ ...handledState,
5458
+ ...JSON.parse(atob(storageValue))
5459
+ };
5460
+ return handled;
5461
+ }
5462
+ catch {
5463
+ localStorage.removeItem('state');
5464
+ }
5465
+ }
5466
+ }
5467
+ let data = null;
5468
+ try {
5469
+ keys.forEach((key) => {
5470
+ data = {
5471
+ ...data,
5472
+ [key]: handledState[key]
5473
+ };
5474
+ });
5475
+ localStorage.setItem('state', btoa(JSON.stringify(data)));
5476
+ }
5477
+ catch (e) {
5478
+ localStorage.removeItem('state');
5479
+ }
5480
+ return data || handledState;
5481
+ };
5482
+ };
5483
+ };
5484
+
5485
+ var monkeyecxSeeder_reducer = /*#__PURE__*/Object.freeze({
5486
+ __proto__: null,
5487
+ seederReducer: seederReducer
5488
+ });
5489
+
5448
5490
  const featureKey = 'mecx-core-storage';
5449
5491
  const adapter = createEntityAdapter({
5450
5492
  selectId: (item) => {
@@ -5494,33 +5536,6 @@ var monkeyecxStorage_reducer = /*#__PURE__*/Object.freeze({
5494
5536
  selectTotal: selectTotal
5495
5537
  });
5496
5538
 
5497
- const seederReducer = (reducer) => {
5498
- return (state, action) => {
5499
- /* if (action.type === INIT || action.type === UPDATE) {
5500
- const storageValue = localStorage.getItem('state');
5501
- if (storageValue) {
5502
- try {
5503
- return JSON.parse(storageValue);
5504
- } catch {
5505
- localStorage.removeItem('state');
5506
- }
5507
- }
5508
- } */
5509
- const nextState = reducer(state, action);
5510
- const data = nextState?.[featureKey];
5511
- console.log('@#@@@@@');
5512
- console.log(data);
5513
- console.log('@#@@@@@');
5514
- localStorage.setItem('state', JSON.stringify(nextState));
5515
- return nextState;
5516
- };
5517
- };
5518
-
5519
- var monkeyecxSeeder_reducer = /*#__PURE__*/Object.freeze({
5520
- __proto__: null,
5521
- seederReducer: seederReducer
5522
- });
5523
-
5524
5539
  var index$1 = /*#__PURE__*/Object.freeze({
5525
5540
  __proto__: null,
5526
5541
  fromMonkeyecxSeeder: monkeyecxSeeder_reducer,