Files
lunasea/lib/core/database/database.dart
Jagandeep Brar 5cf33b3abd [Release/TestFlight] v4.1.0+40100001 (#266)
NEW
- [Networking] Strict TLS/SSL validation is now disabled globally
- [Routing] Hold the AppBar back button to pop back to the home page of the module
- [Settings/Sonarr] Toggle to enable Sonarr v3 features
- [Sonarr] Complete rewrite of Sonarr
- [Sonarr] State is now held across module switches
- [Sonarr/Overview] View tags applied to series
- [Sonarr/Catalogue] (v3 only) Ability to set and update language profile
- [Sonarr/Catalogue] Ability to view all, only monitored, or only unmonitored series
- [Sonarr/Releases] (v3 only) Ability to interactively search for season packs
- [Sonarr/Releases] Ability to view all, only approved, or only rejected releases

TWEAKS
- [Settings] Removed all toggles for strict TLS
- [Sonarr] Many tweaks to Sonarr's design
- [Sonarr/Add] (v3 only) Tapping an already-added series will take you to the series page
- [Sonarr/Add] Automatically navigate to newly added series
- [Sonarr/Series] Toggling monitored state of series has now been moved to the edit prompt

FIXES
- [Images] Images will now load for invalid/self-signed certificates
- [Tautulli/Activity] Fix grey screen for music activity
- [TextField] Fix TextField actions (cut, copy, paste, etc.) not showing
- [Timestamps] Fix 12:xx AM being shown as 00:xx AM
- Additional small bug fixes
2020-10-13 09:43:28 -05:00

82 lines
2.5 KiB
Dart

// Imports
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import './adapters.dart';
import 'package:lunasea/modules.dart' show
HomeDatabase,
SearchDatabase,
SettingsDatabase,
LidarrDatabase,
RadarrDatabase,
SonarrDatabase,
NZBGetDatabase,
SABnzbdDatabase;
// Exports
export 'package:hive/hive.dart';
export 'package:hive_flutter/hive_flutter.dart';
/// Next HiveType: 16
///
/// Dead Fields:
class Database {
Database._();
static Future<void> initialize() async {
await Hive.initFlutter('database');
_registerAdapters();
await _openBoxes();
if(profilesBox.keys.length == 0) setDefaults();
}
static Future<void> deinitialize() async => await Hive.close();
static void _registerAdapters() {
//Core
Hive.registerAdapter(IndexerHiveObjectAdapter());
Hive.registerAdapter(ProfileHiveObjectAdapter());
//General
LunaSeaDatabase.registerAdapters();
HomeDatabase.registerAdapters();
SearchDatabase.registerAdapters();
SettingsDatabase.registerAdapters();
//Automation
LidarrDatabase.registerAdapters();
RadarrDatabase.registerAdapters();
SonarrDatabase.registerAdapters();
//Clients
NZBGetDatabase.registerAdapters();
SABnzbdDatabase.registerAdapters();
}
static Future<void> _openBoxes() async {
await Hive.openBox('lunasea');
await Hive.openBox<IndexerHiveObject>('indexers');
await Hive.openBox<ProfileHiveObject>('profiles');
}
static void setDefaults() {
//Clear all the boxes
clearLunaSeaBox();
clearProfilesBox();
clearIndexersBox();
//Set default profile & enabled profile
profilesBox.put('default', ProfileHiveObject.empty());
lunaSeaBox.put(LunaSeaDatabaseValue.ENABLED_PROFILE.key, 'default');
}
//Get boxes
static Box get lunaSeaBox => Hive.box('lunasea');
static Box get profilesBox => Hive.box<ProfileHiveObject>('profiles');
static Box get indexersBox => Hive.box<IndexerHiveObject>('indexers');
//Clear boxes
static void clearLunaSeaBox() => lunaSeaBox.deleteAll(lunaSeaBox.keys);
static void clearProfilesBox() => profilesBox.deleteAll(profilesBox.keys);
static void clearIndexersBox() => indexersBox.deleteAll(indexersBox.keys);
//Profile values
static String get currentProfile => lunaSeaBox.get('profile');
static ProfileHiveObject get currentProfileObject => profilesBox.get(currentProfile);
}