feat: refactor Google Auth handling and improve media file management with enhanced error logging

This commit is contained in:
bobbert committed 2026-02-25 01:17:32 +00:00
1 parent ad0cc1a7f5
commit 99c0e1186c
3 files changed
+110 -35

No files matched your search

+18 -1
View File
@@ -8,6 +8,7 @@ import DatabaseService from '../services/DatabaseService';
import DeviceMediaService from '../services/DeviceMediaService';
import GoogleAUTH from '../AUTH/GoogleAUTH';
import NASAUTH from '../AUTH/NASAUTH';
import { File } from 'expo-file-system';
import TopBar from '../components/TopBar';
import PhotoGrid from '../components/PhotoGrid';
import MediaViewer from '../components/MediaViewer';
@@ -132,7 +133,23 @@ const HomeScreen = ({ navigation, route }) => {
// ─── Previously imported Google Photos (stored in DB) ───
try {
const googleMedia = await DatabaseService.getMediaByService(userId, 'GOOGLE_PHOTOS');
if (googleMedia?.length) newMedia.push(...googleMedia);
if (googleMedia?.length) {
// Validate cached files still exist — clear stale paths
const validated = googleMedia.map((item) => {
if (item.local_path) {
try {
const f = new File(item.local_path);
if (!f.exists || f.size === 0) {
return { ...item, local_path: null };
}
} catch (_) {
return { ...item, local_path: null };
}
}
return item;
});
newMedia.push(...validated);
}
} catch (err) {
console.error('DB Google media fetch error:', err);
}