@xh/hoist 74.0.0-SNAPSHOT.1748338432179 → 74.0.0-SNAPSHOT.1748339158877

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;
@@ -204,7 +198,6 @@ export declare class ViewManagerModel<T = PlainObject> extends HoistModel {
204
198
  resetAsync(): Promise<void>;
205
199
  getValue(): Partial<T>;
206
200
  setValue(value: Partial<T>): void;
207
- noteStatePushed(): void;
208
201
  userPin(view: ViewInfo): void;
209
202
  userUnpin(view: ViewInfo): void;
210
203
  isUserPinned(view: ViewInfo): boolean | null;
@@ -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,14 +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
- if (!isEqual(value, view.settledValue)) {
429
+ value = this.cleanState(value);
430
+ if (!isEqual(value, view.value)) {
441
431
  this.pendingValue = {
442
432
  token: pendingValue ? pendingValue.token : view.token,
443
433
  baseUpdated: pendingValue ? pendingValue.baseUpdated : view.lastUpdated,
@@ -448,10 +438,6 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
448
438
  }
449
439
  }
450
440
 
451
- noteStatePushed() {
452
- this.lastPushed = Date.now();
453
- }
454
-
455
441
  //------------------
456
442
  // Pinning
457
443
  //------------------
@@ -529,9 +515,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
529
515
  this.views = views;
530
516
  this.userPinned = state.userPinned;
531
517
  this.autoSave = state.autoSave;
532
- if (this.preserveUnsavedChanges) {
533
- this.pendingValue = XH.sessionStorageService.get(pendingValueStorageKey);
534
- }
518
+ this.pendingValue = XH.sessionStorageService.get(pendingValueStorageKey);
535
519
  });
536
520
 
537
521
  // 2) Initialize/choose initial view. Null is ok, and will yield default.
@@ -562,10 +546,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
562
546
  private pendingValueReaction(): ReactionSpec {
563
547
  return {
564
548
  track: () => this.pendingValue,
565
- run: v => {
566
- if (!this.preserveUnsavedChanges) return;
567
- XH.sessionStorageService.set(this.pendingValueStorageKey, v);
568
- }
549
+ run: v => XH.sessionStorageService.set(this.pendingValueStorageKey, v)
569
550
  };
570
551
  }
571
552
 
@@ -607,6 +588,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
607
588
  .thenAction(latest => {
608
589
  this.setAsView(latest, pendingValue?.token == token ? pendingValue : null);
609
590
  this.providers.forEach(it => it.pushStateToTarget());
591
+ this.lastPushed = Date.now();
610
592
  })
611
593
  .linkTo(this.selectTask);
612
594
  }
@@ -19,13 +19,11 @@ export class ViewManagerProvider<S> extends PersistenceProvider<S> {
19
19
  throwIf(!viewManagerModel, `ViewManagerProvider requires a 'viewManagerModel'.`);
20
20
  this.viewManagerModel = viewManagerModel;
21
21
  viewManagerModel.providers.push(this);
22
- viewManagerModel.noteStatePushed();
23
22
  }
24
23
 
25
24
  pushStateToTarget() {
26
25
  const state = this.read();
27
26
  this.target.setPersistableState(state ? state : this.defaultState);
28
- this.viewManagerModel.noteStatePushed();
29
27
  }
30
28
 
31
29
  //----------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "74.0.0-SNAPSHOT.1748338432179",
3
+ "version": "74.0.0-SNAPSHOT.1748339158877",
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",