@xh/hoist 74.0.0-SNAPSHOT.1748001673599 → 74.0.0-SNAPSHOT.1748002015150

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.
@@ -17,11 +17,6 @@ export declare class View<T extends PlainObject = PlainObject> {
17
17
  * state of the components is captured.
18
18
  */
19
19
  readonly value: Partial<T>;
20
- /**
21
- * Defaulted to value, but may be updated during ViewManagerModel's settleTime to be
22
- * the "settled" state after loading. Used for comparison to determine dirtiness.
23
- */
24
- settledValue: Partial<T>;
25
20
  private readonly model;
26
21
  get name(): string;
27
22
  get group(): string;
@@ -43,11 +43,6 @@ export interface ViewManagerConfig {
43
43
  * True (default) to allow users to share their views with other users.
44
44
  */
45
45
  enableSharing?: boolean;
46
- /**
47
- * True (default) to save pending state to SessionStorage so that it can be restored across
48
- * browser refreshes. Unlike auto-save, this does not write to the database.
49
- */
50
- preserveUnsavedChanges?: boolean;
51
46
  /**
52
47
  * Function to determine the initial view for a user, when no view has already been persisted.
53
48
  * Will be passed a list of views available to the current user. Implementations where
@@ -137,7 +132,6 @@ export declare class ViewManagerModel<T = PlainObject> extends HoistModel {
137
132
  readonly enableDefault: boolean;
138
133
  readonly enableGlobal: boolean;
139
134
  readonly enableSharing: boolean;
140
- readonly preserveUnsavedChanges: boolean;
141
135
  readonly manageGlobal: boolean;
142
136
  readonly settleTime: number;
143
137
  readonly initialViewSpec: (views: ViewInfo[]) => ViewInfo;
@@ -27,12 +27,6 @@ export class View<T extends PlainObject = PlainObject> {
27
27
  */
28
28
  readonly value: Partial<T> = null;
29
29
 
30
- /**
31
- * Defaulted to value, but may be updated during ViewManagerModel's settleTime to be
32
- * the "settled" state after loading. Used for comparison to determine dirtiness.
33
- */
34
- settledValue: Partial<T> = null;
35
-
36
30
  private readonly model: ViewManagerModel;
37
31
 
38
32
  get name(): string {
@@ -98,7 +92,6 @@ export class View<T extends PlainObject = PlainObject> {
98
92
  constructor(info: ViewInfo, value: Partial<T>, model: ViewManagerModel) {
99
93
  this.info = info;
100
94
  this.value = value;
101
- this.settledValue = value;
102
95
  this.model = model;
103
96
  }
104
97
  }
@@ -74,12 +74,6 @@ export interface ViewManagerConfig {
74
74
  */
75
75
  enableSharing?: boolean;
76
76
 
77
- /**
78
- * True (default) to save pending state to SessionStorage so that it can be restored across
79
- * browser refreshes. Unlike auto-save, this does not write to the database.
80
- */
81
- preserveUnsavedChanges?: boolean;
82
-
83
77
  /**
84
78
  * Function to determine the initial view for a user, when no view has already been persisted.
85
79
  * Will be passed a list of views available to the current user. Implementations where
@@ -182,7 +176,6 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
182
176
  readonly enableDefault: boolean;
183
177
  readonly enableGlobal: boolean;
184
178
  readonly enableSharing: boolean;
185
- readonly preserveUnsavedChanges: boolean;
186
179
  readonly manageGlobal: boolean;
187
180
  readonly settleTime: number;
188
181
  readonly initialViewSpec: (views: ViewInfo[]) => ViewInfo;
@@ -303,7 +296,6 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
303
296
  enableDefault = true,
304
297
  enableGlobal = true,
305
298
  enableSharing = true,
306
- preserveUnsavedChanges = true,
307
299
  settleTime = 1000,
308
300
  initialViewSpec = null
309
301
  }: ViewManagerConfig) {
@@ -325,7 +317,6 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
325
317
  this.enableGlobal = enableGlobal;
326
318
  this.enableSharing = enableSharing;
327
319
  this.enableAutoSave = enableAutoSave;
328
- this.preserveUnsavedChanges = preserveUnsavedChanges;
329
320
  this.settleTime = settleTime;
330
321
  this.initialViewSpec = initialViewSpec;
331
322
 
@@ -430,15 +421,13 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
430
421
 
431
422
  @action
432
423
  setValue(value: Partial<T>) {
433
- value = this.cleanState(value);
434
-
435
424
  const {view, pendingValue, lastPushed, settleTime} = this;
436
425
  if (!pendingValue && settleTime && !olderThan(lastPushed, settleTime)) {
437
- this.view.settledValue = value;
426
+ return;
438
427
  }
439
428
 
440
- // Todo: Consider how this interacts with the localStorage pending state
441
- if (!isEqual(value, view.settledValue)) {
429
+ value = this.cleanState(value);
430
+ if (!isEqual(value, view.value)) {
442
431
  this.pendingValue = {
443
432
  token: pendingValue ? pendingValue.token : view.token,
444
433
  baseUpdated: pendingValue ? pendingValue.baseUpdated : view.lastUpdated,
@@ -526,9 +515,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
526
515
  this.views = views;
527
516
  this.userPinned = state.userPinned;
528
517
  this.autoSave = state.autoSave;
529
- if (this.preserveUnsavedChanges) {
530
- this.pendingValue = XH.sessionStorageService.get(pendingValueStorageKey);
531
- }
518
+ this.pendingValue = XH.sessionStorageService.get(pendingValueStorageKey);
532
519
  });
533
520
 
534
521
  // 2) Initialize/choose initial view. Null is ok, and will yield default.
@@ -559,10 +546,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
559
546
  private pendingValueReaction(): ReactionSpec {
560
547
  return {
561
548
  track: () => this.pendingValue,
562
- run: v => {
563
- if (!this.preserveUnsavedChanges) return;
564
- XH.sessionStorageService.set(this.pendingValueStorageKey, v);
565
- }
549
+ run: v => XH.sessionStorageService.set(this.pendingValueStorageKey, v)
566
550
  };
567
551
  }
568
552
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "74.0.0-SNAPSHOT.1748001673599",
3
+ "version": "74.0.0-SNAPSHOT.1748002015150",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",