Your music, beautifully tracked. All yours. (coming soon) teal.fm
teal-fm atproto

fail better when we can't find teal profile + onboarding fixes

Natalie B. ad735f8d dbf0da17

+37 -25
+5 -5
apps/amethyst/app/(tabs)/index.tsx
··· 56 56 return <AuthOptions />; 57 57 } 58 58 59 - // TODO: replace with skeleton 60 - if (!profile || !agent) { 59 + if (hasTealProfile !== null && !hasTealProfile) { 61 60 return ( 62 61 <View className="flex-1 justify-center items-center gap-5 p-6 bg-background"> 63 - <ActivityIndicator size="large" /> 62 + <Redirect href="/onboarding" /> 64 63 </View> 65 64 ); 66 65 } 67 66 68 - if (hasTealProfile !== null && !hasTealProfile) { 67 + // TODO: replace with skeleton 68 + if (!profile || !agent) { 69 69 return ( 70 70 <View className="flex-1 justify-center items-center gap-5 p-6 bg-background"> 71 - <Redirect href="/onboarding" /> 71 + <ActivityIndicator size="large" /> 72 72 </View> 73 73 ); 74 74 }
+5 -3
apps/amethyst/app/onboarding/index.tsx
··· 27 27 const [avatarUri, setAvatarUri] = useState(''); 28 28 const [bannerUri, setBannerUri] = useState(''); 29 29 30 - const [submissionStep, setSubmissionStep] = useState(1); 30 + const [submissionStep, setSubmissionStep] = useState(0); 31 31 const [submissionError, setSubmissionError] = useState(''); 32 32 33 33 const router = useRouter(); ··· 121 121 }, 2000); 122 122 }; 123 123 124 - if (!agent) { 124 + if (!agent || !profile[agent?.did!]) { 125 125 return <div>Loading...</div>; 126 126 } 127 127 128 128 // if we already have stuff then go back 129 129 // 130 - if (profile[agent?.did!].teal) { 130 + 131 + console.log(profile); 132 + if (profile[agent?.did!].teal !== null) { 131 133 return ( 132 134 <Text> 133 135 Profile already exists: {JSON.stringify(profile[agent?.did!].teal)}
+27 -17
apps/amethyst/stores/authenticationSlice.tsx
··· 180 180 return profile.data || null; 181 181 }); 182 182 // get teal did 183 - let tealDid = get().tealDid; 184 - let tealProfile = await agent 185 - .call( 186 - 'fm.teal.alpha.actor.getProfile', 187 - { actor: agent?.did }, 188 - {}, 189 - { headers: { 'atproto-proxy': tealDid + '#teal_fm_appview' } }, 190 - ) 191 - .then((profile) => { 192 - console.log(profile); 193 - return profile.data.agent || null; 194 - }); 183 + try { 184 + let tealDid = get().tealDid; 185 + let tealProfile = await agent 186 + .call( 187 + 'fm.teal.alpha.actor.getProfile', 188 + { actor: agent?.did }, 189 + {}, 190 + { headers: { 'atproto-proxy': tealDid + '#teal_fm_appview' } }, 191 + ) 192 + .then((profile) => { 193 + console.log(profile); 194 + return profile.data.agent || null; 195 + }); 195 196 196 - set({ 197 - profiles: { 198 - [agent.did]: { bsky: bskyProfile, teal: tealProfile }, 199 - }, 200 - }); 197 + set({ 198 + profiles: { 199 + [agent.did]: { bsky: bskyProfile, teal: tealProfile }, 200 + }, 201 + }); 202 + } catch (error) { 203 + console.error('Failed to get teal profile:', error); 204 + // insert bsky profile 205 + set({ 206 + profiles: { 207 + [agent.did]: { bsky: bskyProfile, teal: null }, 208 + }, 209 + }); 210 + } 201 211 } catch (error) { 202 212 console.error('Failed to get profile:', error); 203 213 }