From 80de6eae00bad596e448f09e3d6485ddac6e2823 Mon Sep 17 00:00:00 2001 From: Pavel Prichodko <14926950+prichodko@users.noreply.github.com> Date: Fri, 10 Jun 2022 14:16:06 +0200 Subject: [PATCH] add protocol provider --- .../status-react/src/protocol/provider.tsx | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/status-react/src/protocol/provider.tsx b/packages/status-react/src/protocol/provider.tsx index 6f5bc74..ea297ab 100644 --- a/packages/status-react/src/protocol/provider.tsx +++ b/packages/status-react/src/protocol/provider.tsx @@ -1,15 +1,17 @@ import React, { - useEffect, createContext, useContext, + useEffect, useMemo, useState, } from 'react' -import type { Config } from '~/src/types/config' -import {Loading} from '~/src/components/loading' import { createClient } from '@status-im/js' -import type { Client, ClientOptions, Community , Account} from '@status-im/js' + +import { Loading } from '~/src/components/loading' + +import type { Account, Client, ClientOptions, Community } from '@status-im/js' +import type { Config } from '~/src/types/config' const Context = createContext(undefined) const CommunityContext = createContext< @@ -58,11 +60,12 @@ export const ClientProvider = (props: ClientProviderProps) => { const loadClient = async () => { // setLoading(true) const client = await createClient({ publicKey: props.options.publicKey }) -console.log('starting') - await client.start() console.log('init', client) setCommunity(client.community.communityMetadata) - console.log("file: provider.tsx > line 64 > loadClient > client.community.communityMetadata", client.community.communityMetadata) + console.log( + 'file: provider.tsx > line 64 > loadClient > client.community.communityMetadata', + client.community.communityMetadata + ) setClient(client) setLoading(false) @@ -76,7 +79,10 @@ console.log('starting') console.log('useEffect subscribe') return client.community.onCommunityUpdate(community => { setCommunity(community) - console.log("file: provider.tsx > line 75 > useEffect > community", community) + console.log( + 'file: provider.tsx > line 75 > useEffect > community', + community + ) }) } }, [client]) @@ -88,11 +94,7 @@ console.log('starting') return ( - {loading ? ( - - ) : ( - children - )} + {loading ? : children} )