@xh/hoist 71.0.0-SNAPSHOT.1736198138276 → 71.0.0-SNAPSHOT.1736198397776
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.
- package/build/types/cmp/viewmanager/DataAccess.d.ts +1 -1
- package/build/types/cmp/viewmanager/ViewManagerModel.d.ts +1 -1
- package/cmp/viewmanager/DataAccess.ts +4 -4
- package/cmp/viewmanager/ViewManagerModel.ts +9 -9
- package/desktop/cmp/viewmanager/ViewMenu.ts +2 -2
- package/desktop/cmp/viewmanager/dialog/ManageDialogModel.ts +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -15,7 +15,7 @@ export declare class DataAccess<T> {
|
|
|
15
15
|
state: ViewUserState;
|
|
16
16
|
}>;
|
|
17
17
|
/** Fetch the latest version of a view. */
|
|
18
|
-
fetchViewAsync(
|
|
18
|
+
fetchViewAsync(info: ViewInfo): Promise<View<T>>;
|
|
19
19
|
/** Create a new view, owned by the current user.*/
|
|
20
20
|
createViewAsync(spec: ViewCreateSpec): Promise<View<T>>;
|
|
21
21
|
/** Update all aspects of a view's metadata.*/
|
|
@@ -183,7 +183,7 @@ export declare class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
183
183
|
*/
|
|
184
184
|
private constructor();
|
|
185
185
|
doLoadAsync(loadSpec: LoadSpec): Promise<void>;
|
|
186
|
-
selectViewAsync(
|
|
186
|
+
selectViewAsync(info: ViewInfo, opts?: {
|
|
187
187
|
alertUnsavedChanges: boolean;
|
|
188
188
|
}): Promise<void>;
|
|
189
189
|
saveAsAsync(spec: ViewCreateSpec): Promise<void>;
|
|
@@ -48,14 +48,14 @@ export class DataAccess<T> {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/** Fetch the latest version of a view. */
|
|
51
|
-
async fetchViewAsync(
|
|
51
|
+
async fetchViewAsync(info: ViewInfo): Promise<View<T>> {
|
|
52
52
|
const {model} = this;
|
|
53
|
-
if (!
|
|
53
|
+
if (!info) return View.createDefault(model);
|
|
54
54
|
try {
|
|
55
|
-
const raw = await XH.fetchJson({url: 'xhView/get', params: {token}});
|
|
55
|
+
const raw = await XH.fetchJson({url: 'xhView/get', params: {token: info.token}});
|
|
56
56
|
return View.fromBlob(raw, model);
|
|
57
57
|
} catch (e) {
|
|
58
|
-
throw XH.exception({message: `Unable to fetch
|
|
58
|
+
throw XH.exception({message: `Unable to fetch ${info.typedName}`, cause: e});
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -337,7 +337,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
337
337
|
if (!view.isDefault) {
|
|
338
338
|
const latestInfo = find(views, {token: view.token});
|
|
339
339
|
if (latestInfo && latestInfo.lastUpdated > view.lastUpdated) {
|
|
340
|
-
this.loadViewAsync(
|
|
340
|
+
this.loadViewAsync(latestInfo, this.pendingValue);
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
} catch (e) {
|
|
@@ -346,7 +346,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
async selectViewAsync(
|
|
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();
|
|
@@ -362,7 +362,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
362
362
|
return;
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
-
|
|
365
|
+
await this.loadViewAsync(info).catch(e => this.handleException(e));
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
async saveAsAsync(spec: ViewCreateSpec): Promise<void> {
|
|
@@ -399,7 +399,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
async resetAsync(): Promise<void> {
|
|
402
|
-
await this.loadViewAsync(this.view.info
|
|
402
|
+
await this.loadViewAsync(this.view.info).catch(e => this.handleException(e));
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
//--------------------------------
|
|
@@ -483,7 +483,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
483
483
|
const {views} = this;
|
|
484
484
|
|
|
485
485
|
if (toDelete.some(view => view.isCurrentView) && !views.some(view => view.isCurrentView)) {
|
|
486
|
-
await this.loadViewAsync(this.initialViewSpec?.(views)
|
|
486
|
+
await this.loadViewAsync(this.initialViewSpec?.(views));
|
|
487
487
|
}
|
|
488
488
|
|
|
489
489
|
if (exception) throw exception;
|
|
@@ -569,13 +569,13 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
569
569
|
}
|
|
570
570
|
|
|
571
571
|
private async loadViewAsync(
|
|
572
|
-
|
|
572
|
+
info: ViewInfo,
|
|
573
573
|
pendingValue: PendingValue<T> = null
|
|
574
574
|
): Promise<void> {
|
|
575
575
|
return this.dataAccess
|
|
576
|
-
.fetchViewAsync(
|
|
576
|
+
.fetchViewAsync(info)
|
|
577
577
|
.thenAction(latest => {
|
|
578
|
-
this.setAsView(latest, pendingValue?.token == token ? pendingValue : null);
|
|
578
|
+
this.setAsView(latest, pendingValue?.token == info?.token ? pendingValue : null);
|
|
579
579
|
this.providers.forEach(it => it.pushStateToTarget());
|
|
580
580
|
this.lastPushed = Date.now();
|
|
581
581
|
})
|
|
@@ -649,7 +649,7 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
649
649
|
|
|
650
650
|
private async maybeConfirmSaveAsync(view: View, pendingValue: PendingValue<T>) {
|
|
651
651
|
// Get latest from server for reference
|
|
652
|
-
const latest = await this.dataAccess.fetchViewAsync(view.info
|
|
652
|
+
const latest = await this.dataAccess.fetchViewAsync(view.info),
|
|
653
653
|
isGlobal = latest.isGlobal,
|
|
654
654
|
isStale = latest.lastUpdated > pendingValue.baseUpdated;
|
|
655
655
|
if (!isStale && !isGlobal) return true;
|
|
@@ -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)
|
|
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
|
|
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
|
|
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.
|
|
3
|
+
"version": "71.0.0-SNAPSHOT.1736198397776",
|
|
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",
|