From 1fbe1823cbb60953a74a37253ecee797db8f2c1c Mon Sep 17 00:00:00 2001 From: ericz Date: Wed, 13 May 2026 18:06:26 +0200 Subject: [PATCH] only take translated result if status==completed --- lib/connector/meshcore_connector.dart | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 1f422b88..a3dc4650 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -4423,9 +4423,13 @@ class MeshCoreConnector extends ChangeNotifier { final msg = message; if (contact?.type == advTypeChat) { unawaited(() async { - final resolvedText = translationResult != null + final resolvedText = + (translationResult != null && + translationResult.status == + MessageTranslationStatus.completed && + translationResult.translatedText.trim().isNotEmpty) ? translationResult.translatedText.trim() - : msg.text; + : msg.text.trim(); await _notificationService.showMessageNotification( contactName: contact?.name ?? 'Unknown', message: resolvedText, @@ -4439,9 +4443,13 @@ class MeshCoreConnector extends ChangeNotifier { ? msg.text.substring(4) : msg.text; unawaited(() async { - final resolvedText = translationResult != null + final resolvedText = + (translationResult != null && + translationResult.status == + MessageTranslationStatus.completed && + translationResult.translatedText.trim().isNotEmpty) ? translationResult.translatedText.trim() - : bodyText; + : bodyText.trim(); await _notificationService.showMessageNotification( contactName: contact?.name ?? 'Unknown Room', message: resolvedText, @@ -4731,10 +4739,13 @@ class MeshCoreConnector extends ChangeNotifier { final label = channelName ?? _channelDisplayName(channelIndex); if (_appSettingsService!.isChannelMuted(label)) return; - // Reuse translation result from earlier translation, or use original text - final resolvedText = translationResult != null + // Reuse translation result only if completed and non-empty; else use original text + final resolvedText = + (translationResult != null && + translationResult.status == MessageTranslationStatus.completed && + translationResult.translatedText.trim().isNotEmpty) ? translationResult.translatedText.trim() - : message.text; + : message.text.trim(); unawaited(() async { await _notificationService.showChannelMessageNotification( channelName: label,