mirror of
https://github.com/R0m1k3/xtremobile.git
synced 2026-10-15 19:27:41 +02:00
feat: add XtreamServiceMobile for Xtream Codes API communication with caching and DNS resolution for mobile.
This commit is contained in:
1 parent
80320d0eae
commit
5dd83019d3
8 files changed
+107
-177
No files matched your search
@@ -20,8 +20,13 @@ class HiveService {
|
||||
await Hive.initFlutter();
|
||||
|
||||
// Register adapters
|
||||
Hive.registerAdapter(AppUserAdapter());
|
||||
Hive.registerAdapter(PlaylistConfigAdapter());
|
||||
// Register adapters
|
||||
if (!Hive.isAdapterRegistered(0)) {
|
||||
Hive.registerAdapter(AppUserAdapter());
|
||||
}
|
||||
if (!Hive.isAdapterRegistered(1)) {
|
||||
Hive.registerAdapter(PlaylistConfigAdapter());
|
||||
}
|
||||
|
||||
// Open boxes WITHOUT encryption on Web
|
||||
// Note: On Web, IndexedDB is already isolated by origin,
|
||||
|
||||
@@ -7,9 +7,7 @@ class PlaylistApiService {
|
||||
/// Get all playlists for current user
|
||||
Future<List<PlaylistConfig>> getPlaylists() async {
|
||||
try {
|
||||
if (!HiveService.playlistsBox.isOpen) {
|
||||
await HiveService.init();
|
||||
}
|
||||
await HiveService.init();
|
||||
return HiveService.playlistsBox.values.toList();
|
||||
} catch (e) {
|
||||
print('Error fetching playlists from Hive: $e');
|
||||
@@ -25,6 +23,7 @@ class PlaylistApiService {
|
||||
required String password,
|
||||
}) async {
|
||||
try {
|
||||
await HiveService.init();
|
||||
final id = const Uuid().v4();
|
||||
final playlist = PlaylistConfig(
|
||||
id: id,
|
||||
@@ -52,6 +51,7 @@ class PlaylistApiService {
|
||||
required String password,
|
||||
}) async {
|
||||
try {
|
||||
await HiveService.init();
|
||||
if (!HiveService.playlistsBox.containsKey(id)) {
|
||||
return null;
|
||||
}
|
||||
@@ -79,6 +79,7 @@ class PlaylistApiService {
|
||||
/// Delete a playlist
|
||||
Future<bool> deletePlaylist(String id) async {
|
||||
try {
|
||||
await HiveService.init();
|
||||
await HiveService.playlistsBox.delete(id);
|
||||
return true;
|
||||
} catch (e) {
|
||||
|
||||
Reference in new issue
Block a user