chore: Post-merge cleanup

This commit is contained in:
Inex Code 2024-06-25 18:06:50 +03:00
parent 4ce7b0bcdb
commit 78b026ed42
5 changed files with 23 additions and 28 deletions

View file

@ -19,7 +19,6 @@ Future<void> getItSetup() async {
getIt.registerSingleton<WizardDataModel>(WizardDataModel()..init()); getIt.registerSingleton<WizardDataModel>(WizardDataModel()..init());
final apiConfigModel = ApiConfigModel(); final apiConfigModel = ApiConfigModel();
await apiConfigModel.init();
getIt.registerSingleton<ApiConfigModel>(apiConfigModel); getIt.registerSingleton<ApiConfigModel>(apiConfigModel);
getIt.registerSingleton<ApiConnectionRepository>( getIt.registerSingleton<ApiConnectionRepository>(

View file

@ -41,45 +41,48 @@ class HiveConfig {
await getEncryptedKey(BNames.serverInstallationEncryptionKey), await getEncryptedKey(BNames.serverInstallationEncryptionKey),
); );
await Hive.openBox(BNames.serverInstallationBox, encryptionCipher: cipher); await Hive.openBox(BNames.serverInstallationBox,
encryptionCipher: cipher);
await Hive.openBox(BNames.resourcesBox, encryptionCipher: cipher); await Hive.openBox(BNames.resourcesBox, encryptionCipher: cipher);
await Hive.openBox(BNames.wizardDataBox, encryptionCipher: cipher); await Hive.openBox(BNames.wizardDataBox, encryptionCipher: cipher);
final Box resourcesBox = Hive.box(BNames.resourcesBox); final Box resourcesBox = Hive.box(BNames.resourcesBox);
if (resourcesBox.isEmpty) { if (resourcesBox.isEmpty) {
final Box serverInstallationBox = Hive.box(BNames.serverInstallationBox); final Box serverInstallationBox =
Hive.box(BNames.serverInstallationBox);
final String? serverProviderKey = final String? serverProviderKey =
serverInstallationBox.get(BNames.hetznerKey); serverInstallationBox.get(BNames.hetznerKey);
final String? serverLocation = final String? serverLocation =
serverInstallationBox.get(BNames.serverLocation); serverInstallationBox.get(BNames.serverLocation);
final String? dnsProviderKey = final String? dnsProviderKey =
serverInstallationBox.get(BNames.cloudFlareKey); serverInstallationBox.get(BNames.cloudFlareKey);
final BackupsCredential? backblazeCredential = final BackupsCredential? backblazeCredential =
serverInstallationBox.get(BNames.backblazeCredential); serverInstallationBox.get(BNames.backblazeCredential);
final ServerDomain? serverDomain = final ServerDomain? serverDomain =
serverInstallationBox.get(BNames.serverDomain); serverInstallationBox.get(BNames.serverDomain);
final ServerHostingDetails? serverDetails = final ServerHostingDetails? serverDetails =
serverInstallationBox.get(BNames.serverDetails); serverInstallationBox.get(BNames.serverDetails);
final BackblazeBucket? backblazeBucket = final BackblazeBucket? backblazeBucket =
serverInstallationBox.get(BNames.backblazeBucket); serverInstallationBox.get(BNames.backblazeBucket);
final String? serverType = final String? serverType =
serverInstallationBox.get(BNames.serverTypeIdentifier); serverInstallationBox.get(BNames.serverTypeIdentifier);
final ServerProviderType? serverProvider = final ServerProviderType? serverProvider =
serverInstallationBox.get(BNames.serverProvider); serverInstallationBox.get(BNames.serverProvider);
final DnsProviderType? dnsProvider = final DnsProviderType? dnsProvider =
serverInstallationBox.get(BNames.dnsProvider); serverInstallationBox.get(BNames.dnsProvider);
if (serverProviderKey != null && if (serverProviderKey != null &&
(serverProvider != null || (serverProvider != null ||
(serverDetails != null && (serverDetails != null &&
serverDetails.provider != ServerProviderType.unknown))) { serverDetails.provider != ServerProviderType.unknown))) {
final ServerProviderCredential serverProviderCredential = final ServerProviderCredential serverProviderCredential =
ServerProviderCredential( ServerProviderCredential(
tokenId: null, tokenId: null,
token: serverProviderKey, token: serverProviderKey,
provider: serverProvider ?? serverDetails!.provider, provider: serverProvider ?? serverDetails!.provider,
associatedServerIds: serverDetails != null ? [serverDetails.id] : [], associatedServerIds:
serverDetails != null ? [serverDetails.id] : [],
); );
await resourcesBox await resourcesBox
@ -91,12 +94,12 @@ class HiveConfig {
(serverDomain != null && (serverDomain != null &&
serverDomain.provider != DnsProviderType.unknown))) { serverDomain.provider != DnsProviderType.unknown))) {
final DnsProviderCredential dnsProviderCredential = final DnsProviderCredential dnsProviderCredential =
DnsProviderCredential( DnsProviderCredential(
tokenId: null, tokenId: null,
token: dnsProviderKey, token: dnsProviderKey,
provider: dnsProvider ?? serverDomain!.provider, provider: dnsProvider ?? serverDomain!.provider,
associatedDomainNames: associatedDomainNames:
serverDomain != null ? [serverDomain.domainName] : [], serverDomain != null ? [serverDomain.domainName] : [],
); );
await resourcesBox await resourcesBox
@ -128,7 +131,6 @@ class HiveConfig {
print('HiveConfig: Error while opening boxes: $e'); print('HiveConfig: Error while opening boxes: $e');
rethrow; rethrow;
} }
} }
static Future<Uint8List> getEncryptedKey(final String encKey) async { static Future<Uint8List> getEncryptedKey(final String encKey) async {

View file

@ -5,8 +5,6 @@ import 'package:selfprivacy/logic/models/hive/backblaze_bucket.dart';
class ApiConfigModel { class ApiConfigModel {
final Box _box = Hive.box(BNames.serverInstallationBox); final Box _box = Hive.box(BNames.serverInstallationBox);
String? get localeCode => _localeCode;
static const localeCodeFallback = 'en'; static const localeCodeFallback = 'en';
String? _localeCode; String? _localeCode;
@ -17,12 +15,4 @@ class ApiConfigModel {
Future<void> setBackblazeBucket(final BackblazeBucket value) async { Future<void> setBackblazeBucket(final BackblazeBucket value) async {
await _box.put(BNames.backblazeBucket, value); await _box.put(BNames.backblazeBucket, value);
} }
// TODO: Remove it
void clear() {
}
// TODO: Remove it
void init() {
}
} }

View file

@ -9,6 +9,7 @@
#include <connectivity_plus/connectivity_plus_windows_plugin.h> #include <connectivity_plus/connectivity_plus_windows_plugin.h>
#include <dynamic_color/dynamic_color_plugin_c_api.h> #include <dynamic_color/dynamic_color_plugin_c_api.h>
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h> #include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
#include <local_auth_windows/local_auth_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h> #include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
@ -18,6 +19,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); registry->GetRegistrarForPlugin("DynamicColorPluginCApi"));
FlutterSecureStorageWindowsPluginRegisterWithRegistrar( FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
LocalAuthPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("LocalAuthPlugin"));
UrlLauncherWindowsRegisterWithRegistrar( UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows")); registry->GetRegistrarForPlugin("UrlLauncherWindows"));
} }

View file

@ -6,6 +6,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
connectivity_plus connectivity_plus
dynamic_color dynamic_color
flutter_secure_storage_windows flutter_secure_storage_windows
local_auth_windows
url_launcher_windows url_launcher_windows
) )