@zeniai/client-epic-state 5.2.49-beta0ND → 5.2.49-betaAK0

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.
Files changed (84) hide show
  1. package/lib/entity/notificationRegistry/notificationRegistryReducer.d.ts +1 -2
  2. package/lib/entity/notificationRegistry/notificationRegistryReducer.js +9 -20
  3. package/lib/entity/notificationRegistry/notificationRegistrySelector.d.ts +1 -2
  4. package/lib/entity/notificationRegistry/notificationRegistrySelector.js +1 -7
  5. package/lib/entity/notificationRegistry/notificationRegistryState.d.ts +0 -5
  6. package/lib/entity/notificationRegistry/notificationRegistryState.js +1 -7
  7. package/lib/entity/sectionProjectView/sectionProjectViewReducer.js +1 -3
  8. package/lib/epic.js +4 -4
  9. package/lib/esm/entity/notificationRegistry/notificationRegistryReducer.js +9 -20
  10. package/lib/esm/entity/notificationRegistry/notificationRegistrySelector.js +0 -5
  11. package/lib/esm/entity/notificationRegistry/notificationRegistryState.js +0 -5
  12. package/lib/esm/entity/sectionProjectView/sectionProjectViewReducer.js +1 -3
  13. package/lib/esm/epic.js +4 -4
  14. package/lib/esm/index.js +4 -4
  15. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +2 -4
  16. package/lib/esm/view/aiCfoView/epics/fetchRoutineRunsEpic.js +1 -3
  17. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +19 -11
  18. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +4 -1
  19. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -2
  20. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +18 -9
  21. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +19 -11
  22. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +3 -1
  23. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +1 -1
  24. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +16 -7
  25. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +19 -11
  26. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +4 -2
  27. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +1 -1
  28. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +21 -13
  29. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +3 -2
  30. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionFormPageEpic.js +4 -1
  31. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +1 -1
  32. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.js +18 -9
  33. package/lib/esm/view/invoicing/invoicingFormDraft.js +56 -0
  34. package/lib/esm/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.js +7 -20
  35. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewReducer.js +17 -43
  36. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewSelector.js +4 -24
  37. package/lib/esm/view/settingsView/epic/fetchNotificationSettingsEpic.js +2 -12
  38. package/lib/index.d.ts +4 -4
  39. package/lib/index.js +14 -21
  40. package/lib/view/aiCfoView/aiCfoViewReducer.js +2 -4
  41. package/lib/view/aiCfoView/aiCfoViewSelector.d.ts +1 -1
  42. package/lib/view/aiCfoView/epics/fetchRoutineRunsEpic.js +1 -3
  43. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.d.ts +3 -1
  44. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +19 -11
  45. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +10 -0
  46. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +4 -1
  47. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewState.d.ts +2 -1
  48. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -2
  49. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.d.ts +10 -6
  50. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +17 -8
  51. package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.d.ts +3 -1
  52. package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +19 -11
  53. package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.d.ts +13 -0
  54. package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +3 -1
  55. package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.d.ts +2 -1
  56. package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +1 -1
  57. package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.d.ts +10 -6
  58. package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +15 -6
  59. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +3 -1
  60. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +19 -11
  61. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +9 -0
  62. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +4 -2
  63. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +2 -1
  64. package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +1 -1
  65. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.d.ts +3 -1
  66. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +21 -13
  67. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +9 -0
  68. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +3 -2
  69. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +2 -1
  70. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionFormPageEpic.js +4 -1
  71. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +1 -1
  72. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.d.ts +10 -6
  73. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.js +17 -8
  74. package/lib/view/invoicing/invoicingFormDraft.d.ts +50 -0
  75. package/lib/view/invoicing/invoicingFormDraft.js +63 -0
  76. package/lib/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.js +6 -19
  77. package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.d.ts +5 -8
  78. package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.js +17 -43
  79. package/lib/view/notificationPreferencesView/notificationPreferencesViewSelector.d.ts +0 -4
  80. package/lib/view/notificationPreferencesView/notificationPreferencesViewSelector.js +5 -30
  81. package/lib/view/notificationPreferencesView/notificationPreferencesViewState.d.ts +3 -4
  82. package/lib/view/settingsView/epic/fetchNotificationSettingsEpic.js +2 -12
  83. package/lib/view/settingsView/settingsViewPayload.d.ts +0 -2
  84. package/package.json +1 -1
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.saveNotificationPreferencesEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
- const notificationRegistryState_1 = require("../../../entity/notificationRegistry/notificationRegistryState");
7
6
  const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
8
7
  const responsePayload_1 = require("../../../responsePayload");
9
8
  const notificationPreferencesEndpoint_1 = require("../notificationPreferencesEndpoint");
@@ -17,19 +16,9 @@ const saveNotificationPreferencesEpic = (actions$, state$, zeniAPI) => actions$.
17
16
  // ignored, so stale success/failure actions cannot clobber the newer
18
17
  // batch's state. Server-side ordering is arrival-order LWW.
19
18
  (0, operators_1.switchMap)(([, state]) => {
20
- // A clean domain is omitted entirely: an empty patch is still a write against it.
21
- const overridesByDomain = {};
22
- const body = {};
23
- notificationRegistryState_1.NOTIFICATION_DOMAINS.forEach((domain) => {
24
- const overrides = (0, notificationPreferencesViewSelector_1.getNotificationLocalOverridesForDomain)(state, domain);
25
- const preferencesPatch = (0, notificationPreferencesViewPayload_1.mapPreferencesToPayload)(overrides);
26
- if (Object.keys(preferencesPatch).length === 0) {
27
- return;
28
- }
29
- overridesByDomain[domain] = overrides;
30
- body[`${domain}_preferences`] = preferencesPatch;
31
- });
32
- if (Object.keys(body).length === 0) {
19
+ const overrides = (0, notificationPreferencesViewSelector_1.getNotificationLocalOverrides)(state);
20
+ const preferencesPatch = (0, notificationPreferencesViewPayload_1.mapPreferencesToPayload)(overrides);
21
+ if (Object.keys(preferencesPatch).length === 0) {
33
22
  // No diff → do not dispatch a synthetic success (that would wipe
34
23
  // stored preferences via the reducer). Simply no-op.
35
24
  return rxjs_1.EMPTY;
@@ -42,6 +31,7 @@ const saveNotificationPreferencesEpic = (actions$, state$, zeniAPI) => actions$.
42
31
  // in-flight save's response (Success/Failure never dispatched, so
43
32
  // the counter never drained and future saves got their merge dropped).
44
33
  const cancelEpochAtDispatch = state.notificationPreferencesViewState.cancelEpoch;
34
+ const body = { task_checklist_preferences: preferencesPatch };
45
35
  // Suppress the error snackbar when the response lands AFTER the user
46
36
  // pressed Cancel — the Failure reducer already swallows the state
47
37
  // update, so the toast would be a stale error for a save the user
@@ -70,11 +60,8 @@ const saveNotificationPreferencesEpic = (actions$, state$, zeniAPI) => actions$.
70
60
  if ((0, responsePayload_1.isSuccessResponse)(response)) {
71
61
  return (0, rxjs_1.of)((0, notificationPreferencesViewReducer_1.saveNotificationPreferencesSuccess)({
72
62
  cancelEpochAtDispatch,
73
- savedOverridesByDomain: overridesByDomain,
74
- serverEchoByDomain: {
75
- task_checklist: response.data?.task_checklist_preferences,
76
- commenting: response.data?.commenting_preferences,
77
- },
63
+ savedOverrides: overrides,
64
+ serverEcho: response.data?.task_checklist_preferences,
78
65
  }));
79
66
  }
80
67
  const actions = [
@@ -1,33 +1,30 @@
1
- import { NotificationChannel, NotificationDomain, NotificationFrequency } from '../../entity/notificationRegistry/notificationRegistryState';
1
+ import { NotificationChannel, NotificationFrequency } from '../../entity/notificationRegistry/notificationRegistryState';
2
2
  import { ZeniAPIStatus } from '../../responsePayload';
3
3
  import { NotificationPreferencesPayload } from './notificationPreferencesViewPayload';
4
- import { NotificationPreferencesByDomain, NotificationPreferencesViewState } from './notificationPreferencesViewState';
4
+ import { NotificationPreferences, NotificationPreferencesViewState } from './notificationPreferencesViewState';
5
5
  export declare const initialState: NotificationPreferencesViewState;
6
6
  export interface SetFrequencyPayload {
7
7
  frequency: NotificationFrequency;
8
8
  groupId: string;
9
- domain?: NotificationDomain;
10
9
  }
11
10
  export interface TogglePreferencePayload {
12
11
  channel: NotificationChannel;
13
12
  enabled: boolean;
14
13
  eventId: string;
15
- domain?: NotificationDomain;
16
14
  }
17
15
  export interface SetGroupChannelMasterPayload {
18
16
  channel: NotificationChannel;
19
17
  enabled: boolean;
20
18
  groupId: string;
21
- domain?: NotificationDomain;
22
19
  }
23
20
  export interface FetchNotificationPreferencesSuccessPayload {
24
- preferencesByDomain: Partial<Record<NotificationDomain, NotificationPreferencesPayload | undefined>>;
21
+ preferences: NotificationPreferencesPayload | undefined;
25
22
  saveEpochAtDispatch: number;
26
23
  }
27
24
  export interface SaveNotificationPreferencesSuccessPayload {
28
25
  cancelEpochAtDispatch: number;
29
- savedOverridesByDomain: NotificationPreferencesByDomain;
30
- serverEchoByDomain: Partial<Record<NotificationDomain, NotificationPreferencesPayload | undefined>>;
26
+ savedOverrides: NotificationPreferences;
27
+ serverEcho: NotificationPreferencesPayload | undefined;
31
28
  }
32
29
  export interface SaveNotificationPreferencesFailurePayload {
33
30
  cancelEpochAtDispatch: number;
@@ -3,27 +3,16 @@ var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.toggleEventChannel = exports.setGroupFrequency = exports.setGroupChannelMaster = exports.saveNotificationPreferencesSuccess = exports.saveNotificationPreferencesFailure = exports.saveNotificationPreferences = exports.fetchNotificationPreferencesSuccess = exports.clearNotificationPreferencesLocalOverrides = exports.clearAllNotificationPreferencesView = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
- const notificationRegistryState_1 = require("../../entity/notificationRegistry/notificationRegistryState");
7
6
  const rootActions_1 = require("../../rootActions");
8
7
  const notificationPreferencesViewPayload_1 = require("./notificationPreferencesViewPayload");
9
8
  const notificationPreferencesViewState_1 = require("./notificationPreferencesViewState");
10
9
  exports.initialState = {
11
10
  cancelEpoch: 0,
12
- localOverridesByDomain: {},
13
- preferencesByDomain: {},
11
+ localOverrides: (0, notificationPreferencesViewState_1.emptyNotificationPreferences)(),
12
+ preferences: (0, notificationPreferencesViewState_1.emptyNotificationPreferences)(),
14
13
  saveEpoch: 0,
15
14
  savePreferencesState: { fetchState: 'Not-Started' },
16
15
  };
17
- // Lazy: a gate-off tenant never receives that domain's key at all.
18
- const overridesFor = (byDomain, domain) => {
19
- const existing = byDomain[domain];
20
- if (existing != null) {
21
- return existing;
22
- }
23
- const created = (0, notificationPreferencesViewState_1.emptyNotificationPreferences)();
24
- byDomain[domain] = created;
25
- return created;
26
- };
27
16
  const mergePreferences = (base, patch) => {
28
17
  const eventEnabledByChannel = {
29
18
  ...base.eventEnabledByChannel,
@@ -161,8 +150,7 @@ const notificationPreferencesView = (0, toolkit_1.createSlice)({
161
150
  // Success/Failure never dispatches, subsequent legitimate saves
162
151
  // still work because their captured epoch matches the current one.
163
152
  draft.cancelEpoch += 1;
164
- // One shared Save/Cancel footer, so Cancel discards every domain.
165
- draft.localOverridesByDomain = {};
153
+ draft.localOverrides = (0, notificationPreferencesViewState_1.emptyNotificationPreferences)();
166
154
  // Also drop `savePreferencesState` back to Not-Started so any
167
155
  // "Saving…" affordance bound to `getNotificationPreferencesSaveState`
168
156
  // clears on Cancel. Without this, a Cancel-during-save whose stale
@@ -179,6 +167,9 @@ const notificationPreferencesView = (0, toolkit_1.createSlice)({
179
167
  // them; the save-success path is the only clearer.
180
168
  // A `null`/`undefined` payload isn't a snapshot at all (e.g. the
181
169
  // envelope key was omitted); no-op instead of wiping preferences.
170
+ if (action.payload.preferences == null) {
171
+ return;
172
+ }
182
173
  // Stale-GET guard (Cursor Bugbot 3632510237): if the fetch epic
183
174
  // captured a `saveEpoch` lower than the current one, a save has
184
175
  // succeeded since this GET dispatched — the response is carrying
@@ -188,13 +179,7 @@ const notificationPreferencesView = (0, toolkit_1.createSlice)({
188
179
  if (action.payload.saveEpochAtDispatch < draft.saveEpoch) {
189
180
  return;
190
181
  }
191
- Object.entries(action.payload.preferencesByDomain).forEach(([domain, payload]) => {
192
- if (payload == null) {
193
- return;
194
- }
195
- draft.preferencesByDomain[domain] =
196
- (0, notificationPreferencesViewPayload_1.mapPayloadToPreferences)(payload);
197
- });
182
+ draft.preferences = (0, notificationPreferencesViewPayload_1.mapPayloadToPreferences)(action.payload.preferences);
198
183
  },
199
184
  saveNotificationPreferences(draft) {
200
185
  draft.savePreferencesState = { fetchState: 'In-Progress' };
@@ -253,44 +238,33 @@ const notificationPreferencesView = (0, toolkit_1.createSlice)({
253
238
  // skip the `preferences` replace. Cursor Bugbot 3632510237.
254
239
  draft.saveEpoch += 1;
255
240
  draft.savePreferencesState = { fetchState: 'Completed' };
256
- Object.entries(action.payload.savedOverridesByDomain).forEach(([rawDomain, savedOverrides]) => {
257
- if (savedOverrides == null) {
258
- return;
259
- }
260
- const domain = rawDomain;
261
- const serverEcho = action.payload.serverEchoByDomain[domain];
262
- const patch = serverEcho == null
263
- ? savedOverrides
264
- : (0, notificationPreferencesViewPayload_1.mapPayloadToPreferences)(serverEcho);
265
- draft.preferencesByDomain[domain] = mergePreferences(draft.preferencesByDomain[domain] ?? (0, notificationPreferencesViewState_1.emptyNotificationPreferences)(), patch);
266
- draft.localOverridesByDomain[domain] = subtractSavedOverrides(draft.localOverridesByDomain[domain] ??
267
- (0, notificationPreferencesViewState_1.emptyNotificationPreferences)(), savedOverrides);
268
- });
241
+ const patch = action.payload.serverEcho == null
242
+ ? action.payload.savedOverrides
243
+ : (0, notificationPreferencesViewPayload_1.mapPayloadToPreferences)(action.payload.serverEcho);
244
+ draft.preferences = mergePreferences(draft.preferences, patch);
245
+ draft.localOverrides = subtractSavedOverrides(draft.localOverrides, action.payload.savedOverrides);
269
246
  },
270
247
  setGroupChannelMaster(draft, action) {
271
248
  // Mirror of `toggleEventChannel` but scoped to the group-channel master
272
249
  // held under `groupChannelEnabledByGroupId[groupId][channel]`.
273
250
  const { channel, enabled, groupId } = action.payload;
274
- const overrides = overridesFor(draft.localOverridesByDomain, action.payload.domain ?? notificationRegistryState_1.DEFAULT_NOTIFICATION_DOMAIN);
275
251
  const groupMap = {
276
- ...(overrides.groupChannelEnabledByGroupId[groupId] ?? {}),
252
+ ...(draft.localOverrides.groupChannelEnabledByGroupId[groupId] ?? {}),
277
253
  };
278
254
  groupMap[channel] = enabled;
279
- overrides.groupChannelEnabledByGroupId[groupId] = groupMap;
255
+ draft.localOverrides.groupChannelEnabledByGroupId[groupId] = groupMap;
280
256
  },
281
257
  setGroupFrequency(draft, action) {
282
- const overrides = overridesFor(draft.localOverridesByDomain, action.payload.domain ?? notificationRegistryState_1.DEFAULT_NOTIFICATION_DOMAIN);
283
- overrides.groupFrequencyByGroupId[action.payload.groupId] =
258
+ draft.localOverrides.groupFrequencyByGroupId[action.payload.groupId] =
284
259
  action.payload.frequency;
285
260
  },
286
261
  toggleEventChannel(draft, action) {
287
262
  const { channel, enabled, eventId } = action.payload;
288
- const overrides = overridesFor(draft.localOverridesByDomain, action.payload.domain ?? notificationRegistryState_1.DEFAULT_NOTIFICATION_DOMAIN);
289
263
  const eventMap = {
290
- ...(overrides.eventEnabledByChannel[eventId] ?? {}),
264
+ ...(draft.localOverrides.eventEnabledByChannel[eventId] ?? {}),
291
265
  };
292
266
  eventMap[channel] = enabled;
293
- overrides.eventEnabledByChannel[eventId] = eventMap;
267
+ draft.localOverrides.eventEnabledByChannel[eventId] = eventMap;
294
268
  },
295
269
  },
296
270
  extraReducers: (builder) => {
@@ -1,11 +1,7 @@
1
1
  import { FetchStateAndError } from '../../commonStateTypes/common';
2
- import { NotificationDomain } from '../../entity/notificationRegistry/notificationRegistryState';
3
2
  import { RootState } from '../../rootStateTypes';
4
3
  import { NotificationPreferences } from './notificationPreferencesViewState';
5
4
  export declare const getNotificationPreferencesSaveState: (state: RootState) => FetchStateAndError;
6
- export declare const getEffectiveNotificationPreferencesForDomain: (state: RootState, domain: NotificationDomain) => NotificationPreferences;
7
5
  export declare const getEffectiveNotificationPreferences: (state: RootState) => NotificationPreferences;
8
- export declare const getNotificationLocalOverridesForDomain: (state: RootState, domain: NotificationDomain) => NotificationPreferences;
9
6
  export declare const getNotificationLocalOverrides: (state: RootState) => NotificationPreferences;
10
- export declare const hasUnsavedNotificationPreferencesForDomain: (state: RootState, domain: NotificationDomain) => boolean;
11
7
  export declare const hasUnsavedNotificationPreferences: (state: RootState) => boolean;
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasUnsavedNotificationPreferences = exports.hasUnsavedNotificationPreferencesForDomain = exports.getNotificationLocalOverrides = exports.getNotificationLocalOverridesForDomain = exports.getEffectiveNotificationPreferences = exports.getEffectiveNotificationPreferencesForDomain = exports.getNotificationPreferencesSaveState = void 0;
3
+ exports.hasUnsavedNotificationPreferences = exports.getNotificationLocalOverrides = exports.getEffectiveNotificationPreferences = exports.getNotificationPreferencesSaveState = void 0;
4
4
  const toolkit_1 = require("@reduxjs/toolkit");
5
- const notificationRegistryState_1 = require("../../entity/notificationRegistry/notificationRegistryState");
6
- const notificationPreferencesViewState_1 = require("./notificationPreferencesViewState");
7
5
  const getView = (state) => state.notificationPreferencesViewState;
8
6
  const getNotificationPreferencesSaveState = (state) => getView(state).savePreferencesState;
9
7
  exports.getNotificationPreferencesSaveState = getNotificationPreferencesSaveState;
@@ -11,12 +9,7 @@ exports.getNotificationPreferencesSaveState = getNotificationPreferencesSaveStat
11
9
  // stable reference while neither input changes — a plain function would
12
10
  // allocate a fresh object on every call and re-render every `useSelector`
13
11
  // consumer on any unrelated dispatch.
14
- const EMPTY_PREFERENCES = (0, notificationPreferencesViewState_1.emptyNotificationPreferences)();
15
- // One per domain: a shared createSelector has a cache of one and would thrash across two.
16
- const effectivePreferencesSelectorByDomain = new Map();
17
- const createEffectivePreferencesSelector = (domain) => (0, toolkit_1.createSelector)((state) => getView(state).preferencesByDomain[domain], (state) => getView(state).localOverridesByDomain[domain], (storedPreferences, storedOverrides) => {
18
- const preferences = storedPreferences ?? EMPTY_PREFERENCES;
19
- const localOverrides = storedOverrides ?? EMPTY_PREFERENCES;
12
+ exports.getEffectiveNotificationPreferences = (0, toolkit_1.createSelector)((state) => getView(state).preferences, (state) => getView(state).localOverrides, (preferences, localOverrides) => {
20
13
  const mergedEventEnabledByChannel = { ...preferences.eventEnabledByChannel };
21
14
  Object.entries(localOverrides.eventEnabledByChannel).forEach(([eventId, channels]) => {
22
15
  mergedEventEnabledByChannel[eventId] = {
@@ -40,26 +33,8 @@ const createEffectivePreferencesSelector = (domain) => (0, toolkit_1.createSelec
40
33
  },
41
34
  };
42
35
  });
43
- const getEffectiveNotificationPreferencesForDomain = (state, domain) => {
44
- let selector = effectivePreferencesSelectorByDomain.get(domain);
45
- if (selector == null) {
46
- selector = createEffectivePreferencesSelector(domain);
47
- effectivePreferencesSelectorByDomain.set(domain, selector);
48
- }
49
- return selector(state);
50
- };
51
- exports.getEffectiveNotificationPreferencesForDomain = getEffectiveNotificationPreferencesForDomain;
52
- const getEffectiveNotificationPreferences = (state) => (0, exports.getEffectiveNotificationPreferencesForDomain)(state, notificationRegistryState_1.DEFAULT_NOTIFICATION_DOMAIN);
53
- exports.getEffectiveNotificationPreferences = getEffectiveNotificationPreferences;
54
- const getNotificationLocalOverridesForDomain = (state, domain) => getView(state).localOverridesByDomain[domain] ?? EMPTY_PREFERENCES;
55
- exports.getNotificationLocalOverridesForDomain = getNotificationLocalOverridesForDomain;
56
- const getNotificationLocalOverrides = (state) => (0, exports.getNotificationLocalOverridesForDomain)(state, notificationRegistryState_1.DEFAULT_NOTIFICATION_DOMAIN);
36
+ const getNotificationLocalOverrides = (state) => getView(state).localOverrides;
57
37
  exports.getNotificationLocalOverrides = getNotificationLocalOverrides;
58
- const isDirty = (localOverrides) => Object.keys(localOverrides.eventEnabledByChannel).length > 0 ||
38
+ exports.hasUnsavedNotificationPreferences = (0, toolkit_1.createSelector)((state) => getView(state).localOverrides, (localOverrides) => Object.keys(localOverrides.eventEnabledByChannel).length > 0 ||
59
39
  Object.keys(localOverrides.groupChannelEnabledByGroupId).length > 0 ||
60
- Object.keys(localOverrides.groupFrequencyByGroupId).length > 0;
61
- const hasUnsavedNotificationPreferencesForDomain = (state, domain) => isDirty((0, exports.getNotificationLocalOverridesForDomain)(state, domain));
62
- exports.hasUnsavedNotificationPreferencesForDomain = hasUnsavedNotificationPreferencesForDomain;
63
- // Drives the shared page-level Save/Cancel footer.
64
- const hasUnsavedNotificationPreferences = (state) => Object.values(getView(state).localOverridesByDomain).some((localOverrides) => localOverrides != null && isDirty(localOverrides));
65
- exports.hasUnsavedNotificationPreferences = hasUnsavedNotificationPreferences;
40
+ Object.keys(localOverrides.groupFrequencyByGroupId).length > 0);
@@ -1,5 +1,5 @@
1
1
  import { FetchStateAndError } from '../../commonStateTypes/common';
2
- import { NotificationChannel, NotificationDomain, NotificationFrequency } from '../../entity/notificationRegistry/notificationRegistryState';
2
+ import { NotificationChannel, NotificationFrequency } from '../../entity/notificationRegistry/notificationRegistryState';
3
3
  export interface NotificationPreferences {
4
4
  eventEnabledByChannel: Record<string, Partial<Record<NotificationChannel, boolean>>>;
5
5
  groupChannelEnabledByGroupId: Record<string, Partial<Record<NotificationChannel, boolean>>>;
@@ -7,10 +7,9 @@ export interface NotificationPreferences {
7
7
  }
8
8
  export interface NotificationPreferencesViewState {
9
9
  cancelEpoch: number;
10
- localOverridesByDomain: NotificationPreferencesByDomain;
11
- preferencesByDomain: NotificationPreferencesByDomain;
10
+ localOverrides: NotificationPreferences;
11
+ preferences: NotificationPreferences;
12
12
  saveEpoch: number;
13
13
  savePreferencesState: FetchStateAndError;
14
14
  }
15
- export type NotificationPreferencesByDomain = Partial<Record<NotificationDomain, NotificationPreferences>>;
16
15
  export declare const emptyNotificationPreferences: () => NotificationPreferences;
@@ -41,21 +41,11 @@ const fetchNotificationSettingsEpic = (actions$, state$, zeniAPI) => actions$.pi
41
41
  // 67d6918e.
42
42
  updateActions.push((0, notificationRegistryReducer_1.updateNotificationRegistry)({
43
43
  registry: response.data.task_checklist_registry ?? undefined,
44
- // An absent `<domain>_registry` means that domain's gate is off.
45
- registriesByDomain: {
46
- task_checklist: response.data.task_checklist_registry ?? undefined,
47
- commenting: response.data.commenting_registry ?? undefined,
48
- },
49
44
  registryEpochAtDispatch,
50
45
  }));
51
- // One action so the domains cannot land on different store epochs.
52
- const preferencesByDomain = {
53
- task_checklist: response.data.task_checklist_preferences ?? undefined,
54
- commenting: response.data.commenting_preferences ?? undefined,
55
- };
56
- if (Object.values(preferencesByDomain).some((preferences) => preferences != null)) {
46
+ if (response.data.task_checklist_preferences != null) {
57
47
  updateActions.push((0, notificationPreferencesViewReducer_1.fetchNotificationPreferencesSuccess)({
58
- preferencesByDomain,
48
+ preferences: response.data.task_checklist_preferences,
59
49
  saveEpochAtDispatch,
60
50
  }));
61
51
  }
@@ -37,8 +37,6 @@ export interface NotificationSettingsPayload {
37
37
  pending_bill_approval_notification: RemindersPayload | null;
38
38
  pending_reimbursement_approval_notification: RemindersPayload | null;
39
39
  uncategorized_transaction_notification: RemindersPayload | null;
40
- commenting_preferences?: NotificationPreferencesPayload;
41
- commenting_registry?: NotificationRegistryPayload;
42
40
  month_end_email_recipient_email_ids?: string[];
43
41
  task_checklist_preferences?: NotificationPreferencesPayload;
44
42
  task_checklist_registry?: NotificationRegistryPayload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.2.49-beta0ND",
3
+ "version": "5.2.49-betaAK0",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",