mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 06:15:10 +00:00
fix: Bootstrap on first try fails sometimes
This commit is contained in:
parent
dd34f3c232
commit
1d934c5353
4 changed files with 50 additions and 45 deletions
|
@ -412,17 +412,19 @@ abstract class AppRoutes {
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
static Page defaultPageBuilder(BuildContext context, Widget child) =>
|
static Page defaultPageBuilder(BuildContext context, Widget child) {
|
||||||
CustomTransitionPage(
|
Matrix.of(context).navigatorContext = context;
|
||||||
child: child,
|
return CustomTransitionPage(
|
||||||
transitionsBuilder: (context, animation, secondaryAnimation, child) =>
|
child: child,
|
||||||
FluffyThemes.isColumnMode(context)
|
transitionsBuilder: (context, animation, secondaryAnimation, child) =>
|
||||||
? FadeTransition(opacity: animation, child: child)
|
FluffyThemes.isColumnMode(context)
|
||||||
: CupertinoPageTransition(
|
? FadeTransition(opacity: animation, child: child)
|
||||||
primaryRouteAnimation: animation,
|
: CupertinoPageTransition(
|
||||||
secondaryRouteAnimation: secondaryAnimation,
|
primaryRouteAnimation: animation,
|
||||||
linearTransition: false,
|
secondaryRouteAnimation: secondaryAnimation,
|
||||||
child: child,
|
linearTransition: false,
|
||||||
),
|
child: child,
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||||
|
@ -8,9 +7,9 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||||
import 'package:matrix/encryption.dart';
|
import 'package:matrix/encryption.dart';
|
||||||
import 'package:matrix/encryption/utils/bootstrap.dart';
|
import 'package:matrix/encryption/utils/bootstrap.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
|
||||||
|
|
||||||
import 'package:fluffychat/config/themes.dart';
|
import 'package:fluffychat/config/themes.dart';
|
||||||
|
import 'package:fluffychat/utils/fluffy_share.dart';
|
||||||
import 'package:fluffychat/utils/platform_infos.dart';
|
import 'package:fluffychat/utils/platform_infos.dart';
|
||||||
import 'package:fluffychat/widgets/adaptive_flat_button.dart';
|
import 'package:fluffychat/widgets/adaptive_flat_button.dart';
|
||||||
import '../../utils/adaptive_bottom_sheet.dart';
|
import '../../utils/adaptive_bottom_sheet.dart';
|
||||||
|
@ -91,9 +90,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
_wipe ??= widget.wipe;
|
_wipe ??= widget.wipe;
|
||||||
final buttons = <AdaptiveFlatButton>[];
|
final buttons = <AdaptiveFlatButton>[];
|
||||||
Widget body = PlatformInfos.isCupertinoStyle
|
Widget body = const CircularProgressIndicator.adaptive();
|
||||||
? const CupertinoActivityIndicator()
|
|
||||||
: const LinearProgressIndicator();
|
|
||||||
titleText = L10n.of(context)!.loadingPleaseWait;
|
titleText = L10n.of(context)!.loadingPleaseWait;
|
||||||
|
|
||||||
if (bootstrap.newSsssKey?.recoveryKey != null &&
|
if (bootstrap.newSsssKey?.recoveryKey != null &&
|
||||||
|
@ -163,12 +160,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
||||||
value: _recoveryKeyCopied,
|
value: _recoveryKeyCopied,
|
||||||
activeColor: Theme.of(context).colorScheme.primary,
|
activeColor: Theme.of(context).colorScheme.primary,
|
||||||
onChanged: (b) {
|
onChanged: (b) {
|
||||||
final box = context.findRenderObject() as RenderBox;
|
FluffyShare.share(key!, context);
|
||||||
Share.share(
|
|
||||||
key!,
|
|
||||||
sharePositionOrigin:
|
|
||||||
box.localToGlobal(Offset.zero) & box.size,
|
|
||||||
);
|
|
||||||
setState(() => _recoveryKeyCopied = true);
|
setState(() => _recoveryKeyCopied = true);
|
||||||
},
|
},
|
||||||
title: Text(L10n.of(context)!.copyToClipboard),
|
title: Text(L10n.of(context)!.copyToClipboard),
|
||||||
|
@ -295,18 +287,31 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
||||||
_recoveryKeyInputLoading = true;
|
_recoveryKeyInputLoading = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
final key =
|
final key = _recoveryKeyTextEditingController
|
||||||
_recoveryKeyTextEditingController.text;
|
.text
|
||||||
|
.trim();
|
||||||
await bootstrap.newSsssKey!.unlock(
|
await bootstrap.newSsssKey!.unlock(
|
||||||
keyOrPassphrase: key,
|
keyOrPassphrase: key,
|
||||||
);
|
);
|
||||||
Logs().d('SSSS unlocked');
|
|
||||||
await bootstrap.client.encryption!.crossSigning
|
|
||||||
.selfSign(
|
|
||||||
keyOrPassphrase: key,
|
|
||||||
);
|
|
||||||
Logs().d('Successful elfsigned');
|
|
||||||
await bootstrap.openExistingSsss();
|
await bootstrap.openExistingSsss();
|
||||||
|
Logs().d('SSSS unlocked');
|
||||||
|
if (bootstrap.encryption.crossSigning.enabled) {
|
||||||
|
Logs().v(
|
||||||
|
'Cross signing is already enabled. Try to self-sign',
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
await bootstrap
|
||||||
|
.client.encryption!.crossSigning
|
||||||
|
.selfSign(recoveryKey: key);
|
||||||
|
Logs().d('Successful selfsigned');
|
||||||
|
} catch (e, s) {
|
||||||
|
Logs().e(
|
||||||
|
'Unable to self sign with recovery key after successfully open existing SSSS',
|
||||||
|
e,
|
||||||
|
s,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logs().w('Unable to unlock SSSS', e, s);
|
Logs().w('Unable to unlock SSSS', e, s);
|
||||||
setState(
|
setState(
|
||||||
|
@ -435,18 +440,12 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final title = Text(titleText!);
|
return Scaffold(
|
||||||
if (PlatformInfos.isCupertinoStyle) {
|
appBar: AppBar(
|
||||||
return CupertinoAlertDialog(
|
title: Text(titleText ?? L10n.of(context)!.loadingPleaseWait),
|
||||||
title: title,
|
),
|
||||||
content: body,
|
body: Center(child: body),
|
||||||
actions: buttons,
|
bottomNavigationBar: Row(children: buttons),
|
||||||
);
|
|
||||||
}
|
|
||||||
return AlertDialog(
|
|
||||||
title: title,
|
|
||||||
content: body,
|
|
||||||
actions: buttons,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,6 +182,10 @@ class _LoginButton extends StatelessWidget {
|
||||||
width: 256,
|
width: 256,
|
||||||
child: OutlinedButton(
|
child: OutlinedButton(
|
||||||
style: OutlinedButton.styleFrom(
|
style: OutlinedButton.styleFrom(
|
||||||
|
side: BorderSide(
|
||||||
|
width: 1,
|
||||||
|
color: Theme.of(context).colorScheme.onBackground,
|
||||||
|
),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(90),
|
borderRadius: BorderRadius.circular(90),
|
||||||
),
|
),
|
||||||
|
|
|
@ -60,7 +60,7 @@ static void my_application_activate(GApplication* application) {
|
||||||
gtk_window_set_title(window, "fluffychat");
|
gtk_window_set_title(window, "fluffychat");
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_window_set_default_size(window, 864, 600);
|
gtk_window_set_default_size(window, 864, 680);
|
||||||
|
|
||||||
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
||||||
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
|
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
|
||||||
|
|
Loading…
Reference in a new issue