mudular code ready to fork
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import '../../core/logger.dart';
|
||||
import '../../core/exceptions/session_exception.dart';
|
||||
import '../local/local_storage_service.dart';
|
||||
import '../sync/sync_engine.dart';
|
||||
import '../firebase/firebase_service.dart';
|
||||
@@ -10,18 +11,6 @@ import '../nostr/models/nostr_keypair.dart';
|
||||
import '../nostr/models/nostr_profile.dart';
|
||||
import 'models/user.dart';
|
||||
|
||||
/// Exception thrown when session operations fail.
|
||||
class SessionException implements Exception {
|
||||
/// Error message.
|
||||
final String message;
|
||||
|
||||
/// Creates a [SessionException] with the provided message.
|
||||
SessionException(this.message);
|
||||
|
||||
@override
|
||||
String toString() => 'SessionException: $message';
|
||||
}
|
||||
|
||||
/// Service for managing user sessions, login, logout, and session isolation.
|
||||
///
|
||||
/// This service provides:
|
||||
@@ -124,7 +113,7 @@ class SessionService {
|
||||
await _firebaseService!.syncItemsFromFirestore(user.id);
|
||||
} catch (e) {
|
||||
// Log error but don't fail login - offline-first behavior
|
||||
debugPrint('Warning: Failed to sync from Firebase on login: $e');
|
||||
Logger.warning('Failed to sync from Firebase on login: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +163,7 @@ class SessionService {
|
||||
try {
|
||||
profile = await _nostrService!.fetchProfile(keyPair.publicKey);
|
||||
} catch (e) {
|
||||
debugPrint('Warning: Failed to fetch Nostr profile: $e');
|
||||
Logger.warning('Failed to fetch Nostr profile: $e');
|
||||
// Continue without profile - offline-first behavior
|
||||
}
|
||||
|
||||
@@ -195,7 +184,7 @@ class SessionService {
|
||||
await _firebaseService!.syncItemsFromFirestore(user.id);
|
||||
} catch (e) {
|
||||
// Log error but don't fail login - offline-first behavior
|
||||
debugPrint('Warning: Failed to sync from Firebase on login: $e');
|
||||
Logger.warning('Failed to sync from Firebase on login: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +219,7 @@ class SessionService {
|
||||
await _firebaseService!.syncItemsToFirestore(userId);
|
||||
} catch (e) {
|
||||
// Log error but don't fail logout - offline-first behavior
|
||||
debugPrint('Warning: Failed to sync to Firebase on logout: $e');
|
||||
Logger.warning('Failed to sync to Firebase on logout: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +396,7 @@ class SessionService {
|
||||
try {
|
||||
profile = await _nostrService!.fetchProfile(_currentUser!.id);
|
||||
} catch (e) {
|
||||
debugPrint('Warning: Failed to refresh Nostr profile: $e');
|
||||
Logger.warning('Failed to refresh Nostr profile: $e');
|
||||
// Continue without profile update - offline-first behavior
|
||||
}
|
||||
|
||||
@@ -447,11 +436,11 @@ class SessionService {
|
||||
);
|
||||
|
||||
if (addedCount > 0) {
|
||||
debugPrint('Loaded $addedCount preferred relay(s) from NIP-05: $nip05');
|
||||
Logger.info('Loaded $addedCount preferred relay(s) from NIP-05: $nip05');
|
||||
}
|
||||
} catch (e) {
|
||||
// Log error but don't fail - offline-first behavior
|
||||
debugPrint('Warning: Failed to load preferred relays from NIP-05: $e');
|
||||
Logger.warning('Failed to load preferred relays from NIP-05: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user