Skip to content

Commit 9caeecf

Browse files
committed
fix confirmation error using async await (change target to ES2017)
1 parent b77dcbf commit 9caeecf

File tree

9 files changed

+44
-33
lines changed

9 files changed

+44
-33
lines changed

Signum.React.Extensions/Workflow/Case/CaseFrameModal.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,17 @@ export default class CaseFrameModal extends React.Component<CaseFrameModalProps,
179179
allowExchangeEntity: false,
180180
prefix: this.prefix,
181181
isExecuting: () => this.state.executing == true,
182-
execute: action => {
182+
execute: async action => {
183183
if (this.state.executing)
184184
return;
185185

186186
this.setState({ executing: true });
187-
action()
188-
.finally(() => this.setState({ executing: undefined }))
189-
.done();
187+
try {
188+
await action();
189+
} finally {
190+
this.setState({ executing: undefined });
191+
}
190192
}
191-
192193
};
193194

194195
var activityPack = { entity: pack.activity, canExecute: pack.canExecuteActivity };
@@ -243,15 +244,16 @@ export default class CaseFrameModal extends React.Component<CaseFrameModalProps,
243244
allowExchangeEntity: false,
244245
prefix: this.prefix,
245246
isExecuting: () => this.state.executing == true,
246-
execute: action => {
247+
execute: async action => {
247248
if (this.state.executing)
248249
return;
249250

250251
this.setState({ executing: true });
251-
252-
action()
253-
.finally(() => this.setState({ executing: undefined }))
254-
.done();
252+
try {
253+
await action();
254+
} finally {
255+
this.setState({ executing: undefined })
256+
}
255257
}
256258
};
257259

Signum.React.Extensions/Workflow/Case/CaseFramePage.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,16 @@ export default class CaseFramePage extends React.Component<CaseFramePageProps, C
164164
allowExchangeEntity: false,
165165
prefix: "caseFrame",
166166
isExecuting: () => this.state.executing == true,
167-
execute: action => {
167+
execute: async action => {
168168
if (this.state.executing)
169169
return;
170170

171171
this.setState({ executing: true });
172-
action()
173-
.finally(() => { this.setState({ executing: undefined }) })
174-
.done();
172+
try {
173+
await action();
174+
} finally {
175+
this.setState({ executing: undefined });
176+
}
175177
}
176178
};
177179

@@ -245,14 +247,16 @@ export default class CaseFramePage extends React.Component<CaseFramePageProps, C
245247
allowExchangeEntity: false,
246248
prefix: "caseFrame",
247249
isExecuting: () => this.state.executing == true,
248-
execute: action => {
250+
execute: async action => {
249251
if (this.state.executing)
250252
return;
251253

252254
this.setState({ executing: true });
253-
action()
254-
.finally(() => this.setState({ executing: undefined }))
255-
.done();
255+
try {
256+
await action();
257+
} finally {
258+
this.setState({ executing: undefined });
259+
}
256260
}
257261
};
258262

Signum.React.Extensions/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
3+
"target": "ES2017",
44
"sourceMap": true,
55
"module": "esnext",
66
"moduleResolution": "node",

Signum.React/Scripts/Frames/FrameModal.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,18 +265,19 @@ export const FrameModal = React.forwardRef(function FrameModal(p: FrameModalProp
265265
allowExchangeEntity: p.buttons == "close" && (p.allowExchangeEntity ?? true),
266266
prefix: prefix,
267267
isExecuting: () => pc.executing == true,
268-
execute: action => {
268+
execute: async action => {
269269
if (pc.executing)
270270
return;
271271

272272
pc.executing = true;
273273
forceUpdate();
274-
action()
275-
.finally(() => {
276-
pc.executing = undefined;
277-
forceUpdate();
278-
})
279-
.done();
274+
try {
275+
await action();
276+
277+
} finally {
278+
pc.executing = undefined;
279+
forceUpdate();
280+
}
280281
}
281282
};
282283

Signum.React/Scripts/Frames/FramePage.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,18 @@ export default function FramePage(p: FramePageProps) {
182182
entityComponent: entityComponent.current,
183183
pack: state.pack,
184184
isExecuting: () => state.executing == true,
185-
execute: action => {
185+
execute: async action => {
186186
if (state.executing)
187187
return;
188188

189189
state.executing = true;
190190
forceUpdate();
191-
action()
192-
.finally(() => { state.executing = undefined; forceUpdate(); }).done();
191+
try {
192+
await action();
193+
} finally {
194+
state.executing = undefined;
195+
forceUpdate();
196+
}
193197
},
194198
onReload: (pack, reloadComponent, callback) => {
195199

Signum.React/Scripts/Operations.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ export class EntityOperationContext<T extends Entity> {
410410
return this.settings.onClick(this);
411411
else
412412
return defaultOnClick(this);
413-
});
413+
}).done();
414414
}
415415

416416
textOrNiceName() {

Signum.React/Scripts/Reflection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ export function createBinding(parentValue: any, lambdaMembers: LambdaMember[]):
892892

893893

894894
const functionRegex = /^function\s*\(\s*([$a-zA-Z_][0-9a-zA-Z_$]*)\s*\)\s*{\s*(\"use strict\"\;)?\s*(var [^;]*;)?\s*return\s*([^;]*)\s*;?\s*}$/;
895-
const lambdaRegex = /^\s*\(?\s*([$a-zA-Z_][0-9a-zA-Z_$]*)\s*\)?\s*=>\s*{?\s*(return\s+)?([^;]*)\s*;?\s*}?$/;
895+
const lambdaRegex = /^\s*\(?\s*([$a-zA-Z_][0-9a-zA-Z_$]*)\s*\)?\s*=>(\s*{?\s*(return\s+)?([^;]*)\s*;?\s*}?)$/;
896896
const memberRegex = /^(.*)\.([$a-zA-Z_][0-9a-zA-Z_$]*)$/;
897897
const memberIndexerRegex = /^(.*)\["([$a-zA-Z_][0-9a-zA-Z_$]*)"\]$/;
898898
const mixinMemberRegex = /^(.*)\.mixins\["([$a-zA-Z_][0-9a-zA-Z_$]*)"\]$/; //Necessary for some crazy minimizers

Signum.React/Scripts/TypeContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ export interface EntityFrame {
493493
allowExchangeEntity: boolean;
494494

495495
isExecuting(): boolean;
496-
execute: (action: () => Promise<void>) => void;
496+
execute: (action: () => Promise<void>) => Promise<void>;
497497

498498
createNew?: (oldPack: EntityPack<ModifiableEntity>) => (Promise<EntityPack<ModifiableEntity> | undefined>) | undefined;
499499
prefix: string;

Signum.React/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
3+
"target": "ES2017",
44
"sourceMap": false,
55
"module": "esnext",
66
"moduleResolution": "node",

0 commit comments

Comments
 (0)