Rename Bnames boxes names to include the Box
parent
bf79fb1adf
commit
dd77b99ac8
|
@ -5,8 +5,8 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/backblaze_bucket.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||
|
||||
class HiveConfig {
|
||||
|
@ -25,16 +25,16 @@ class HiveConfig {
|
|||
await getEncryptedKey(BNames.serverInstallationEncryptionKey));
|
||||
|
||||
await Hive.openBox<User>(BNames.usersDeprecated);
|
||||
await Hive.openBox<User>(BNames.users, encryptionCipher: cipher);
|
||||
await Hive.openBox<User>(BNames.usersBox, encryptionCipher: cipher);
|
||||
|
||||
Box<User> deprecatedUsers = Hive.box<User>(BNames.usersDeprecated);
|
||||
if (deprecatedUsers.isNotEmpty) {
|
||||
Box<User> users = Hive.box<User>(BNames.users);
|
||||
Box<User> users = Hive.box<User>(BNames.usersBox);
|
||||
users.addAll(deprecatedUsers.values.toList());
|
||||
deprecatedUsers.clear();
|
||||
}
|
||||
|
||||
await Hive.openBox(BNames.serverInstallation, encryptionCipher: cipher);
|
||||
await Hive.openBox(BNames.serverInstallationBox, encryptionCipher: cipher);
|
||||
}
|
||||
|
||||
static Future<Uint8List> getEncryptedKey(String encKey) async {
|
||||
|
@ -61,54 +61,54 @@ class BNames {
|
|||
/// A boolean field of [appSettingsBox] box.
|
||||
static String isOnboardingShowing = 'isOnboardingShowing';
|
||||
|
||||
/// Encryption key to decrypt [serverInstallation] and [users] box.
|
||||
/// Encryption key to decrypt [serverInstallationBox] and [usersBox] box.
|
||||
static String serverInstallationEncryptionKey = 'key';
|
||||
|
||||
/// Server installation box. Contains server details and provider tokens.
|
||||
static String serverInstallation = 'appConfig';
|
||||
static String serverInstallationBox = 'appConfig';
|
||||
|
||||
/// A List<String> field of [serverInstallation] box.
|
||||
/// A List<String> field of [serverInstallationBox] box.
|
||||
static String rootKeys = 'rootKeys';
|
||||
|
||||
/// A boolean field of [serverInstallation] box.
|
||||
/// A boolean field of [serverInstallationBox] box.
|
||||
static String hasFinalChecked = 'hasFinalChecked';
|
||||
|
||||
/// A boolean field of [serverInstallation] box.
|
||||
/// A boolean field of [serverInstallationBox] box.
|
||||
static String isServerStarted = 'isServerStarted';
|
||||
|
||||
/// A [ServerDomain] field of [serverInstallation] box.
|
||||
/// A [ServerDomain] field of [serverInstallationBox] box.
|
||||
static String serverDomain = 'cloudFlareDomain';
|
||||
|
||||
/// A String field of [serverInstallation] box.
|
||||
/// A String field of [serverInstallationBox] box.
|
||||
static String hetznerKey = 'hetznerKey';
|
||||
|
||||
/// A String field of [serverInstallation] box.
|
||||
/// A String field of [serverInstallationBox] box.
|
||||
static String cloudFlareKey = 'cloudFlareKey';
|
||||
|
||||
/// A [User] field of [serverInstallation] box.
|
||||
/// A [User] field of [serverInstallationBox] box.
|
||||
static String rootUser = 'rootUser';
|
||||
|
||||
/// A [ServerHostingDetails] field of [serverInstallation] box.
|
||||
/// A [ServerHostingDetails] field of [serverInstallationBox] box.
|
||||
static String serverDetails = 'hetznerServer';
|
||||
|
||||
/// A [BackblazeCredential] field of [serverInstallation] box.
|
||||
/// A [BackblazeCredential] field of [serverInstallationBox] box.
|
||||
static String backblazeCredential = 'backblazeKey';
|
||||
|
||||
/// A [BackblazeBucket] field of [serverInstallation] box.
|
||||
/// A [BackblazeBucket] field of [serverInstallationBox] box.
|
||||
static String backblazeBucket = 'backblazeBucket';
|
||||
|
||||
/// A boolean field of [serverInstallation] box.
|
||||
/// A boolean field of [serverInstallationBox] box.
|
||||
static String isLoading = 'isLoading';
|
||||
|
||||
/// A boolean field of [serverInstallation] box.
|
||||
/// A boolean field of [serverInstallationBox] box.
|
||||
static String isServerResetedFirstTime = 'isServerResetedFirstTime';
|
||||
|
||||
/// A boolean field of [serverInstallation] box.
|
||||
/// A boolean field of [serverInstallationBox] box.
|
||||
static String isServerResetedSecondTime = 'isServerResetedSecondTime';
|
||||
|
||||
/// Deprecated users box as it is unencrypted
|
||||
static String usersDeprecated = 'users';
|
||||
|
||||
/// Box with users
|
||||
static String users = 'usersEncrypted';
|
||||
static String usersBox = 'usersEncrypted';
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'package:bloc/bloc.dart';
|
|||
import 'package:equatable/equatable.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:selfprivacy/config/hive_config.dart';
|
||||
|
||||
export 'package:provider/provider.dart';
|
||||
|
||||
part 'app_settings_state.dart';
|
||||
|
|
|
@ -8,17 +8,17 @@ import 'package:selfprivacy/logic/api_maps/cloudflare.dart';
|
|||
import 'package:selfprivacy/logic/api_maps/hetzner.dart';
|
||||
import 'package:selfprivacy/logic/api_maps/server.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||
import 'package:selfprivacy/logic/models/message.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||
import 'package:selfprivacy/logic/models/message.dart';
|
||||
import 'package:selfprivacy/ui/components/action_button/action_button.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart';
|
||||
|
||||
import '../server_installation/server_installation_cubit.dart';
|
||||
|
||||
class ServerInstallationRepository {
|
||||
Box box = Hive.box(BNames.serverInstallation);
|
||||
Box box = Hive.box(BNames.serverInstallationBox);
|
||||
|
||||
Future<ServerInstallationState> load() async {
|
||||
final hetznerToken = getIt<ApiConfigModel>().hetznerKey;
|
||||
|
|
|
@ -15,8 +15,8 @@ class UsersCubit extends ServerInstallationDependendCubit<UsersState> {
|
|||
serverInstallationCubit,
|
||||
UsersState(
|
||||
<User>[], User(login: 'root'), User(login: 'loading...')));
|
||||
Box<User> box = Hive.box<User>(BNames.users);
|
||||
Box serverInstallationBox = Hive.box(BNames.serverInstallation);
|
||||
Box<User> box = Hive.box<User>(BNames.usersBox);
|
||||
Box serverInstallationBox = Hive.box(BNames.serverInstallationBox);
|
||||
|
||||
final api = ServerApi();
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ import 'package:hive/hive.dart';
|
|||
import 'package:selfprivacy/config/hive_config.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/backblaze_bucket.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||
|
||||
class ApiConfigModel {
|
||||
Box _box = Hive.box(BNames.serverInstallation);
|
||||
Box _box = Hive.box(BNames.serverInstallationBox);
|
||||
|
||||
ServerHostingDetails? get serverDetails => _serverDetails;
|
||||
String? get hetznerKey => _hetznerKey;
|
||||
|
|
Loading…
Reference in New Issue