From 7cff49a69a36020bcaa702cd44d558ca996e2950 Mon Sep 17 00:00:00 2001 From: LukassF Date: Fri, 23 Feb 2024 14:25:32 +0100 Subject: [PATCH] add: showing error in modal --- .../nightly-desktop-main/nightly-desktop-main.stories.ts | 2 +- .../components/nightly-desktop-main/nightly-desktop-main.ts | 4 ++-- .../src/components/nightly-mobile-qr/nightly-mobile-qr.ts | 4 ++-- .../components/nightly-selector/nightly-selector.stories.ts | 2 +- .../modal/src/components/nightly-selector/nightly-selector.ts | 4 ++-- sdk/packages/selector-base/src/modal.ts | 4 ++++ sdk/packages/selector-polkadot/src/adapter.ts | 4 ++-- sdk/packages/selector-solana/src/adapter.ts | 2 +- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/sdk/packages/modal/src/components/nightly-desktop-main/nightly-desktop-main.stories.ts b/sdk/packages/modal/src/components/nightly-desktop-main/nightly-desktop-main.stories.ts index 53f1a457..6f376ae7 100644 --- a/sdk/packages/modal/src/components/nightly-desktop-main/nightly-desktop-main.stories.ts +++ b/sdk/packages/modal/src/components/nightly-desktop-main/nightly-desktop-main.stories.ts @@ -154,7 +154,7 @@ export const Error: Story = (args: NightlyModalArgs) => { if (!args.sessionId) setTimeout(() => { - updateArgs({ timeoutError: true }) + updateArgs({ timeoutError: 'error' }) }, 5000) return html` = {} - @property({ type: Boolean }) - timeoutError = false + @property({ type: String }) + timeoutError = '' @state() copyMessage = 'Copy' diff --git a/sdk/packages/modal/src/components/nightly-mobile-qr/nightly-mobile-qr.ts b/sdk/packages/modal/src/components/nightly-mobile-qr/nightly-mobile-qr.ts index 2bc8bdb9..f205668c 100644 --- a/sdk/packages/modal/src/components/nightly-mobile-qr/nightly-mobile-qr.ts +++ b/sdk/packages/modal/src/components/nightly-mobile-qr/nightly-mobile-qr.ts @@ -24,8 +24,8 @@ export class NightlyMobileQr extends LitElement { @property({ type: Object }) qrConfigOverride: Partial = {} - @property({ type: Boolean }) - timeoutError = false + @property({ type: String }) + timeoutError = '' @state() qrSource: string | undefined = undefined diff --git a/sdk/packages/modal/src/components/nightly-selector/nightly-selector.stories.ts b/sdk/packages/modal/src/components/nightly-selector/nightly-selector.stories.ts index 5a5b2fdf..2e983040 100644 --- a/sdk/packages/modal/src/components/nightly-selector/nightly-selector.stories.ts +++ b/sdk/packages/modal/src/components/nightly-selector/nightly-selector.stories.ts @@ -159,7 +159,7 @@ export const Error: Story = (args: NightlyModalArgs) => { if (!args.sessionId) setTimeout(() => { - updateArgs({ timeoutError: true }) + updateArgs({ timeoutError: 'error' }) }, 5000) return open diff --git a/sdk/packages/modal/src/components/nightly-selector/nightly-selector.ts b/sdk/packages/modal/src/components/nightly-selector/nightly-selector.ts index 89830bae..c3ea2f20 100644 --- a/sdk/packages/modal/src/components/nightly-selector/nightly-selector.ts +++ b/sdk/packages/modal/src/components/nightly-selector/nightly-selector.ts @@ -47,8 +47,8 @@ export class NightlySelector extends LitElement { @property({ type: Object }) qrConfigOverride: Partial = {} - @property({ type: Boolean }) - timeoutError = false + @property({ type: String }) + timeoutError = '' // state diff --git a/sdk/packages/selector-base/src/modal.ts b/sdk/packages/selector-base/src/modal.ts index 4af34d4d..69d962a8 100644 --- a/sdk/packages/selector-base/src/modal.ts +++ b/sdk/packages/selector-base/src/modal.ts @@ -61,6 +61,10 @@ export class NightlyConnectSelectorModal { if (this._modal && id) this._modal.sessionId = id } + set timeoutError(error: string) { + if (this._modal && error) this._modal.timeoutError = error + } + createSelectorElement = ( variablesOverride?: object, stylesOverride?: string, diff --git a/sdk/packages/selector-polkadot/src/adapter.ts b/sdk/packages/selector-polkadot/src/adapter.ts index ed3ddce4..f5031a2f 100644 --- a/sdk/packages/selector-polkadot/src/adapter.ts +++ b/sdk/packages/selector-polkadot/src/adapter.ts @@ -161,7 +161,7 @@ export class NightlyConnectAdapter implements Injected { ) if (!adapter._connectionOptions.disableModal) { adapter._modal = new NightlyConnectSelectorModal( - adapter.walletsList as IWalletListItem[], + adapter.walletsList, appInitData.url ?? 'https://nc2.nightly.app', networkToData(adapter.network), anchorRef, @@ -553,7 +553,7 @@ export class NightlyConnectAdapter implements Injected { if (checks > 500) { clearInterval(loadingInterval) // reject(new Error('Connecting takes too long')) - // TODO we need to have a way to show error on modal + if (this._modal) this._modal.timeoutError = 'Connecting is taking too long' } }, 10) } diff --git a/sdk/packages/selector-solana/src/adapter.ts b/sdk/packages/selector-solana/src/adapter.ts index 6bd10e5e..d44c3449 100644 --- a/sdk/packages/selector-solana/src/adapter.ts +++ b/sdk/packages/selector-solana/src/adapter.ts @@ -588,7 +588,7 @@ export class NightlyConnectAdapter extends BaseMessageSignerWalletAdapter { if (checks > 500) { clearInterval(loadingInterval) // reject(new Error('Connecting takes too long')) - // TODO we need to have a way to show error on modal + if (this._modal) this._modal.timeoutError = 'Connecting is taking too long' } }, 10) }