💄 Optimize connection experience

This commit is contained in:
LittleSheep 2024-05-12 22:29:38 +08:00
parent 8e0e2dacfe
commit b9461e5019
3 changed files with 21 additions and 12 deletions

View File

@ -55,6 +55,8 @@ class ChatProvider extends ChangeNotifier {
if (!noRetry) {
await auth.client!.refreshToken(auth.client!.currentRefreshToken!);
connect(auth, noRetry: true);
} else {
rethrow;
}
}

View File

@ -95,6 +95,8 @@ class NotifyProvider extends ChangeNotifier {
if (!noRetry) {
await auth.client!.refreshToken(auth.client!.currentRefreshToken!);
connect(auth, noRetry: true);
} else {
rethrow;
}
}

View File

@ -5,6 +5,7 @@ import 'package:solian/providers/chat.dart';
import 'package:solian/providers/keypair.dart';
import 'package:solian/providers/notify.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:solian/widgets/exts.dart';
class ProviderInitializer extends StatefulWidget {
final Widget child;
@ -29,18 +30,22 @@ class _ProviderInitializerState extends State<ProviderInitializer> {
),
);
if (await auth.isAuthorized()) {
if (auth.client == null) {
await auth.loadClient();
}
try {
if (await auth.isAuthorized()) {
if (auth.client == null) {
await auth.loadClient();
}
nty.fetch(auth);
chat.connect(auth);
keypair.channel = await nty.connect(
auth,
onKexRequest: keypair.provideKeypair,
onKexProvide: keypair.receiveKeypair,
);
nty.fetch(auth);
chat.connect(auth);
keypair.channel = await nty.connect(
auth,
onKexRequest: keypair.provideKeypair,
onKexProvide: keypair.receiveKeypair,
);
}
} catch (e) {
context.showErrorDialog(e);
}
notify.close();
@ -56,4 +61,4 @@ class _ProviderInitializerState extends State<ProviderInitializer> {
Widget build(BuildContext context) {
return widget.child;
}
}
}