feat: implement Hive service for local data persistence, user management, and playlist configuration.

This commit is contained in:
Michael committed 2025-12-06 01:11:43 +01:00
1 parent 3cd8e3dd52
commit a1ce183cd3
6 files changed
+200 -29

No files matched your search

+5 -13
View File
@@ -19,23 +19,15 @@ class HiveService {
// Initialize Hive for Web (uses IndexedDB)
await Hive.initFlutter();
// Generate or retrieve encryption key
final encryptionKey = await _getOrCreateEncryptionKey();
// Register adapters
Hive.registerAdapter(AppUserAdapter());
Hive.registerAdapter(PlaylistConfigAdapter());
// Open encrypted boxes
await Hive.openBox<AppUser>(
_usersBoxName,
encryptionCipher: HiveAesCipher(encryptionKey),
);
await Hive.openBox<PlaylistConfig>(
_playlistsBoxName,
encryptionCipher: HiveAesCipher(encryptionKey),
);
// Open boxes WITHOUT encryption on Web
// Note: On Web, IndexedDB is already isolated by origin,
// and session-based encryption keys cause decrypt errors on reload
await Hive.openBox<AppUser>(_usersBoxName);
await Hive.openBox<PlaylistConfig>(_playlistsBoxName);
// Seed default admin if no users exist
await _seedDefaultAdmin();