tiny bit simplified

+6 -14
+1 -1
atproto-notifications/src/App.tsx
··· 13 14 {user === null 15 ? ( 16 - <WhoAmI onSetUser={setUser} /> 17 ) 18 : ( 19 <>
··· 13 14 {user === null 15 ? ( 16 + <WhoAmI onIdentify={setUser} /> 17 ) 18 : ( 19 <>
+5 -13
atproto-notifications/src/components/WhoAmI.tsx
··· 1 import { useRef, useEffect } from 'react'; 2 3 - export function WhoAmI({ onSetUser, origin = 'http://127.0.0.1:9997' }) { 4 const frameRef = useRef(null); 5 6 useEffect(() => { ··· 9 ev.source !== frameRef.current?.contentWindow || 10 ev.origin !== origin 11 ) return; 12 - onSetUser(ev.data); 13 } 14 - 15 - console.log('ready'); 16 window.addEventListener('message', handleMessage); 17 - return () => { 18 - console.log('byeeeeeeeeeeeee'); 19 - window.removeEventListener('message', handleMessage); 20 - } 21 }, []); 22 23 return ( 24 <iframe 25 src={`${origin}/prompt`} 26 ref={frameRef} 27 - id="whoami" 28 style={{ 29 border: 'none', 30 - boxSizing: 'border-box', 31 display: 'block', 32 colorScheme: 'none', 33 }} 34 - allowtransparency="true" 35 - height="160" 36 - width="320" 37 > 38 Ooops, failed to load the login helper 39 </iframe>
··· 1 import { useRef, useEffect } from 'react'; 2 3 + export function WhoAmI({ onIdentify, origin = 'http://127.0.0.1:9997' }) { 4 const frameRef = useRef(null); 5 6 useEffect(() => { ··· 9 ev.source !== frameRef.current?.contentWindow || 10 ev.origin !== origin 11 ) return; 12 + onIdentify(ev.data); 13 } 14 window.addEventListener('message', handleMessage); 15 + return () => window.removeEventListener('message', handleMessage); 16 }, []); 17 18 return ( 19 <iframe 20 src={`${origin}/prompt`} 21 ref={frameRef} 22 + height="160" 23 + width="320" 24 style={{ 25 border: 'none', 26 display: 'block', 27 colorScheme: 'none', 28 }} 29 > 30 Ooops, failed to load the login helper 31 </iframe>