mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 07:35:13 +00:00
fix: Remove failed to sent events
This commit is contained in:
parent
e70ff68c48
commit
9f0bcd5523
3 changed files with 61 additions and 23 deletions
|
@ -772,6 +772,24 @@ class ChatController extends State<ChatPageWithRoom> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void deleteErrorEventsAction() async {
|
||||||
|
try {
|
||||||
|
if (selectedEvents.any((event) => event.status != EventStatus.error)) {
|
||||||
|
throw Exception(
|
||||||
|
'Tried to delete failed to send events but one event is not failed to sent',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
for (final event in selectedEvents) {
|
||||||
|
await event.remove();
|
||||||
|
}
|
||||||
|
} catch (e, s) {
|
||||||
|
ErrorReporter(
|
||||||
|
context,
|
||||||
|
'Error while delete error events action',
|
||||||
|
).onErrorCallback(e, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void redactEventsAction() async {
|
void redactEventsAction() async {
|
||||||
final reasonInput = selectedEvents.any((event) => event.status.isSent)
|
final reasonInput = selectedEvents.any((event) => event.status.isSent)
|
||||||
? await showTextInputDialog(
|
? await showTextInputDialog(
|
||||||
|
@ -832,6 +850,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
||||||
if (isArchived) return false;
|
if (isArchived) return false;
|
||||||
final clients = Matrix.of(context).currentBundle;
|
final clients = Matrix.of(context).currentBundle;
|
||||||
for (final event in selectedEvents) {
|
for (final event in selectedEvents) {
|
||||||
|
if (!event.status.isSent) return false;
|
||||||
if (event.canRedact == false &&
|
if (event.canRedact == false &&
|
||||||
!(clients!.any((cl) => event.senderId == cl!.userID))) return false;
|
!(clients!.any((cl) => event.senderId == cl!.userID))) return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,24 @@ class ChatInputRow extends StatelessWidget {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: controller.selectMode
|
children: controller.selectMode
|
||||||
? <Widget>[
|
? <Widget>[
|
||||||
|
if (controller.selectedEvents
|
||||||
|
.every((event) => event.status == EventStatus.error))
|
||||||
|
SizedBox(
|
||||||
|
height: 56,
|
||||||
|
child: TextButton(
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor: Theme.of(context).colorScheme.error,
|
||||||
|
),
|
||||||
|
onPressed: controller.deleteErrorEventsAction,
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
const Icon(Icons.delete),
|
||||||
|
Text(L10n.of(context)!.delete),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 56,
|
height: 56,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
|
|
|
@ -91,6 +91,7 @@ class ChatView extends StatelessWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (controller.selectedEvents.single.status.isSent)
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
value: _EventContextAction.report,
|
value: _EventContextAction.report,
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|
Loading…
Reference in a new issue