@@ -36,8 +39,6 @@
-
-
-
- {#if state.status === 'connecting' || state.status === 'reconnecting'}
+ {#if $state.status === 'connecting' || $state.status === 'reconnecting'}
Requesting Connection
{copyEN(activeRequest.name).connecting[activeRequest.type]}
diff --git a/packages/ui/src/components/index.ts b/packages/ui/src/components/index.ts
index c3a24f1..a2b0210 100644
--- a/packages/ui/src/components/index.ts
+++ b/packages/ui/src/components/index.ts
@@ -1,20 +1,29 @@
import ConnectModal from './ConnectModal/ConnectModal.svelte'
import AccountModal from './AccountModal.svelte'
import FractlModal from './FractlModal.svelte'
-import type { Config } from '@fractl-ui/types'
+import type { Config, Connector, StateConnected } from '@fractl-ui/types'
-export const create = async (config: Promise>) => {
+export const create = async (config: Promise>) => {
let _config = await Promise.resolve(config)
+ //TODO: return singleton when modal is dismissed without completing connection
return () => {
const getTarget = () => document.body
return new Promise((resolve, reject) => {
- new ConnectModal({
+ const modal = new ConnectModal({
target: getTarget(),
props: {
config: _config,
- state: _config.state
+ state: _config.state,
+ onConnect: (state: StateConnected) => {
+ resolve(state)
+ modal.$destroy()
+ },
+ onConnectFail: (error) => {
+ reject(error)
+ modal.$destroy()
+ }
}
})
})