mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 03:45:12 +00:00
fix: Missing null check and bootstrap ask
This commit is contained in:
parent
597e723515
commit
21801318eb
4 changed files with 31 additions and 2 deletions
|
@ -903,6 +903,11 @@
|
|||
"type": "text",
|
||||
"placeholders": {}
|
||||
},
|
||||
"dontAskAgain": "Cancel and don't ask again",
|
||||
"@dontAskAgain": {
|
||||
"type": "text",
|
||||
"placeholders": {}
|
||||
},
|
||||
"encrypted": "Encrypted",
|
||||
"@encrypted": {
|
||||
"type": "text",
|
||||
|
|
|
@ -18,4 +18,6 @@ abstract class SettingKeys {
|
|||
static const String unifiedPushEndpoint = 'chat.fluffy.unifiedpush.endpoint';
|
||||
static const String notificationCurrentIds = 'chat.fluffy.notification_ids';
|
||||
static const String ownStatusMessage = 'chat.fluffy.status_msg';
|
||||
static const String dontAskForBootstrapKey =
|
||||
'chat.fluffychat.dont_ask_bootstrap';
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:fluffychat/config/setting_keys.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/flutter_matrix_hive_database.dart';
|
||||
import 'package:matrix/encryption.dart';
|
||||
import 'package:matrix/encryption/utils/bootstrap.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
@ -65,6 +67,12 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
});
|
||||
}
|
||||
|
||||
void cancelAndDontAskAgain() async {
|
||||
await (widget.client.database as FlutterMatrixHiveStore)
|
||||
.put(SettingKeys.dontAskForBootstrapKey, true);
|
||||
Navigator.of(context, rootNavigator: false).pop<bool>(false);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_wipe ??= widget.wipe;
|
||||
|
@ -81,6 +89,11 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
label: L10n.of(context).next,
|
||||
onPressed: () => _createBootstrap(false),
|
||||
));
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
label: L10n.of(context).dontAskAgain,
|
||||
onPressed: cancelAndDontAskAgain,
|
||||
textColor: Colors.red,
|
||||
));
|
||||
} else if (bootstrap.newSsssKey?.recoveryKey != null &&
|
||||
_recoveryKeyStored == false) {
|
||||
final key = bootstrap.newSsssKey.recoveryKey;
|
||||
|
|
|
@ -2,6 +2,8 @@ import 'dart:async';
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:fluffychat/config/setting_keys.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/flutter_matrix_hive_database.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:fluffychat/utils/fluffy_share.dart';
|
||||
|
@ -156,6 +158,11 @@ class ChatListController extends State<ChatList> {
|
|||
_initReceiveSharingIntent();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
if (!Matrix.of(context).client.encryptionEnabled) return;
|
||||
if ((Matrix.of(context).client.database as FlutterMatrixHiveStore)
|
||||
.get(SettingKeys.dontAskForBootstrapKey) ==
|
||||
true) {
|
||||
return;
|
||||
}
|
||||
final crossSigning = await crossSigningCachedFuture;
|
||||
final needsBootstrap =
|
||||
Matrix.of(context).client.encryption?.crossSigning?.enabled ==
|
||||
|
@ -181,10 +188,12 @@ class ChatListController extends State<ChatList> {
|
|||
if (room.isSpace) return false;
|
||||
if (activeSpaceId != null) {
|
||||
final space = Matrix.of(context).client.getRoomById(activeSpaceId);
|
||||
if (space.spaceChildren.any((child) => child.roomId == room.id)) {
|
||||
if (space.spaceChildren?.any((child) => child.roomId == room.id) ??
|
||||
false) {
|
||||
return true;
|
||||
}
|
||||
if (room.spaceParents.any((parent) => parent.roomId == activeSpaceId)) {
|
||||
if (room.spaceParents?.any((parent) => parent.roomId == activeSpaceId) ??
|
||||
false) {
|
||||
return true;
|
||||
}
|
||||
if (room.isDirectChat &&
|
||||
|
|
Loading…
Reference in a new issue