fix(ui): Message retraction

This commit is contained in:
PapaTutuWawa 2023-02-19 20:20:06 +01:00
parent 76041671eb
commit 55113543dd
4 changed files with 12 additions and 21 deletions

View File

@ -42,7 +42,6 @@ class ConversationBloc extends Bloc<ConversationEvent, ConversationState> {
on<ImagePickerRequestedEvent>(_onImagePickerRequested); on<ImagePickerRequestedEvent>(_onImagePickerRequested);
on<FilePickerRequestedEvent>(_onFilePickerRequested); on<FilePickerRequestedEvent>(_onFilePickerRequested);
on<OmemoSetEvent>(_onOmemoSet); on<OmemoSetEvent>(_onOmemoSet);
on<MessageRetractedEvent>(_onMessageRetracted);
on<SendButtonDragStartedEvent>(_onDragStarted); on<SendButtonDragStartedEvent>(_onDragStarted);
on<SendButtonDragEndedEvent>(_onDragEnded); on<SendButtonDragEndedEvent>(_onDragEnded);
on<SendButtonLockedEvent>(_onSendButtonLocked); on<SendButtonLockedEvent>(_onSendButtonLocked);
@ -213,16 +212,6 @@ class ConversationBloc extends Bloc<ConversationEvent, ConversationState> {
); );
} }
Future<void> _onMessageRetracted(MessageRetractedEvent event, Emitter<ConversationState> emit) async {
await MoxplatformPlugin.handler.getDataSender().sendData(
RetractMessageCommentCommand(
originId: event.id,
conversationJid: state.conversation!.jid,
),
awaitable: false,
);
}
Future<void> _onDragStarted(SendButtonDragStartedEvent event, Emitter<ConversationState> emit) async { Future<void> _onDragStarted(SendButtonDragStartedEvent event, Emitter<ConversationState> emit) async {
final status = await Permission.speech.status; final status = await Permission.speech.status;
if (status.isDenied) { if (status.isDenied) {

View File

@ -71,12 +71,6 @@ class OmemoSetEvent extends ConversationEvent {
final bool enabled; final bool enabled;
} }
/// Triggered when a message should be retracted
class MessageRetractedEvent extends ConversationEvent {
MessageRetractedEvent(this.id);
final String id;
}
/// Triggered when the dragging began /// Triggered when the dragging began
class SendButtonDragStartedEvent extends ConversationEvent {} class SendButtonDragStartedEvent extends ConversationEvent {}

View File

@ -287,6 +287,17 @@ class BidirectionalConversationController {
} }
} }
/// Retract the message with originId [originId].
void retractMessage(String originId) {
MoxplatformPlugin.handler.getDataSender().sendData(
RetractMessageCommentCommand(
originId: originId,
conversationJid: conversationJid,
),
awaitable: false,
);
}
Future<void> sendMessage(bool encrypted) async { Future<void> sendMessage(bool encrypted) async {
// Stop the compose timer // Stop the compose timer
_stopComposeTimer(); _stopComposeTimer();

View File

@ -111,10 +111,7 @@ class ConversationPageState extends State<ConversationPage> with TickerProviderS
); );
if (result) { if (result) {
// ignore: use_build_context_synchronously _conversationController.retractMessage(originId);
context.read<ConversationBloc>().add(
MessageRetractedEvent(originId),
);
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
Navigator.of(context).pop(); Navigator.of(context).pop();