mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-09-20 02:17:51 +00:00
fix: App didn't save the server type and location correctly
This commit is contained in:
parent
ad910d564a
commit
1ad8fccbb6
|
@ -115,10 +115,10 @@ class HiveConfig {
|
||||||
|
|
||||||
/// add new migrations here, like:
|
/// add new migrations here, like:
|
||||||
/// if (version < 3) {...}, etc.
|
/// if (version < 3) {...}, etc.
|
||||||
|
}
|
||||||
|
|
||||||
/// update saved version after successfull migrations
|
/// update saved version after successfull migrations
|
||||||
await localSettingsBox.put(BNames.databaseVersion, version);
|
await localSettingsBox.put(BNames.databaseVersion, version);
|
||||||
}
|
|
||||||
} catch (error, stackTrace) {
|
} catch (error, stackTrace) {
|
||||||
log(
|
log(
|
||||||
'error running db migrations',
|
'error running db migrations',
|
||||||
|
|
|
@ -794,13 +794,13 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
||||||
await repository.saveIsServerStarted(true);
|
await repository.saveIsServerStarted(true);
|
||||||
await repository.saveIsServerRebootedFirstTime(true);
|
await repository.saveIsServerRebootedFirstTime(true);
|
||||||
await repository.saveIsServerRebootedSecondTime(true);
|
await repository.saveIsServerRebootedSecondTime(true);
|
||||||
await repository.saveHasFinalChecked(true);
|
|
||||||
await repository.saveIsRecoveringServer(false);
|
await repository.saveIsRecoveringServer(false);
|
||||||
final serverType = await ProvidersController.currentServerProvider!
|
final serverType = await ProvidersController.currentServerProvider!
|
||||||
.getServerType(state.serverDetails!.id);
|
.getServerType(state.serverDetails!.id);
|
||||||
await repository.saveServerType(serverType.data!);
|
await repository.saveServerType(serverType.data!);
|
||||||
await ProvidersController.currentServerProvider!
|
await ProvidersController.currentServerProvider!
|
||||||
.trySetServerLocation(serverType.data!.location.identifier);
|
.trySetServerLocation(serverType.data!.location.identifier);
|
||||||
|
await repository.saveHasFinalChecked(true);
|
||||||
final ServerInstallationRecovery updatedState =
|
final ServerInstallationRecovery updatedState =
|
||||||
(state as ServerInstallationRecovery).copyWith(
|
(state as ServerInstallationRecovery).copyWith(
|
||||||
backblazeCredential: backblazeCredential,
|
backblazeCredential: backblazeCredential,
|
||||||
|
|
|
@ -182,6 +182,9 @@ class ServerInstallationRepository {
|
||||||
if (!domainResult.success || domainResult.data.isEmpty) {
|
if (!domainResult.success || domainResult.data.isEmpty) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
await getIt<ResourcesModel>().removeDnsProviderToken(
|
||||||
|
getIt<ResourcesModel>().dnsProviderCredentials.first,
|
||||||
|
);
|
||||||
|
|
||||||
return domainResult.data.any(
|
return domainResult.data.any(
|
||||||
(final serverDomain) => serverDomain.domainName == domain,
|
(final serverDomain) => serverDomain.domainName == domain,
|
||||||
|
@ -519,6 +522,7 @@ class ServerInstallationRepository {
|
||||||
// We are finished here. Time to save the state and finish the wizard
|
// We are finished here. Time to save the state and finish the wizard
|
||||||
// TODO: A lot of null checks are skipped here. Implication that every value exists might become false in the future.
|
// TODO: A lot of null checks are skipped here. Implication that every value exists might become false in the future.
|
||||||
// TODO: We would actually want to handle token creation elsewhere.
|
// TODO: We would actually want to handle token creation elsewhere.
|
||||||
|
await getIt<WizardDataModel>().moveServerTypeToServerDetails();
|
||||||
final ServerInstallationWizardData wizardData =
|
final ServerInstallationWizardData wizardData =
|
||||||
getIt<WizardDataModel>().serverInstallation!;
|
getIt<WizardDataModel>().serverInstallation!;
|
||||||
await getIt<ResourcesModel>().addServer(
|
await getIt<ResourcesModel>().addServer(
|
||||||
|
|
|
@ -78,6 +78,11 @@ class ResourcesModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addDnsProviderToken(final DnsProviderCredential token) async {
|
Future<void> addDnsProviderToken(final DnsProviderCredential token) async {
|
||||||
|
// Check if this token already exists
|
||||||
|
if (_dnsProviderTokens
|
||||||
|
.any((final credential) => credential.token == token.token)) {
|
||||||
|
throw Exception('Token already exists');
|
||||||
|
}
|
||||||
_dnsProviderTokens.add(token);
|
_dnsProviderTokens.add(token);
|
||||||
await _box.put(BNames.dnsProviderTokens, _dnsProviderTokens);
|
await _box.put(BNames.dnsProviderTokens, _dnsProviderTokens);
|
||||||
}
|
}
|
||||||
|
@ -227,10 +232,33 @@ class WizardDataModel {
|
||||||
await _box.put(BNames.serverInstallationWizardData, _serverInstallation);
|
await _box.put(BNames.serverInstallationWizardData, _serverInstallation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> moveServerTypeToServerDetails() async {
|
||||||
|
final details = _serverInstallation?.serverDetails;
|
||||||
|
if (details != null) {
|
||||||
|
if (_serverInstallation?.serverTypeIdentifier != null &&
|
||||||
|
_serverInstallation?.serverLocation != null) {
|
||||||
|
_serverInstallation = _serverInstallation?.copyWith(
|
||||||
|
serverDetails: () => details.copyWith(
|
||||||
|
serverType: _serverInstallation?.serverTypeIdentifier,
|
||||||
|
serverLocation: _serverInstallation?.serverLocation,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await _box.put(
|
||||||
|
BNames.serverInstallationWizardData,
|
||||||
|
_serverInstallation,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> setServerDetails(final ServerHostingDetails details) async {
|
Future<void> setServerDetails(final ServerHostingDetails details) async {
|
||||||
|
final detailsWithServerType = details.copyWith(
|
||||||
|
serverLocation: _serverInstallation?.serverLocation,
|
||||||
|
serverType: _serverInstallation?.serverTypeIdentifier,
|
||||||
|
);
|
||||||
_serverInstallation =
|
_serverInstallation =
|
||||||
(_serverInstallation ?? ServerInstallationWizardData.empty())
|
(_serverInstallation ?? ServerInstallationWizardData.empty())
|
||||||
.copyWith(serverDetails: () => details);
|
.copyWith(serverDetails: () => detailsWithServerType);
|
||||||
await _box.put(BNames.serverInstallationWizardData, _serverInstallation);
|
await _box.put(BNames.serverInstallationWizardData, _serverInstallation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue