This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

fix

+113 -12
+14 -4
src/components/Navbar/Navbar.js
··· 155 155 const getDisplayName = () => { 156 156 if (!session) return ''; 157 157 158 + // First try displayName if available 159 + if (session.displayName) { 160 + return session.displayName; 161 + } 162 + 158 163 // Try to get the handle from the session 159 164 const handle = session.handle || ''; 165 + if (handle) { 166 + return handle; 167 + } 160 168 161 - // If it's a DID, show a shortened version 162 - if (session.sub.startsWith('did:')) { 163 - return session.sub.substring(0, 15) + '...'; 169 + // Try to get DID (could be in session.did or session.sub) 170 + const did = session.did || session.sub; 171 + if (did && did.startsWith('did:')) { 172 + return did.substring(0, 15) + '...'; 164 173 } 165 174 166 - return handle; 175 + // Fallback 176 + return 'User'; 167 177 }; 168 178 169 179 return (
+99 -8
src/contexts/AuthContext.js
··· 81 81 const atprotoSession = localStorage.getItem('atproto_session'); 82 82 console.log('atproto_session in localStorage:', atprotoSession ? 'exists' : 'not found'); 83 83 84 + // Try to extract handle from session 85 + let handle = result.session.handle; 86 + 87 + // If handle is missing, try to extract it from other sources 88 + if (!handle) { 89 + try { 90 + // Try server login data 91 + if (result.session.server && result.session.server.login && result.session.server.login.handle) { 92 + handle = result.session.server.login.handle; 93 + } 94 + // Try atproto_session in localStorage if it exists 95 + else if (atprotoSession) { 96 + try { 97 + const parsedSession = JSON.parse(atprotoSession); 98 + if (parsedSession && parsedSession.handle) { 99 + handle = parsedSession.handle; 100 + } 101 + } catch (e) { 102 + console.error('Error parsing atproto_session:', e); 103 + } 104 + } 105 + } catch (e) { 106 + console.error('Error extracting handle:', e); 107 + } 108 + } 109 + 84 110 // Format session data for our internal use and sync with server 85 111 const sessionData = { 86 112 did: result.session.sub, 87 - handle: result.session.handle 113 + handle: handle || 'unknown' // Ensure we always have a handle value 88 114 }; 89 115 90 116 console.log('Syncing session with server:', sessionData); ··· 107 133 } else { 108 134 console.warn('Initial session sync failed:', await syncResponse.text()); 109 135 110 - // If sync fails, use client session in our internal format 111 - console.log('Using client session as fallback'); 136 + // If sync fails, extract what we can from the result.session 137 + const handle = result.session.handle; 138 + 139 + // Try to get the handle from other properties if undefined 140 + let fallbackHandle = handle; 141 + if (!fallbackHandle) { 142 + // Check if we can extract handle from other properties 143 + try { 144 + // If we have additional properties in the session that might contain the handle 145 + if (result.session.server && result.session.server.login && result.session.server.login.handle) { 146 + fallbackHandle = result.session.server.login.handle; 147 + } else if (result.session.displayName && result.session.displayName.includes('@')) { 148 + // Sometimes displayName has the handle 149 + fallbackHandle = result.session.displayName.replace('@', ''); 150 + } else { 151 + // Fallback to 'unknown' if we can't find a handle 152 + fallbackHandle = 'unknown'; 153 + } 154 + } catch (e) { 155 + console.error('Error extracting handle from session:', e); 156 + fallbackHandle = 'unknown'; 157 + } 158 + } 159 + 160 + // Log what we're doing 161 + console.log(`Using client session as fallback with handle: ${fallbackHandle}`); 162 + 163 + // Use client session in our internal format 112 164 setSession({ 113 165 did: result.session.sub, 114 - handle: result.session.handle, 115 - displayName: result.session.handle 166 + handle: fallbackHandle, 167 + displayName: result.session.displayName || fallbackHandle 116 168 }); 117 169 } 118 170 } catch (syncError) { 119 171 console.error('Error syncing initial session:', syncError); 120 172 173 + // Extract handle with fallbacks similar to above 174 + const handle = result.session.handle; 175 + let fallbackHandle = handle; 176 + 177 + if (!fallbackHandle) { 178 + try { 179 + if (result.session.server && result.session.server.login && result.session.server.login.handle) { 180 + fallbackHandle = result.session.server.login.handle; 181 + } else if (result.session.displayName && result.session.displayName.includes('@')) { 182 + fallbackHandle = result.session.displayName.replace('@', ''); 183 + } else { 184 + fallbackHandle = 'unknown'; 185 + } 186 + } catch (e) { 187 + console.error('Error extracting handle from session:', e); 188 + fallbackHandle = 'unknown'; 189 + } 190 + } 191 + 192 + console.log(`Using client session after error with handle: ${fallbackHandle}`); 193 + 121 194 // If sync fails, still use client session in our internal format 122 195 setSession({ 123 196 did: result.session.sub, 124 - handle: result.session.handle, 125 - displayName: result.session.handle 197 + handle: fallbackHandle, 198 + displayName: result.session.displayName || fallbackHandle 126 199 }); 127 200 } 128 201 } else { ··· 298 371 try { 299 372 console.log('Server says not authenticated but we have a client session, trying to sync'); 300 373 374 + // Extract handle from current session 375 + let handle = session.handle; 376 + if (!handle) { 377 + // If our session doesn't have a handle, try to extract from other properties 378 + try { 379 + if (session.displayName && typeof session.displayName === 'string') { 380 + // Sometimes the handle might be in the displayName 381 + handle = session.displayName.includes('@') ? 382 + session.displayName.replace('@', '') : 383 + session.displayName; 384 + } 385 + } catch (e) { 386 + console.error('Error extracting handle from session:', e); 387 + } 388 + } 389 + 301 390 // Format session data properly 302 391 const sessionData = { 303 392 did: session.did || session.sub, 304 - handle: session.handle 393 + handle: handle || 'unknown' // Always provide a handle value 305 394 }; 395 + 396 + console.log('Syncing with data:', sessionData); 306 397 307 398 // Try to sync one more time 308 399 const syncResponse = await fetch('/api/sync-session', {