@@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
5
5
import 'package:flutter_gen/gen_l10n/zulip_localizations.dart' ;
6
6
import 'package:image_picker/image_picker.dart' ;
7
7
8
+ import '../api/exception.dart' ;
8
9
import '../api/model/model.dart' ;
9
10
import '../api/route/messages.dart' ;
10
11
import '../model/compose.dart' ;
@@ -716,7 +717,7 @@ class _SendButtonState extends State<_SendButton> {
716
717
|| widget.contentController.hasValidationErrors.value;
717
718
}
718
719
719
- void _send () {
720
+ void _send () async {
720
721
if (_hasValidationErrors) {
721
722
final zulipLocalizations = ZulipLocalizations .of (context);
722
723
List <String > validationErrorMessages = [
@@ -735,9 +736,26 @@ class _SendButtonState extends State<_SendButton> {
735
736
736
737
final store = PerAccountStoreWidget .of (context);
737
738
final content = widget.contentController.textNormalized;
738
- store.sendMessage (destination: widget.getDestination (), content: content);
739
739
740
740
widget.contentController.clear ();
741
+
742
+ try {
743
+ // TODO(#720) await send request, putting input(s) and send button into a
744
+ // disabled "working on it" state (allowing input text to be selected
745
+ // for copying).
746
+ await store.sendMessage (destination: widget.getDestination (), content: content);
747
+ } on ApiRequestException catch (e) {
748
+ if (! mounted) return ;
749
+ final zulipLocalizations = ZulipLocalizations .of (context);
750
+ final message = switch (e) {
751
+ ZulipApiException () => zulipLocalizations.errorServerMessage (e.message),
752
+ _ => e.message,
753
+ };
754
+ showErrorDialog (context: context,
755
+ title: zulipLocalizations.errorMessageNotSent,
756
+ message: message);
757
+ return ;
758
+ }
741
759
}
742
760
743
761
@override
0 commit comments