feat: use onInitStateChanged in login function to redirect to chat view quicker (#1696)

pull/1593/head
ggurdin 9 months ago committed by GitHub
parent 1e40e1d1a6
commit 8dd74d7e8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:go_router/go_router.dart';
import 'package:matrix/matrix.dart';
import 'package:fluffychat/pangea/common/constants/local.key.dart';
@ -176,20 +177,27 @@ class LoginController extends State<Login> {
// #Pangea
// await matrix.getLoginClient().login(
final loginRes = await matrix.getLoginClient().login(
// Pangea#
LoginType.mLoginPassword,
identifier: identifier,
// To stay compatible with older server versions
// ignore: deprecated_member_use
user: identifier.type == AuthenticationIdentifierTypes.userId
? username
: null,
// #Pangea
// password: passwordController.text,
password: passwordController.text.trim(),
// Pangea#
initialDeviceDisplayName: PlatformInfos.clientName,
);
// Pangea#
LoginType.mLoginPassword,
identifier: identifier,
// To stay compatible with older server versions
// ignore: deprecated_member_use
user: identifier.type == AuthenticationIdentifierTypes.userId
? username
: null,
// #Pangea
// password: passwordController.text,
password: passwordController.text.trim(),
// Pangea#
initialDeviceDisplayName: PlatformInfos.clientName,
// #Pangea
onInitStateChanged: (state) {
if (state == InitState.settingUpEncryption) {
context.go("/rooms");
}
},
// Pangea#
);
MatrixState.pangeaController.pStoreService
.save(PLocalKey.loginType, 'password');
// #Pangea

@ -123,7 +123,9 @@ class UserController extends BaseController {
data: {},
);
} finally {
_profileCompleter!.complete();
if (!_profileCompleter!.isCompleted) {
_profileCompleter!.complete();
}
}
return _profileCompleter!.future;

@ -37,21 +37,32 @@ Future<Result<T>> showFutureLoadingDialog<T>({
}
}
final result = await showAdaptiveDialog<Result<T>>(
context: context,
barrierDismissible: barrierDismissible,
builder: (BuildContext context) => LoadingDialog<T>(
future: futureExec,
title: title,
backLabel: backLabel,
exceptionContext: exceptionContext,
),
// #Pangea
if (context.mounted) {
// Pangea#
final result = await showAdaptiveDialog<Result<T>>(
context: context,
barrierDismissible: barrierDismissible,
builder: (BuildContext context) => LoadingDialog<T>(
future: futureExec,
title: title,
backLabel: backLabel,
exceptionContext: exceptionContext,
),
);
return result ??
Result.error(
Exception('FutureDialog canceled'),
StackTrace.current,
);
}
// #Pangea
return Result.error(
Exception('FutureDialog canceled'),
StackTrace.current,
);
return result ??
Result.error(
Exception('FutureDialog canceled'),
StackTrace.current,
);
// Pangea#
}
class LoadingDialog<T> extends StatefulWidget {

Loading…
Cancel
Save