Merge branch 'krille/bootstrap' into 'main'

chore: Simplify bootstrap

See merge request famedly/fluffychat!358
This commit is contained in:
Krille Fear 2021-01-23 18:37:31 +00:00
commit 4e2f2d6d43
4 changed files with 36 additions and 120 deletions

View file

@ -78,9 +78,7 @@ class _InvitationSelectionState extends State<InvitationSelection> {
void searchUser(BuildContext context, String text) async {
coolDown?.cancel();
if (text.isEmpty) {
setState(() {
foundProfiles = [];
});
setState(() => foundProfiles = []);
}
currentSearchTerm = text;
if (currentSearchTerm.isEmpty) return;

View file

@ -486,109 +486,6 @@ class _SettingsState extends State<Settings> {
title: Text(L10n.of(context).appLock),
onTap: () => _setAppLockAction(context),
),
ListTile(
trailing: Icon(Icons.compare_arrows_outlined),
title: Text(client.encryption.crossSigning.enabled
? L10n.of(context).crossSigningEnabled
: L10n.of(context).crossSigningDisabled),
subtitle: client.encryption.crossSigning.enabled
? Text(client.isUnknownSession
? L10n.of(context).unknownSessionVerify
: L10n.of(context).sessionVerified +
', ' +
(crossSigningCached == null
? ''
: (crossSigningCached
? L10n.of(context).keysCached
: L10n.of(context).keysMissing)))
: null,
onTap: () async {
if (!client.encryption.crossSigning.enabled) {
return BootstrapDialog(l10n: L10n.of(context))
.show(context);
}
if (client.isUnknownSession) {
final input = await showTextInputDialog(
context: context,
title: L10n.of(context).askSSSSVerify,
textFields: [
DialogTextField(
hintText: L10n.of(context).passphraseOrKey,
obscureText: true,
minLines: 1,
maxLines: 1,
)
],
);
if (input != null) {
final valid = await showFutureLoadingDialog(
context: context,
future: () async {
// make sure the loading spinner shows before we test the keys
await Future.delayed(Duration(milliseconds: 100));
var valid = false;
try {
await client.encryption.crossSigning
.selfSign(recoveryKey: input.single);
valid = true;
} catch (_) {
try {
await client.encryption.crossSigning
.selfSign(passphrase: input.single);
valid = true;
} catch (_) {
valid = false;
}
}
return valid;
});
if (valid.result == true) {
await showOkAlertDialog(
context: context,
message: L10n.of(context).verifiedSession,
);
setState(() {
crossSigningCachedFuture = null;
crossSigningCached = null;
megolmBackupCachedFuture = null;
megolmBackupCached = null;
});
} else {
await showOkAlertDialog(
context: context,
message: L10n.of(context).incorrectPassphraseOrKey,
);
}
}
}
if (!(await client.encryption.crossSigning.isCached())) {
await requestSSSSCache(context);
}
},
),
ListTile(
trailing: Icon(Icons.wb_cloudy_outlined),
title: Text(client.encryption.keyManager.enabled
? L10n.of(context).onlineKeyBackupEnabled
: L10n.of(context).onlineKeyBackupDisabled),
subtitle: client.encryption.keyManager.enabled
? Text(megolmBackupCached == null
? ''
: (megolmBackupCached
? L10n.of(context).keysCached
: L10n.of(context).keysMissing))
: null,
onTap: () async {
if (!client.encryption.keyManager.enabled) {
return BootstrapDialog(l10n: L10n.of(context))
.show(context);
}
if (!(await client.encryption.keyManager.isCached())) {
await requestSSSSCache(context);
}
},
),
ListTile(
title: Text(L10n.of(context).yourPublicKey),
onTap: () => showOkAlertDialog(
@ -598,6 +495,16 @@ class _SettingsState extends State<Settings> {
),
trailing: Icon(Icons.vpn_key_outlined),
),
ListTile(
title: Text(L10n.of(context).cachedKeys),
trailing: Icon(Icons.wb_cloudy_outlined),
subtitle: Text(
'${client.encryption.keyManager.enabled ? L10n.of(context).onlineKeyBackupEnabled : L10n.of(context).onlineKeyBackupDisabled}\n${client.encryption.crossSigning.enabled ? L10n.of(context).crossSigningEnabled : L10n.of(context).crossSigningDisabled}'),
onTap: () => BootstrapDialog(
l10n: L10n.of(context),
client: Matrix.of(context).client,
).show(context),
),
},
Divider(thickness: 1),
ListTile(