fix(initializing): Implement store and load of server provider from BNames

routes-refactor
NaiJi ✨ 2022-10-21 08:34:36 +04:00
parent df9ec28d02
commit b574659dc3
3 changed files with 9 additions and 3 deletions

View File

@ -118,6 +118,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
void setServerProviderKey(final String serverProviderKey) async { void setServerProviderKey(final String serverProviderKey) async {
await repository.saveServerProviderKey(serverProviderKey); await repository.saveServerProviderKey(serverProviderKey);
if (state is ServerInstallationRecovery) { if (state is ServerInstallationRecovery) {
emit( emit(
(state as ServerInstallationRecovery).copyWith( (state as ServerInstallationRecovery).copyWith(

View File

@ -56,17 +56,20 @@ class ServerInstallationRepository {
final String? cloudflareToken = getIt<ApiConfigModel>().cloudFlareKey; final String? cloudflareToken = getIt<ApiConfigModel>().cloudFlareKey;
final String? serverTypeIdentificator = getIt<ApiConfigModel>().serverType; final String? serverTypeIdentificator = getIt<ApiConfigModel>().serverType;
final ServerDomain? serverDomain = getIt<ApiConfigModel>().serverDomain; final ServerDomain? serverDomain = getIt<ApiConfigModel>().serverDomain;
final ServerProvider? serverProvider =
getIt<ApiConfigModel>().serverProvider;
final BackblazeCredential? backblazeCredential = final BackblazeCredential? backblazeCredential =
getIt<ApiConfigModel>().backblazeCredential; getIt<ApiConfigModel>().backblazeCredential;
final ServerHostingDetails? serverDetails = final ServerHostingDetails? serverDetails =
getIt<ApiConfigModel>().serverDetails; getIt<ApiConfigModel>().serverDetails;
if (serverDetails != null && if (serverProvider != null ||
serverDetails.provider != ServerProvider.unknown) { (serverDetails != null &&
serverDetails.provider != ServerProvider.unknown)) {
serverProviderApiFactory = serverProviderApiFactory =
ApiFactoryCreator.createServerProviderApiFactory( ApiFactoryCreator.createServerProviderApiFactory(
ServerProviderApiFactorySettings( ServerProviderApiFactorySettings(
provider: serverDetails.provider, provider: serverProvider ?? serverDetails!.provider,
location: location, location: location,
), ),
); );

View File

@ -82,6 +82,7 @@ class ApiConfigModel {
_serverDetails = null; _serverDetails = null;
_backblazeBucket = null; _backblazeBucket = null;
_serverType = null; _serverType = null;
_serverProvider = null;
} }
void init() { void init() {
@ -93,5 +94,6 @@ class ApiConfigModel {
_serverDetails = _box.get(BNames.serverDetails); _serverDetails = _box.get(BNames.serverDetails);
_backblazeBucket = _box.get(BNames.backblazeBucket); _backblazeBucket = _box.get(BNames.backblazeBucket);
_serverType = _box.get(BNames.serverTypeIdentifier); _serverType = _box.get(BNames.serverTypeIdentifier);
_serverProvider = _box.get(BNames.serverProvider);
} }
} }