Skip to content

Commit 3bee7cd

Browse files
committed
make methods async
1 parent a7bec09 commit 3bee7cd

File tree

1 file changed

+22
-23
lines changed
  • src/server_manager/web_app

1 file changed

+22
-23
lines changed

src/server_manager/web_app/app.ts

+22-23
Original file line numberDiff line numberDiff line change
@@ -874,18 +874,18 @@ export class App {
874874
};
875875
}
876876

877-
private addAccessKey() {
878-
this.selectedServer.addAccessKey()
879-
.then(async (serverAccessKey: server.AccessKey) => {
880-
const uiAccessKey = this.convertToUiAccessKey(serverAccessKey);
881-
(await this.appRoot.getServerView(this.appRoot.selectedServerId))
882-
.addAccessKey(uiAccessKey);
883-
this.appRoot.showNotification(this.appRoot.localize('notification-key-added'));
884-
})
885-
.catch((error) => {
886-
console.error(`Failed to add access key: ${error}`);
887-
this.appRoot.showError(this.appRoot.localize('error-key-add'));
888-
});
877+
private async addAccessKey() {
878+
const server = this.selectedServer;
879+
try {
880+
const serverAccessKey = await server.addAccessKey();
881+
const uiAccessKey = this.convertToUiAccessKey(serverAccessKey);
882+
const serverView = await this.appRoot.getServerView(server.getId());
883+
serverView.addAccessKey(uiAccessKey);
884+
this.appRoot.showNotification(this.appRoot.localize('notification-key-added'));
885+
} catch (error) {
886+
console.error(`Failed to add access key: ${error}`);
887+
this.appRoot.showError(this.appRoot.localize('error-key-add'));
888+
}
889889
}
890890

891891
private renameAccessKey(accessKeyId: string, newName: string, entry: polymer.Base) {
@@ -1061,17 +1061,16 @@ export class App {
10611061
}
10621062
}
10631063

1064-
private removeAccessKey(accessKeyId: string) {
1065-
this.selectedServer.removeAccessKey(accessKeyId)
1066-
.then(async () => {
1067-
(await this.appRoot.getServerView(this.appRoot.selectedServerId))
1068-
.removeAccessKey(accessKeyId);
1069-
this.appRoot.showNotification(this.appRoot.localize('notification-key-removed'));
1070-
})
1071-
.catch((error) => {
1072-
console.error(`Failed to remove access key: ${error}`);
1073-
this.appRoot.showError(this.appRoot.localize('error-key-remove'));
1074-
});
1064+
private async removeAccessKey(accessKeyId: string) {
1065+
const server = this.selectedServer;
1066+
try {
1067+
await server.removeAccessKey(accessKeyId);
1068+
(await this.appRoot.getServerView(server.getId())).removeAccessKey(accessKeyId);
1069+
this.appRoot.showNotification(this.appRoot.localize('notification-key-removed'));
1070+
} catch (error) {
1071+
console.error(`Failed to remove access key: ${error}`);
1072+
this.appRoot.showError(this.appRoot.localize('error-key-remove'));
1073+
}
10751074
}
10761075

10771076
private deleteServer(serverId: string) {

0 commit comments

Comments
 (0)