feat: use onInitStateChanged in login function to redirect to chat view quicker (#1696)
This commit is contained in:
parent
1e40e1d1a6
commit
8dd74d7e8a
3 changed files with 50 additions and 29 deletions
|
|
@ -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…
Add table
Reference in a new issue