mirror of
https://github.com/mudabbir-ahmad/Media-Aggregation-and-Sorting-System.git
synced 2026-10-07 19:40:20 +00:00
feat: refactor Google Auth handling and improve media file management with enhanced error logging
This commit is contained in:
1 parent
ad0cc1a7f5
commit
99c0e1186c
3 files changed
+110
-35
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user