Files
buzz/mobile/lib/features/channels/compose_bar/send_button.dart
Tom Brow d29c679066 fix(mobile): keep error names in send, upload and invite failure text (#9855)
## Summary

The compose bar's send error, the upload error and the invite page's
error removed the first `Exception: ` anywhere in an error's text, not
just a leading one. A `TimeoutException` read "Timeout..." and a wrapped
error lost part of its text.

They now share the helper Add Members already uses: only a plain
`Exception`'s leading prefix is removed, a relay rejection shows its
message verbatim, a lost acknowledgement drops the prefix only from its
cause, and named types such as `TimeoutException` keep their whole name.
The helper moves to `shared/relay/relay_error_text.dart`; Add Members
behaves as before.

## Validation

- New `relay_error_text_test.dart` covers a plain `Exception`, a
`TimeoutException`, a named error whose message contains `Exception: `,
a relay rejection and a lost acknowledgement. The `TimeoutException` and
named-error rows fail with the old `replaceFirst`.

No screenshots: the change only affects text after a failed send, upload
or invite, which can't be triggered on demand against a real relay.

Full-app run on an iOS simulator (signed in, healthy relay): cold start
and session restore, channel list, opening a channel, sending a message,
the attachment button, Settings, and background then foreground. All
passed with no new errors in the device log. The invite page isn't
offered to the test account.

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-22 08:00:17 -08:00

50 lines
1.3 KiB
Dart

part of '../compose_bar.dart';
class _SendButton extends StatelessWidget {
final bool isSending;
final bool isDisabled;
final VoidCallback onTap;
static const size = 36.0;
const _SendButton({
required this.isSending,
required this.onTap,
this.isDisabled = false,
});
@override
Widget build(BuildContext context) {
return SizedBox(
width: size,
height: size,
child: IconButton(
tooltip: 'Send',
onPressed: (isSending || isDisabled)
? null
: () => _runComposerAction(onTap),
style: IconButton.styleFrom(
backgroundColor: context.colors.primary,
disabledBackgroundColor: context.colors.primary.withValues(
alpha: 0.5,
),
shape: const CircleBorder(),
),
padding: EdgeInsets.zero,
icon: isSending
? BuzzLoadingIndicator(
size: 18,
color: context.colors.onPrimary,
semanticLabel: 'Sending message',
)
: Icon(
BuzzIcons.arrowUp,
size: 18,
color: context.colors.onPrimary,
),
),
);
}
}
String _formatUploadError(Object error) => relayErrorText(error);