make doAction async

This commit is contained in:
Géry Debongnie
2019-02-27 13:37:21 +01:00
parent 264420a96b
commit 385156ee72
2 changed files with 9 additions and 6 deletions
+8 -5
View File
@@ -249,10 +249,13 @@ function actionManagerMixin<T extends ReturnType<typeof rpcMixin>>(Base: T) {
if (!menu) {
throw new Error("Invalid menu id");
}
this.updateAppState(menu.app, menu.actionId);
return this.updateAppState(menu.app, menu.actionId);
}
private updateAppState(app: MenuItem | null, actionId: number | null) {
private async updateAppState(
app: MenuItem | null,
actionId: number | null
) {
const newApp = app || this.state.currentApp;
if (actionId) {
const query: Query = { action_id: String(actionId) };
@@ -264,7 +267,7 @@ function actionManagerMixin<T extends ReturnType<typeof rpcMixin>>(Base: T) {
this.update({ currentApp: app });
}
this.services.router.navigate(query);
this.doAction(actionId);
return this.doAction(actionId);
} else {
this.update({ inHome: true, currentApp: newApp });
}
@@ -296,9 +299,9 @@ function actionManagerMixin<T extends ReturnType<typeof rpcMixin>>(Base: T) {
return { app, actionId };
}
doAction(request: ActionRequest) {
async doAction(request: ActionRequest) {
if (typeof request === "number") {
this.loadAction(request);
await this.loadAction(request);
// this is an action ID
let name = request === 131 ? "discuss" : "crm";
let title =
+1 -1
View File
@@ -108,7 +108,7 @@ describe("state transitions", () => {
// should still be in home menu since no app is currently active
expect(store.state.inHome).toBe(true);
store.activateMenuItem(96);
await store.activateMenuItem(96);
expect(store.state.inHome).toBe(false);
store.toggleHomeMenu();