@xh/hoist 71.0.0-SNAPSHOT.1736185761842 → 71.0.0-SNAPSHOT.1736187551916

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.
@@ -183,7 +183,9 @@ export declare class ViewManagerModel<T = PlainObject> extends HoistModel {
183
183
  */
184
184
  private constructor();
185
185
  doLoadAsync(loadSpec: LoadSpec): Promise<void>;
186
- selectViewAsync(info: ViewInfo): Promise<void>;
186
+ selectViewAsync(info: ViewInfo, opts?: {
187
+ alertUnsavedChanges: boolean;
188
+ }): Promise<void>;
187
189
  saveAsAsync(spec: ViewCreateSpec): Promise<void>;
188
190
  saveAsync(): Promise<void>;
189
191
  resetAsync(): Promise<void>;
@@ -346,18 +346,23 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
346
346
  }
347
347
  }
348
348
 
349
- async selectViewAsync(info: ViewInfo): Promise<void> {
349
+ async selectViewAsync(info: ViewInfo, opts = {alertUnsavedChanges: true}): Promise<void> {
350
350
  // ensure any pending auto-save gets completed
351
351
  if (this.isValueDirty && this.isViewAutoSavable) {
352
352
  await this.maybeAutoSaveAsync();
353
353
  }
354
354
 
355
355
  // if still dirty, require confirm
356
- if (this.isValueDirty && this.view.isOwned && !(await this.confirmDiscardChangesAsync())) {
356
+ if (
357
+ opts.alertUnsavedChanges &&
358
+ this.isValueDirty &&
359
+ this.view.isOwned &&
360
+ !(await this.confirmDiscardChangesAsync())
361
+ ) {
357
362
  return;
358
363
  }
359
364
 
360
- return this.loadViewAsync(info);
365
+ await this.loadViewAsync(info).catch(e => this.handleException(e));
361
366
  }
362
367
 
363
368
  async saveAsAsync(spec: ViewCreateSpec): Promise<void> {
@@ -63,7 +63,7 @@ function getNavMenuItems(model: ViewManagerModel): ReactNode[] {
63
63
  className: 'xh-view-manager__menu-item',
64
64
  icon: view.isDefault ? Icon.check() : Icon.placeholder(),
65
65
  text: `Default ${startCase(typeDisplayName)}`,
66
- onClick: () => model.selectViewAsync(null).catchDefault()
66
+ onClick: () => model.selectViewAsync(null)
67
67
  })
68
68
  );
69
69
  }
@@ -168,6 +168,6 @@ function viewMenuItem(view: ViewInfo, model: ViewManagerModel): ReactNode {
168
168
  text: view.name,
169
169
  title: title.join(' | '),
170
170
  icon,
171
- onClick: () => model.selectViewAsync(view).catchDefault()
171
+ onClick: () => model.selectViewAsync(view)
172
172
  });
173
173
  }
@@ -86,7 +86,7 @@ export class ManageDialogModel extends HoistModel {
86
86
  }
87
87
 
88
88
  activateSelectedViewAndClose() {
89
- this.viewManagerModel.selectViewAsync(this.selectedView).catchDefault();
89
+ this.viewManagerModel.selectViewAsync(this.selectedView);
90
90
  this.close();
91
91
  }
92
92
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "71.0.0-SNAPSHOT.1736185761842",
3
+ "version": "71.0.0-SNAPSHOT.1736187551916",
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",