mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 06:25:15 +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,18 +30,36 @@ class ChatInputRow extends StatelessWidget {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: controller.selectMode
|
children: controller.selectMode
|
||||||
? <Widget>[
|
? <Widget>[
|
||||||
SizedBox(
|
if (controller.selectedEvents
|
||||||
height: 56,
|
.every((event) => event.status == EventStatus.error))
|
||||||
child: TextButton(
|
SizedBox(
|
||||||
onPressed: controller.forwardEventsAction,
|
height: 56,
|
||||||
child: Row(
|
child: TextButton(
|
||||||
children: <Widget>[
|
style: TextButton.styleFrom(
|
||||||
const Icon(Icons.keyboard_arrow_left_outlined),
|
foregroundColor: Theme.of(context).colorScheme.error,
|
||||||
Text(L10n.of(context)!.forward),
|
),
|
||||||
],
|
onPressed: controller.deleteErrorEventsAction,
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
const Icon(Icons.delete),
|
||||||
|
Text(L10n.of(context)!.delete),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
SizedBox(
|
||||||
|
height: 56,
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: controller.forwardEventsAction,
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
const Icon(Icons.keyboard_arrow_left_outlined),
|
||||||
|
Text(L10n.of(context)!.forward),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
controller.selectedEvents.length == 1
|
controller.selectedEvents.length == 1
|
||||||
? controller.selectedEvents.first
|
? controller.selectedEvents.first
|
||||||
.getDisplayEvent(controller.timeline!)
|
.getDisplayEvent(controller.timeline!)
|
||||||
|
|
|
@ -91,20 +91,21 @@ class ChatView extends StatelessWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
if (controller.selectedEvents.single.status.isSent)
|
||||||
value: _EventContextAction.report,
|
PopupMenuItem(
|
||||||
child: Row(
|
value: _EventContextAction.report,
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Row(
|
||||||
children: [
|
mainAxisSize: MainAxisSize.min,
|
||||||
const Icon(
|
children: [
|
||||||
Icons.shield_outlined,
|
const Icon(
|
||||||
color: Colors.red,
|
Icons.shield_outlined,
|
||||||
),
|
color: Colors.red,
|
||||||
const SizedBox(width: 12),
|
),
|
||||||
Text(L10n.of(context)!.reportMessage),
|
const SizedBox(width: 12),
|
||||||
],
|
Text(L10n.of(context)!.reportMessage),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue