@xh/hoist 71.0.0-SNAPSHOT.1733372979467 → 71.0.0-SNAPSHOT.1733376295239
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/ViewManagerModel.d.ts +1 -1
- package/build/types/cmp/viewmanager/ViewToBlobApi.d.ts +2 -1
- package/cmp/viewmanager/ViewManagerModel.ts +41 -41
- package/cmp/viewmanager/ViewToBlobApi.ts +20 -2
- package/desktop/cmp/viewmanager/dialog/ManageDialogModel.ts +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -156,7 +156,6 @@ export declare class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
156
156
|
* initial load before binding to persistable components.
|
|
157
157
|
*/
|
|
158
158
|
private constructor();
|
|
159
|
-
private initAsync;
|
|
160
159
|
doLoadAsync(loadSpec: LoadSpec): Promise<void>;
|
|
161
160
|
selectViewAsync(info: ViewInfo): Promise<void>;
|
|
162
161
|
saveAsync(): Promise<void>;
|
|
@@ -171,6 +170,7 @@ export declare class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
171
170
|
openManageDialog(): void;
|
|
172
171
|
closeManageDialog(): void;
|
|
173
172
|
validateViewNameAsync(name: string, existing?: ViewInfo): Promise<string>;
|
|
173
|
+
private initAsync;
|
|
174
174
|
private loadViewAsync;
|
|
175
175
|
private maybeAutoSaveAsync;
|
|
176
176
|
private setAsView;
|
|
@@ -13,6 +13,7 @@ export declare class ViewToBlobApi<T> {
|
|
|
13
13
|
fetchViewInfosAsync(): Promise<ViewInfo[]>;
|
|
14
14
|
fetchViewAsync(info: ViewInfo): Promise<View<T>>;
|
|
15
15
|
createViewAsync(name: string, description: string, value: PlainObject): Promise<View<T>>;
|
|
16
|
-
|
|
16
|
+
updateViewInfoAsync(view: ViewInfo, name: string, description: string, isGlobal: boolean): Promise<View<T>>;
|
|
17
|
+
updateViewValueAsync(view: View<T>, value: Partial<T>): Promise<View<T>>;
|
|
17
18
|
deleteViewAsync(view: ViewInfo): Promise<void>;
|
|
18
19
|
}
|
|
@@ -291,34 +291,6 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
291
291
|
this.api = new ViewToBlobApi(this);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
private async initAsync() {
|
|
295
|
-
try {
|
|
296
|
-
const views = await this.api.fetchViewInfosAsync();
|
|
297
|
-
runInAction(() => (this.views = views));
|
|
298
|
-
|
|
299
|
-
if (this.persistWith) {
|
|
300
|
-
this.initPersist(this.persistWith);
|
|
301
|
-
await when(() => !this.selectTask.isPending);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// If the initial view not initialized from persistence, assign it.
|
|
305
|
-
if (!this.view) {
|
|
306
|
-
await this.loadViewAsync(this.initialViewSpec?.(views), this.pendingValue);
|
|
307
|
-
}
|
|
308
|
-
} catch (e) {
|
|
309
|
-
// Always ensure at least default view is installed.
|
|
310
|
-
if (!this.view) this.loadViewAsync(null, this.pendingValue);
|
|
311
|
-
|
|
312
|
-
this.handleException(e, {showAlert: false, logOnServer: true});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
this.addReaction({
|
|
316
|
-
track: () => [this.pendingValue, this.autoSave],
|
|
317
|
-
run: () => this.maybeAutoSaveAsync(),
|
|
318
|
-
debounce: 5 * SECONDS
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
|
|
322
294
|
override async doLoadAsync(loadSpec: LoadSpec) {
|
|
323
295
|
try {
|
|
324
296
|
// 1) Update all view info
|
|
@@ -358,21 +330,20 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
358
330
|
this.logError('Unexpected conditions for call to save, skipping');
|
|
359
331
|
return;
|
|
360
332
|
}
|
|
361
|
-
const {pendingValue} = this
|
|
362
|
-
{info} = this.view;
|
|
333
|
+
const {pendingValue, view, api} = this;
|
|
363
334
|
try {
|
|
364
|
-
if (!(await this.maybeConfirmSaveAsync(info, pendingValue))) {
|
|
335
|
+
if (!(await this.maybeConfirmSaveAsync(view.info, pendingValue))) {
|
|
365
336
|
return;
|
|
366
337
|
}
|
|
367
|
-
const
|
|
368
|
-
.
|
|
338
|
+
const updated = await api
|
|
339
|
+
.updateViewValueAsync(view, pendingValue.value)
|
|
369
340
|
.linkTo(this.saveTask);
|
|
370
341
|
|
|
371
|
-
this.setAsView(
|
|
372
|
-
this.noteSuccess(`Saved ${info.typedName}`);
|
|
342
|
+
this.setAsView(updated);
|
|
343
|
+
this.noteSuccess(`Saved ${view.info.typedName}`);
|
|
373
344
|
} catch (e) {
|
|
374
345
|
this.handleException(e, {
|
|
375
|
-
message: `Failed to save ${info.typedName}. If this persists consider \`Save As...\`.`
|
|
346
|
+
message: `Failed to save ${view.info.typedName}. If this persists consider \`Save As...\`.`
|
|
376
347
|
});
|
|
377
348
|
}
|
|
378
349
|
this.refreshAsync();
|
|
@@ -468,6 +439,34 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
468
439
|
//------------------
|
|
469
440
|
// Implementation
|
|
470
441
|
//------------------
|
|
442
|
+
private async initAsync() {
|
|
443
|
+
try {
|
|
444
|
+
const views = await this.api.fetchViewInfosAsync();
|
|
445
|
+
runInAction(() => (this.views = views));
|
|
446
|
+
|
|
447
|
+
if (this.persistWith) {
|
|
448
|
+
this.initPersist(this.persistWith);
|
|
449
|
+
await when(() => !this.selectTask.isPending);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// If the initial view not initialized from persistence, assign it.
|
|
453
|
+
if (!this.view) {
|
|
454
|
+
await this.loadViewAsync(this.initialViewSpec?.(views), this.pendingValue);
|
|
455
|
+
}
|
|
456
|
+
} catch (e) {
|
|
457
|
+
// Always ensure at least default view is installed.
|
|
458
|
+
if (!this.view) this.loadViewAsync(null, this.pendingValue);
|
|
459
|
+
|
|
460
|
+
this.handleException(e, {showAlert: false, logOnServer: true});
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
this.addReaction({
|
|
464
|
+
track: () => [this.pendingValue, this.autoSave],
|
|
465
|
+
run: () => this.maybeAutoSaveAsync(),
|
|
466
|
+
debounce: 5 * SECONDS
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
|
|
471
470
|
private async loadViewAsync(
|
|
472
471
|
info: ViewInfo,
|
|
473
472
|
pendingValue: PendingValue<T> = null
|
|
@@ -483,18 +482,19 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
|
|
|
483
482
|
}
|
|
484
483
|
|
|
485
484
|
private async maybeAutoSaveAsync() {
|
|
486
|
-
const {pendingValue, isViewAutoSavable, view} = this;
|
|
485
|
+
const {pendingValue, isViewAutoSavable, view, api} = this;
|
|
487
486
|
if (isViewAutoSavable && pendingValue) {
|
|
488
487
|
try {
|
|
489
|
-
const
|
|
490
|
-
.
|
|
488
|
+
const updated = await api
|
|
489
|
+
.updateViewValueAsync(view, pendingValue.value)
|
|
491
490
|
.linkTo(this.saveTask);
|
|
492
|
-
|
|
491
|
+
|
|
492
|
+
this.setAsView(updated);
|
|
493
493
|
} catch (e) {
|
|
494
494
|
// TODO: How to alert but avoid for flaky or spam when user editing a deleted view
|
|
495
495
|
// Keep count and alert server and user once at count n?
|
|
496
496
|
XH.handleException(e, {
|
|
497
|
-
message: `Failing AutoSave for ${
|
|
497
|
+
message: `Failing AutoSave for ${view.info.typedName}`,
|
|
498
498
|
showAlert: false,
|
|
499
499
|
logOnServer: false
|
|
500
500
|
});
|
|
@@ -70,18 +70,36 @@ export class ViewToBlobApi<T> {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
async
|
|
73
|
+
async updateViewInfoAsync(
|
|
74
|
+
view: ViewInfo,
|
|
75
|
+
name: string,
|
|
76
|
+
description: string,
|
|
77
|
+
isGlobal: boolean
|
|
78
|
+
): Promise<View<T>> {
|
|
74
79
|
try {
|
|
75
|
-
await XH.jsonBlobService.updateAsync(view.token, {
|
|
80
|
+
const blob = await XH.jsonBlobService.updateAsync(view.token, {
|
|
76
81
|
name: name.trim(),
|
|
77
82
|
description: description?.trim(),
|
|
78
83
|
acl: isGlobal ? '*' : null
|
|
79
84
|
});
|
|
85
|
+
return View.fromBlob(blob, this.owner);
|
|
80
86
|
} catch (e) {
|
|
81
87
|
throw XH.exception({message: `Unable to update ${view.typedName}`, cause: e});
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
90
|
|
|
91
|
+
async updateViewValueAsync(view: View<T>, value: Partial<T>): Promise<View<T>> {
|
|
92
|
+
try {
|
|
93
|
+
const blob = await XH.jsonBlobService.updateAsync(view.token, {value});
|
|
94
|
+
return View.fromBlob(blob, this.owner);
|
|
95
|
+
} catch (e) {
|
|
96
|
+
throw XH.exception({
|
|
97
|
+
message: `Unable to update value for ${view.info.typedName}`,
|
|
98
|
+
cause: e
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
85
103
|
async deleteViewAsync(view: ViewInfo) {
|
|
86
104
|
try {
|
|
87
105
|
await XH.jsonBlobService.archiveAsync(view.token);
|
|
@@ -158,7 +158,7 @@ export class ManageDialogModel extends HoistModel {
|
|
|
158
158
|
) {
|
|
159
159
|
const {viewManagerModel} = this;
|
|
160
160
|
|
|
161
|
-
await viewManagerModel.api.
|
|
161
|
+
await viewManagerModel.api.updateViewInfoAsync(view, name, description, isGlobal);
|
|
162
162
|
await viewManagerModel.refreshAsync();
|
|
163
163
|
await this.refreshAsync();
|
|
164
164
|
|
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.1733376295239",
|
|
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",
|