mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
Limit media fetch hops to three
This commit is contained in:
@@ -436,6 +436,7 @@ class _MessagesTabState extends State<MessagesTab> {
|
|||||||
if (_isSendingImage) return;
|
if (_isSendingImage) return;
|
||||||
final shouldContinue = await _confirmPublicChannelMediaSend('image');
|
final shouldContinue = await _confirmPublicChannelMediaSend('image');
|
||||||
if (!shouldContinue) return;
|
if (!shouldContinue) return;
|
||||||
|
if (!mounted) return;
|
||||||
final connectionProvider = context.read<ConnectionProvider>();
|
final connectionProvider = context.read<ConnectionProvider>();
|
||||||
if (!connectionProvider.deviceInfo.isConnected) {
|
if (!connectionProvider.deviceInfo.isConnected) {
|
||||||
ToastLogger.error(context, 'Not connected to device');
|
ToastLogger.error(context, 'Not connected to device');
|
||||||
@@ -537,7 +538,9 @@ class _MessagesTabState extends State<MessagesTab> {
|
|||||||
final isChannel =
|
final isChannel =
|
||||||
_destinationType ==
|
_destinationType ==
|
||||||
MessageDestinationPreferences.destinationTypeChannel;
|
MessageDestinationPreferences.destinationTypeChannel;
|
||||||
final channelIdx = isChannel ? (_selectedRecipient?.publicKey[1] ?? 0) : null;
|
final channelIdx = isChannel
|
||||||
|
? (_selectedRecipient?.publicKey[1] ?? 0)
|
||||||
|
: null;
|
||||||
final recipient = _selectedRecipient;
|
final recipient = _selectedRecipient;
|
||||||
final placeholder = Message(
|
final placeholder = Message(
|
||||||
id: msgId,
|
id: msgId,
|
||||||
@@ -600,7 +603,7 @@ class _MessagesTabState extends State<MessagesTab> {
|
|||||||
requester: recipient,
|
requester: recipient,
|
||||||
);
|
);
|
||||||
debugPrint(
|
debugPrint(
|
||||||
'📷 [Image] Pushed ${ served ? fragments.length : 0} '
|
'📷 [Image] Pushed ${served ? fragments.length : 0} '
|
||||||
'fragments to ${recipient.advName}',
|
'fragments to ${recipient.advName}',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -740,6 +743,17 @@ class _MessagesTabState extends State<MessagesTab> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final shouldContinue = await _confirmPublicChannelMediaSend('voice');
|
||||||
|
if (!shouldContinue) {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
_isSendingVoice = false;
|
||||||
|
_currentVoiceSessionId = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await _encodeAndSendAllPackets(
|
await _encodeAndSendAllPackets(
|
||||||
chunks: chunks,
|
chunks: chunks,
|
||||||
@@ -940,6 +954,43 @@ class _MessagesTabState extends State<MessagesTab> {
|
|||||||
return rms < _silenceRmsThreshold && peak < _silencePeakThreshold;
|
return rms < _silenceRmsThreshold && peak < _silencePeakThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _isPublicChannelSelected() {
|
||||||
|
if (_destinationType !=
|
||||||
|
MessageDestinationPreferences.destinationTypeChannel) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final channelIdx = _selectedRecipient?.publicKey[1] ?? 0;
|
||||||
|
return channelIdx == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _confirmPublicChannelMediaSend(String mediaType) async {
|
||||||
|
if (!_isPublicChannelSelected() || !mounted) return true;
|
||||||
|
|
||||||
|
final decision = await showDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (dialogContext) => AlertDialog(
|
||||||
|
title: const Text('Send to Public Channel?'),
|
||||||
|
content: Text(
|
||||||
|
'You are about to send $mediaType to the Public Channel. '
|
||||||
|
'This is not advised because everyone on the mesh may receive it. '
|
||||||
|
'Choose a private or tagged channel unless this is what you want.',
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(dialogContext).pop(false),
|
||||||
|
child: const Text('Cancel'),
|
||||||
|
),
|
||||||
|
FilledButton(
|
||||||
|
onPressed: () => Navigator.of(dialogContext).pop(true),
|
||||||
|
child: const Text('Send anyway'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return decision ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
// ── SAR dialog ─────────────────────────────────────────────────────────────
|
// ── SAR dialog ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
void _showSarDialog() {
|
void _showSarDialog() {
|
||||||
|
|||||||
Reference in New Issue
Block a user