feat: Archive with clean up
This commit is contained in:
parent
543f437e7c
commit
ccf6d620db
3 changed files with 75 additions and 28 deletions
|
|
@ -1,7 +1,10 @@
|
|||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/views/ui/archive_ui.dart';
|
||||
import 'package:fluffychat/views/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
class Archive extends StatefulWidget {
|
||||
@override
|
||||
|
|
@ -18,6 +21,31 @@ class ArchiveController extends State<Archive> {
|
|||
|
||||
void forgetAction(int i) => setState(() => archive.removeAt(i));
|
||||
|
||||
void forgetAllAction() async {
|
||||
if (await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context).areYouSure,
|
||||
okLabel: L10n.of(context).yes,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
message: L10n.of(context).clearArchive,
|
||||
useRootNavigator: false,
|
||||
) !=
|
||||
OkCancelResult.ok) {
|
||||
return;
|
||||
}
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
while (archive.isNotEmpty) {
|
||||
Logs().v('Forget room ${archive.last.displayname}');
|
||||
await archive.last.forget();
|
||||
archive.removeLast();
|
||||
}
|
||||
},
|
||||
);
|
||||
setState(() => null);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ArchiveUI(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue