mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-15 19:28:16 +02:00
feat: implement Hive service for local data persistence, user management, and playlist configuration.
This commit is contained in:
1 parent
3cd8e3dd52
commit
a1ce183cd3
6 files changed
+200
-29
No files matched your search
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user