mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Remove useless configuration load checks
This commit is contained in:
parent
613ceadfaa
commit
4f9001cb2b
@ -1,8 +1,6 @@
|
|||||||
import 'package:comunic/helpers/account_helper.dart';
|
import 'package:comunic/helpers/account_helper.dart';
|
||||||
import 'package:comunic/helpers/server_config_helper.dart';
|
|
||||||
import 'package:comunic/models/config.dart';
|
import 'package:comunic/models/config.dart';
|
||||||
import 'package:comunic/models/new_account.dart';
|
import 'package:comunic/models/new_account.dart';
|
||||||
import 'package:comunic/ui/widgets/async_screen_widget.dart';
|
|
||||||
import 'package:comunic/ui/widgets/new_password_input_widget.dart';
|
import 'package:comunic/ui/widgets/new_password_input_widget.dart';
|
||||||
import 'package:comunic/utils/input_utils.dart';
|
import 'package:comunic/utils/input_utils.dart';
|
||||||
import 'package:comunic/utils/intl_utils.dart';
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
@ -76,13 +74,7 @@ class __CreateAccountRouteBodyState extends State<_CreateAccountRouteBody> {
|
|||||||
"An error occurred while creating your account. Please try again.");
|
"An error occurred while creating your account. Please try again.");
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => AsyncScreenWidget(
|
Widget build(BuildContext context) {
|
||||||
onReload: () => ServerConfigurationHelper.ensureLoaded(),
|
|
||||||
onBuild: () => _buildForm(),
|
|
||||||
errorMessage: tr("Failed to load server configuration !"),
|
|
||||||
);
|
|
||||||
|
|
||||||
Widget _buildForm() {
|
|
||||||
if (_isCreating)
|
if (_isCreating)
|
||||||
return Center(
|
return Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
|
@ -30,7 +30,6 @@ class _AccountPrivacySettingsState extends State<AccountPrivacySettings> {
|
|||||||
String _cachedPassword;
|
String _cachedPassword;
|
||||||
|
|
||||||
Future<void> _loadSettings() async {
|
Future<void> _loadSettings() async {
|
||||||
await ServerConfigurationHelper.ensureLoaded();
|
|
||||||
_serverConfig = ServerConfigurationHelper.config;
|
_serverConfig = ServerConfigurationHelper.config;
|
||||||
_userSettings = await SettingsHelper.getDataConservationPolicy();
|
_userSettings = await SettingsHelper.getDataConservationPolicy();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'package:comunic/helpers/server_config_helper.dart';
|
import 'package:comunic/helpers/server_config_helper.dart';
|
||||||
import 'package:comunic/models/server_config.dart';
|
import 'package:comunic/models/server_config.dart';
|
||||||
import 'package:comunic/utils/intl_utils.dart';
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
import 'package:comunic/utils/ui_utils.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// New password input widget
|
/// New password input widget
|
||||||
@ -47,32 +46,13 @@ class NewPasswordInputWidget extends StatefulWidget {
|
|||||||
|
|
||||||
class NewPasswordInputWidgetState extends State<NewPasswordInputWidget> {
|
class NewPasswordInputWidgetState extends State<NewPasswordInputWidget> {
|
||||||
final TextEditingController _controller = TextEditingController();
|
final TextEditingController _controller = TextEditingController();
|
||||||
bool _ready = false;
|
|
||||||
|
|
||||||
String get value => _controller.text;
|
String get value => _controller.text;
|
||||||
|
|
||||||
bool get valid => _ready && value.isNotEmpty && (_errorMessage ?? "").isEmpty;
|
bool get valid => value.isNotEmpty && (_errorMessage ?? "").isEmpty;
|
||||||
|
|
||||||
PasswordPolicy get _policy => ServerConfigurationHelper.config.passwordPolicy;
|
PasswordPolicy get _policy => ServerConfigurationHelper.config.passwordPolicy;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
|
|
||||||
_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Make sure server configuration is loaded
|
|
||||||
void _init() async {
|
|
||||||
try {
|
|
||||||
await ServerConfigurationHelper.ensureLoaded();
|
|
||||||
setState(() => _ready = true);
|
|
||||||
} catch (e, s) {
|
|
||||||
print("Failed to initialize NewPasswordInputWidget! : $e - $s");
|
|
||||||
showSimpleSnack(context, tr("Failed to retrieve server configuration!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant NewPasswordInputWidget oldWidget) {
|
void didUpdateWidget(covariant NewPasswordInputWidget oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
@ -102,7 +82,7 @@ class NewPasswordInputWidgetState extends State<NewPasswordInputWidget> {
|
|||||||
|
|
||||||
/// Generate an error message associated with current password
|
/// Generate an error message associated with current password
|
||||||
String get _errorMessage {
|
String get _errorMessage {
|
||||||
if (!_ready || value.isEmpty) return null;
|
if (value.isEmpty) return null;
|
||||||
|
|
||||||
// Mandatory checks
|
// Mandatory checks
|
||||||
if (!_policy.allowMailInPassword &&
|
if (!_policy.allowMailInPassword &&
|
||||||
|
Loading…
Reference in New Issue
Block a user