From 13cc497b040e771b42734dadc76c54daa6547537 Mon Sep 17 00:00:00 2001 From: Daniel LaCosse <3759828+daniellacosse@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:12:35 -0400 Subject: [PATCH] simplify naming --- .../app_mobile/app.ts | 17 +++++++------ .../pages/connectivity_test/index.ts | 24 +++++++++---------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/x/examples/outline-connectivity-app/app_mobile/app.ts b/x/examples/outline-connectivity-app/app_mobile/app.ts index 0ae0ba14..51331121 100644 --- a/x/examples/outline-connectivity-app/app_mobile/app.ts +++ b/x/examples/outline-connectivity-app/app_mobile/app.ts @@ -18,18 +18,18 @@ import { registerPlugin } from "@capacitor/core"; // Capacitor requires passing in a root object to each native call, // that is then accessed via APIs like `call.getString("objectKey")`. const MobileBackend = registerPlugin<{ - Request(request: { resourceName: string; parameters: string}): Promise<{ error: string; body: string}>; + Request(request: { resourceName: string; parameters: string }): Promise<{ error: string; body: string }>; }>("MobileBackend"); async function requestBackend(resourceName: string, parameters: T): Promise { - const response = await MobileBackend.Request({ - resourceName, parameters: JSON.stringify(parameters) + const response = await MobileBackend.Request({ + resourceName, parameters: JSON.stringify(parameters) }); if (response.error) { throw new Error(response.error); } - + return JSON.parse(response.body); } @@ -47,12 +47,11 @@ SharedFrontend.registerAllElements(); export class AppMain extends LitElement { render() { return html` requestBackend("PlatformMetadata", void 0)} - .onSubmit=${ - (parameters: ConnectivityTestRequest) => + .loadPlatform=${() => requestBackend("Platform", void 0)} + .onSubmit=${(parameters: ConnectivityTestRequest) => requestBackend( - "ConnectivityTest", parameters + "ConnectivityTest", parameters ) - } />`; + } />`; } } diff --git a/x/examples/outline-connectivity-app/shared_frontend/pages/connectivity_test/index.ts b/x/examples/outline-connectivity-app/shared_frontend/pages/connectivity_test/index.ts index 18d1728e..e1efc6fe 100644 --- a/x/examples/outline-connectivity-app/shared_frontend/pages/connectivity_test/index.ts +++ b/x/examples/outline-connectivity-app/shared_frontend/pages/connectivity_test/index.ts @@ -32,19 +32,19 @@ const Localization = configureLocalization({ @localized() export class ConnectivityTestPage extends LitElement { @property({ type: Function }) - resolvePlatform?: () => Promise; - - @property({ type: Function }) - onSubmit?: (request: ConnectivityTestRequest) => Promise; + loadPlatform?: () => Promise; @property({ attribute: false }) platform?: PlatformMetadata; + @property({ type: Function }) + onSubmit?: (request: ConnectivityTestRequest) => Promise; + @property({ attribute: false }) isSubmitting = false; @property({ attribute: false }) - testResponse?: ConnectivityTestResponse; + response?: ConnectivityTestResponse; get locale() { return Localization.getLocale(); @@ -91,8 +91,8 @@ export class ConnectivityTestPage extends LitElement { } protected async performUpdate() { - if (!this.platform && this.resolvePlatform) { - this.platform = await this.resolvePlatform(); + if (!this.platform && this.loadPlatform) { + this.platform = await this.loadPlatform(); } super.performUpdate(); @@ -108,9 +108,9 @@ export class ConnectivityTestPage extends LitElement { this.isSubmitting = true; try { - this.testResponse = (await this.onSubmit?.(this.formData)) ?? null; + this.response = (await this.onSubmit?.(this.formData)) ?? null; } catch (error) { - this.testResponse = new Error(error as string); + this.response = new Error(error as string); } finally { this.isSubmitting = false; } @@ -772,7 +772,7 @@ export class ConnectivityTestPage extends LitElement { } renderResults() { - if (!this.testResponse) { + if (!this.response) { return nothing; } @@ -781,12 +781,12 @@ export class ConnectivityTestPage extends LitElement {

${msg("Test Results")}

- ${this.renderResultsList(this.testResponse)} + ${this.renderResultsList(this.response)} `; }