mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-14 22:55:12 +10:00
add toggle for autmatically translated messages for notification and chat or manual translation on message action. Due to heavy battery usage.
This commit is contained in:
@@ -235,6 +235,12 @@ class AppSettingsService extends ChangeNotifier {
|
||||
await updateSettings(_settings.copyWith(translationEnabled: value));
|
||||
}
|
||||
|
||||
Future<void> setAutoTranslateIncomingMessages(bool value) async {
|
||||
await updateSettings(
|
||||
_settings.copyWith(autoTranslateIncomingMessages: value),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> setTranslationTargetLanguageCode(String? value) async {
|
||||
await updateSettings(
|
||||
_settings.copyWith(translationTargetLanguageCode: value),
|
||||
|
||||
@@ -89,7 +89,22 @@ class TranslationService extends ChangeNotifier {
|
||||
'en';
|
||||
}
|
||||
|
||||
bool shouldTranslateIncoming({
|
||||
bool shouldAutoTranslateIncoming({
|
||||
required String text,
|
||||
required bool isCli,
|
||||
required bool isOutgoing,
|
||||
}) {
|
||||
if (!_settings.autoTranslateIncomingMessages) {
|
||||
return false;
|
||||
}
|
||||
return canTranslateIncoming(
|
||||
text: text,
|
||||
isCli: isCli,
|
||||
isOutgoing: isOutgoing,
|
||||
);
|
||||
}
|
||||
|
||||
bool canTranslateIncoming({
|
||||
required String text,
|
||||
required bool isCli,
|
||||
required bool isOutgoing,
|
||||
|
||||
Reference in New Issue
Block a user