mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 08:20:36 +00:00
Add retry for failed media packets
This commit is contained in:
@@ -457,6 +457,7 @@ class _MessagesTabState extends State<MessagesTab> {
|
||||
grayscale: grayscale,
|
||||
);
|
||||
if (result == null) {
|
||||
if (!mounted) return;
|
||||
ToastLogger.error(context, 'Image compression failed');
|
||||
return;
|
||||
}
|
||||
@@ -487,6 +488,7 @@ class _MessagesTabState extends State<MessagesTab> {
|
||||
);
|
||||
|
||||
if (fragments.isEmpty) {
|
||||
if (!mounted) return;
|
||||
ToastLogger.error(context, 'Image fragmentation failed');
|
||||
return;
|
||||
}
|
||||
@@ -494,6 +496,7 @@ class _MessagesTabState extends State<MessagesTab> {
|
||||
// Build envelope.
|
||||
final deviceKey = connectionProvider.deviceInfo.publicKey;
|
||||
if (deviceKey == null || deviceKey.length < 6) {
|
||||
if (!mounted) return;
|
||||
ToastLogger.error(context, 'Device key unavailable');
|
||||
return;
|
||||
}
|
||||
@@ -513,6 +516,8 @@ class _MessagesTabState extends State<MessagesTab> {
|
||||
timestampSec: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
);
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
// Cache for deferred serving.
|
||||
final imageProvider = context.read<ip.ImageProvider>();
|
||||
imageProvider.cacheOutgoingSession(sessionId, fragments, envelope);
|
||||
@@ -555,6 +560,7 @@ class _MessagesTabState extends State<MessagesTab> {
|
||||
);
|
||||
if (!sent) {
|
||||
messagesProvider.markMessageFailed(msgId);
|
||||
if (!mounted) return;
|
||||
ToastLogger.error(context, 'Failed to announce image');
|
||||
}
|
||||
}
|
||||
@@ -566,6 +572,7 @@ class _MessagesTabState extends State<MessagesTab> {
|
||||
);
|
||||
} catch (e, st) {
|
||||
debugPrint('❌ [Image] _pickAndSendImage: $e\n$st');
|
||||
if (!mounted) return;
|
||||
ToastLogger.error(context, 'Image send failed');
|
||||
} finally {
|
||||
if (mounted) setState(() => _isSendingImage = false);
|
||||
|
||||
@@ -1206,24 +1206,26 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Max image size'),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: ImagePreferences.supportedSizes
|
||||
.map(
|
||||
(size) => RadioListTile<int>(
|
||||
value: size,
|
||||
groupValue: _imageMaxSize,
|
||||
title: Text('${size}×$size px'),
|
||||
subtitle: size == ImagePreferences.defaultMaxSize
|
||||
? const Text('Default')
|
||||
: null,
|
||||
onChanged: (value) {
|
||||
if (value != null) _saveImageMaxSize(value);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
child: RadioGroup<int>(
|
||||
groupValue: _imageMaxSize,
|
||||
onChanged: (value) {
|
||||
if (value != null) _saveImageMaxSize(value);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: ImagePreferences.supportedSizes
|
||||
.map(
|
||||
(size) => RadioListTile<int>(
|
||||
value: size,
|
||||
title: Text('$size×$size px'),
|
||||
subtitle: size == ImagePreferences.defaultMaxSize
|
||||
? const Text('Default')
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
|
||||
Reference in New Issue
Block a user