mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 12:14:11 +00:00 
			
		
		
		
	Remove useless configuration load checks
This commit is contained in:
		@@ -1,8 +1,6 @@
 | 
			
		||||
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/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/utils/input_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.");
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) => AsyncScreenWidget(
 | 
			
		||||
        onReload: () => ServerConfigurationHelper.ensureLoaded(),
 | 
			
		||||
        onBuild: () => _buildForm(),
 | 
			
		||||
        errorMessage: tr("Failed to load server configuration !"),
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
  Widget _buildForm() {
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    if (_isCreating)
 | 
			
		||||
      return Center(
 | 
			
		||||
        child: CircularProgressIndicator(),
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,6 @@ class _AccountPrivacySettingsState extends State<AccountPrivacySettings> {
 | 
			
		||||
  String _cachedPassword;
 | 
			
		||||
 | 
			
		||||
  Future<void> _loadSettings() async {
 | 
			
		||||
    await ServerConfigurationHelper.ensureLoaded();
 | 
			
		||||
    _serverConfig = ServerConfigurationHelper.config;
 | 
			
		||||
    _userSettings = await SettingsHelper.getDataConservationPolicy();
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
import 'package:comunic/helpers/server_config_helper.dart';
 | 
			
		||||
import 'package:comunic/models/server_config.dart';
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
import 'package:comunic/utils/ui_utils.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
/// New password input widget
 | 
			
		||||
@@ -47,32 +46,13 @@ class NewPasswordInputWidget extends StatefulWidget {
 | 
			
		||||
 | 
			
		||||
class NewPasswordInputWidgetState extends State<NewPasswordInputWidget> {
 | 
			
		||||
  final TextEditingController _controller = TextEditingController();
 | 
			
		||||
  bool _ready = false;
 | 
			
		||||
 | 
			
		||||
  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;
 | 
			
		||||
 | 
			
		||||
  @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
 | 
			
		||||
  void didUpdateWidget(covariant NewPasswordInputWidget oldWidget) {
 | 
			
		||||
    super.didUpdateWidget(oldWidget);
 | 
			
		||||
@@ -102,7 +82,7 @@ class NewPasswordInputWidgetState extends State<NewPasswordInputWidget> {
 | 
			
		||||
 | 
			
		||||
  /// Generate an error message associated with current password
 | 
			
		||||
  String get _errorMessage {
 | 
			
		||||
    if (!_ready || value.isEmpty) return null;
 | 
			
		||||
    if (value.isEmpty) return null;
 | 
			
		||||
 | 
			
		||||
    // Mandatory checks
 | 
			
		||||
    if (!_policy.allowMailInPassword &&
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user