design: Move chat backup header to settings

This commit is contained in:
Christian Pauly 2022-08-28 13:34:57 +02:00
commit b742fb9bda
4 changed files with 65 additions and 86 deletions

View file

@ -211,19 +211,6 @@ class ChatListController extends State<ChatList>
}
final selectedRoomIds = <String>{};
bool? crossSigningCached;
bool showChatBackupBanner = false;
void firstRunBootstrapAction() async {
setState(() {
showChatBackupBanner = false;
});
await BootstrapDialog(
client: Matrix.of(context).client,
).show(context);
VRouter.of(context).to('/rooms');
}
String? get activeChat => VRouter.of(context).pathParameters['roomid'];
@ -314,24 +301,6 @@ class ChatListController extends State<ChatList>
super.initState();
}
void checkBootstrap() async {
if (!Matrix.of(context).client.encryptionEnabled) return;
await Matrix.of(context).client.accountDataLoading;
await Matrix.of(context).client.userDeviceKeysLoading;
final crossSigning =
await Matrix.of(context).client.encryption?.crossSigning.isCached() ??
false;
final needsBootstrap =
Matrix.of(context).client.encryption?.crossSigning.enabled == false ||
crossSigning == false;
final isUnknownSession = Matrix.of(context).client.isUnknownSession;
if (needsBootstrap || isUnknownSession) {
setState(() {
showChatBackupBanner = true;
});
}
}
@override
void dispose() {
_intentDataStreamSubscription?.cancel();
@ -538,7 +507,17 @@ class ChatListController extends State<ChatList>
await client.accountDataLoading;
if (client.prevBatch == null) {
await client.onSync.stream.first;
// Display first login bootstrap if enabled
if (client.encryption?.keyManager.enabled == true) {
if (await client.encryption?.keyManager.isCached() == false ||
await client.encryption?.crossSigning.isCached() == false ||
client.isUnknownSession) {
await BootstrapDialog(client: client).show(context);
}
}
}
// Load space members to display DM rooms
final spaceId = activeSpaceId;
if (spaceId != null) {
@ -553,7 +532,6 @@ class ChatListController extends State<ChatList>
setState(() {
waitForFirstSync = true;
});
WidgetsBinding.instance.addPostFrameCallback((_) => checkBootstrap());
return;
}

View file

@ -146,44 +146,6 @@ class _ChatListViewBodyState extends State<ChatListViewBody> {
StoriesHeader(
filter: widget.controller.searchController.text,
),
AnimatedContainer(
height: !widget.controller.isSearchMode &&
widget.controller.showChatBackupBanner
? 54
: 0,
duration: const Duration(milliseconds: 300),
clipBehavior: Clip.hardEdge,
curve: Curves.bounceInOut,
decoration: const BoxDecoration(),
child: Material(
color: Theme.of(context).colorScheme.surface,
child: ListTile(
leading: CircleAvatar(
radius: Avatar.defaultSize / 2,
backgroundColor:
Theme.of(context).colorScheme.surfaceVariant,
foregroundColor:
Theme.of(context).colorScheme.onSurfaceVariant,
child: const Icon(Icons.enhanced_encryption_outlined),
),
title: Text(
(Matrix.of(context)
.client
.encryption
?.keyManager
.enabled ==
true)
? L10n.of(context)!.unlockOldMessages
: L10n.of(context)!.enableAutoBackups,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
),
),
trailing: const Icon(Icons.chevron_right_outlined),
onTap: widget.controller.firstRunBootstrapAction,
),
),
),
AnimatedContainer(
height: widget.controller.isTorBrowser ? 64 : 0,
duration: const Duration(milliseconds: 300),