import { Component, Event, EventEmitter, Prop, h } from '@stencil/core'; import { state } from '@/store'; import { CURRENT_MODULE } from '@/types'; @Component({ tag: 'nl-loading', styleUrl: 'nl-loading.css', shadow: false, }) export class NlLoading { @Event() stopFetchHandler: EventEmitter; @Event() handleContinue: EventEmitter; @Prop() path: string; handleStop(e) { e.preventDefault(); this.stopFetchHandler.emit(); } handleContinueClick(e) { e.preventDefault(); // reset(); this.handleContinue.emit(); } render() { let title = 'Connecting...'; let text = 'Establishing connection to your key storage.'; if (state.njumpIframe) { title = ''; text = ''; } else if (this.path === CURRENT_MODULE.LOCAL_SIGNUP) { title = 'Creating...'; text = 'Publishing your profile on Nostr.'; } else if (state.authUrl) { if (state.isLoading) { title = 'Confirming...'; text = 'Please confirm the connection in your key storage app.'; } else { title = 'Almost ready!'; text = 'Continue to confirm the connection to your key storage.'; } } const showButton = this.path !== CURRENT_MODULE.LOCAL_SIGNUP; const showIframe = !state.isLoading && state.iframeUrl && state.authUrl; const iframeUrl = state.iframeUrl ? `${state.iframeUrl}?connect=${encodeURIComponent(state.authUrl)}` : ''; return (
{title && (

{title}

)} {text && (

{text}

)} {!state.njumpIframe && !state.authUrl && state.isLoading && (
)}

{state.error}

{iframeUrl && (
)} {state.njumpIframe && (
)} {!showIframe && showButton && (
{ if (state.authUrl && !state.isLoading) { this.handleContinueClick(e); } else { this.handleStop(e); } }} titleBtn={!state.isLoading ? 'Continue' : 'Cancel'} />
)}
); } }