@@ -169,7 +169,7 @@ const PubkyClientContext = createContext({} as PubkyClientContextType);
169169
170170export function PubkyClientWrapper ( { children } : { children : React . ReactNode } ) {
171171 const [ queryClient ] = useState ( ( ) => new QueryClient ( ) ) ;
172- const [ specsWasmLoaded , setSpecsWasmLoaded ] = useState ( false ) ;
172+ const [ ready , setReady ] = useState ( false ) ;
173173 const [ wasmError , setWasmError ] = useState < string | null > ( null ) ;
174174 const [ pubky , setPubky ] = useState < string | undefined > (
175175 ( Utils . storage . get ( 'pubky_public_key' ) as string ) || undefined
@@ -196,26 +196,7 @@ export function PubkyClientWrapper({ children }: { children: React.ReactNode })
196196 const [ singlePost , setSinglePost ] = useState < PostView | undefined > ( undefined ) ;
197197
198198 useEffect ( ( ) => {
199- if ( ! specsWasmLoaded ) {
200- try {
201- setSpecsWasmLoaded ( true ) ;
202- } catch ( err ) {
203- let message = 'Failed to load core module.' ;
204- if ( typeof window !== 'undefined' && navigator . userAgent . includes ( 'Graphene' ) ) {
205- message =
206- 'This device appears to be running GrapheneOS with JIT disabled. Please enable JIT in your browser settings to use Pubky.' ;
207- } else if (
208- err &&
209- typeof err . message === 'string' &&
210- ( err . message . includes ( 'WebAssembly' ) || err . message . includes ( 'JIT' ) || err . message . includes ( 'not supported' ) )
211- ) {
212- message =
213- 'WebAssembly failed to load. If you are using GrapheneOS, please enable JIT in your browser settings.' ;
214- }
215- setWasmError ( message ) ;
216- setSpecsWasmLoaded ( false ) ;
217- }
218- }
199+ setReady ( true ) ;
219200 } , [ ] ) ;
220201
221202 useEffect ( ( ) => {
@@ -226,10 +207,10 @@ export function PubkyClientWrapper({ children }: { children: React.ReactNode })
226207 } , [ newUser ] ) ;
227208
228209 useEffect ( ( ) => {
229- specsWasmLoaded && pubky && setSpecsBuilder ( new PubkySpecsBuilder ( pubky ) ) ;
230- } , [ specsWasmLoaded , pubky ] ) ;
210+ ready && pubky && setSpecsBuilder ( new PubkySpecsBuilder ( pubky ) ) ;
211+ } , [ ready , pubky ] ) ;
231212
232- if ( wasmError && ! specsWasmLoaded ) {
213+ if ( wasmError ) {
233214 return (
234215 < div className = "flex flex-col items-center justify-center min-h-screen text-white p-8" >
235216 < h1 className = "text-2xl font-bold mb-4" > Initialization Error</ h1 >
@@ -244,7 +225,7 @@ export function PubkyClientWrapper({ children }: { children: React.ReactNode })
244225 ) ;
245226 }
246227
247- if ( ! specsWasmLoaded ) {
228+ if ( ! ready ) {
248229 return (
249230 < div className = "flex justify-center items-center h-screen" >
250231 < div className = "animate-spin rounded-full h-32 w-32 border-t-2 border-b-2 border-white" />
0 commit comments