ATlast — you'll never need to find your favorites on another platform again. Find your favs in the ATmosphere.
atproto

fix new platform not saving

Changed files
+7 -5
src
+7 -5
src/App.tsx
··· 24 25 // Add state to track current platform 26 const [currentPlatform, setCurrentPlatform] = useState<string>('tiktok'); 27 - const saveCalledRef = useRef(false); 28 29 // Search hook 30 const { ··· 62 63 setSearchResults(resultsWithPlatform); 64 setCurrentStep('loading'); 65 searchAllUsers( 66 resultsWithPlatform, 67 setStatusMessage, 68 () => { 69 setCurrentStep('results'); 70 // Prevent duplicate saves 71 - if (!saveCalledRef.current) { 72 - saveCalledRef.current = true; 73 // Need to wait for React to finish updating searchResults state 74 // Use a longer delay and access via setSearchResults callback to get final state 75 setTimeout(() => { 76 setSearchResults(currentResults => { 77 if (currentResults.length > 0) { 78 - const uploadId = crypto.randomUUID(); 79 apiClient.saveResults(uploadId, platform, currentResults).catch(err => { 80 console.error('Background save failed:', err); 81 }); ··· 108 109 const platform = 'tiktok'; // Default, will be updated when we add platform to upload details 110 setCurrentPlatform(platform); 111 - saveCalledRef.current = false; 112 113 // Convert the loaded results to SearchResult format with selectedMatches 114 const loadedResults = data.results.map(result => ({
··· 24 25 // Add state to track current platform 26 const [currentPlatform, setCurrentPlatform] = useState<string>('tiktok'); 27 + const saveCalledRef = useRef<string | null>(null); // Track by uploadId 28 29 // Search hook 30 const { ··· 62 63 setSearchResults(resultsWithPlatform); 64 setCurrentStep('loading'); 65 + 66 + const uploadId = crypto.randomUUID(); 67 + 68 searchAllUsers( 69 resultsWithPlatform, 70 setStatusMessage, 71 () => { 72 setCurrentStep('results'); 73 // Prevent duplicate saves 74 + if (saveCalledRef.current !== uploadId) { 75 + saveCalledRef.current = uploadId; 76 // Need to wait for React to finish updating searchResults state 77 // Use a longer delay and access via setSearchResults callback to get final state 78 setTimeout(() => { 79 setSearchResults(currentResults => { 80 if (currentResults.length > 0) { 81 apiClient.saveResults(uploadId, platform, currentResults).catch(err => { 82 console.error('Background save failed:', err); 83 }); ··· 110 111 const platform = 'tiktok'; // Default, will be updated when we add platform to upload details 112 setCurrentPlatform(platform); 113 + saveCalledRef.current = null; 114 115 // Convert the loaded results to SearchResult format with selectedMatches 116 const loadedResults = data.results.map(result => ({