mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-11 19:17:04 +10:00
only take translated result if status==completed
This commit is contained in:
@@ -4423,9 +4423,13 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
final msg = message;
|
final msg = message;
|
||||||
if (contact?.type == advTypeChat) {
|
if (contact?.type == advTypeChat) {
|
||||||
unawaited(() async {
|
unawaited(() async {
|
||||||
final resolvedText = translationResult != null
|
final resolvedText =
|
||||||
|
(translationResult != null &&
|
||||||
|
translationResult.status ==
|
||||||
|
MessageTranslationStatus.completed &&
|
||||||
|
translationResult.translatedText.trim().isNotEmpty)
|
||||||
? translationResult.translatedText.trim()
|
? translationResult.translatedText.trim()
|
||||||
: msg.text;
|
: msg.text.trim();
|
||||||
await _notificationService.showMessageNotification(
|
await _notificationService.showMessageNotification(
|
||||||
contactName: contact?.name ?? 'Unknown',
|
contactName: contact?.name ?? 'Unknown',
|
||||||
message: resolvedText,
|
message: resolvedText,
|
||||||
@@ -4439,9 +4443,13 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
? msg.text.substring(4)
|
? msg.text.substring(4)
|
||||||
: msg.text;
|
: msg.text;
|
||||||
unawaited(() async {
|
unawaited(() async {
|
||||||
final resolvedText = translationResult != null
|
final resolvedText =
|
||||||
|
(translationResult != null &&
|
||||||
|
translationResult.status ==
|
||||||
|
MessageTranslationStatus.completed &&
|
||||||
|
translationResult.translatedText.trim().isNotEmpty)
|
||||||
? translationResult.translatedText.trim()
|
? translationResult.translatedText.trim()
|
||||||
: bodyText;
|
: bodyText.trim();
|
||||||
await _notificationService.showMessageNotification(
|
await _notificationService.showMessageNotification(
|
||||||
contactName: contact?.name ?? 'Unknown Room',
|
contactName: contact?.name ?? 'Unknown Room',
|
||||||
message: resolvedText,
|
message: resolvedText,
|
||||||
@@ -4731,10 +4739,13 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
final label = channelName ?? _channelDisplayName(channelIndex);
|
final label = channelName ?? _channelDisplayName(channelIndex);
|
||||||
if (_appSettingsService!.isChannelMuted(label)) return;
|
if (_appSettingsService!.isChannelMuted(label)) return;
|
||||||
|
|
||||||
// Reuse translation result from earlier translation, or use original text
|
// Reuse translation result only if completed and non-empty; else use original text
|
||||||
final resolvedText = translationResult != null
|
final resolvedText =
|
||||||
|
(translationResult != null &&
|
||||||
|
translationResult.status == MessageTranslationStatus.completed &&
|
||||||
|
translationResult.translatedText.trim().isNotEmpty)
|
||||||
? translationResult.translatedText.trim()
|
? translationResult.translatedText.trim()
|
||||||
: message.text;
|
: message.text.trim();
|
||||||
unawaited(() async {
|
unawaited(() async {
|
||||||
await _notificationService.showChannelMessageNotification(
|
await _notificationService.showChannelMessageNotification(
|
||||||
channelName: label,
|
channelName: label,
|
||||||
|
|||||||
Reference in New Issue
Block a user