Add unit tests for ChannelMessage replies and update untranslated.json with new translations

This commit is contained in:
zjs81 committed 2026-09-25 13:23:07 -07:00
1 parent c1680208d8
commit 0e8a8bd8c4
61 files changed
+9701 -1140

No files matched your search

+16
View File
@@ -105,6 +105,10 @@ class AppSettingsService extends ChangeNotifier {
await updateSettings(_settings.copyWith(mapShowGuessedLocations: value));
}
Future<void> setMapClusterNodes(bool value) async {
await updateSettings(_settings.copyWith(mapClusterNodes: value));
}
Future<void> setEnableMessageTracing(bool value) async {
await updateSettings(_settings.copyWith(enableMessageTracing: value));
}
@@ -206,6 +210,18 @@ class AppSettingsService extends ChangeNotifier {
await updateSettings(_settings.copyWith(maxMessageRetries: value));
}
Future<void> setChannelMinHopsEnabled(bool value) async {
await updateSettings(_settings.copyWith(channelMinHopsEnabled: value));
}
Future<void> setChannelMinHops(int value) async {
await updateSettings(_settings.copyWith(channelMinHops: value));
}
Future<void> setChannelMinHopsRetries(int value) async {
await updateSettings(_settings.copyWith(channelMinHopsRetries: value));
}
Future<void> setThemeMode(String value) async {
await updateSettings(_settings.copyWith(themeMode: value));
}
+5
View File
@@ -70,6 +70,11 @@ class BackgroundService {
return AppLocalizations.delegate.load(match);
}
static Future<void> openBatteryOptimizationSettings() async {
if (!PlatformInfo.isAndroid) return;
await FlutterForegroundTask.openIgnoreBatteryOptimizationSettings();
}
Future<void> stop() async {
if (!PlatformInfo.isAndroid) return;
final running = await FlutterForegroundTask.isRunningService;
+11
View File
@@ -984,6 +984,17 @@ class ImageCodecService extends ChangeNotifier implements ImageSendCodec {
return bitstream;
}
@override
Future<Uint8List?> decodePreview(Uint8List payload) async {
if (!canDecode) return null;
final result = await decodeBitstream(
bitstream: payload,
ratePoint: aeicRatePointForUi(kImageSendRatePoint),
resolution: kImageCodecSquareSize,
);
return result?.pngBytes;
}
/// Encodes an already-decoded RGB image.
///
/// [rgbBytes] must be exactly `512 * 512 * 3` packed 8-bit RGB. Anything else
+24 -8
View File
@@ -8,6 +8,7 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import '../helpers/message_url_image_helper.dart';
import '../helpers/reaction_helper.dart';
import '../l10n/app_localizations.dart';
import '../storage/prefs_manager.dart';
import '../utils/platform_info.dart';
class NotificationService {
@@ -123,9 +124,11 @@ class NotificationService {
// Cached "are we allowed to post notifications" result. Null = not yet
// determined. Avoids calling _notifications.show() when it would only throw
// "You must request notifications permissions first" (every web build, and
// Android 13+ before the user grants the permission).
// "You must request notifications permissions first" (every web build).
// Android denials are never cached so a later grant in system settings is
// picked up without restarting the app.
bool? _canNotify;
static const _permissionRequestedKey = 'notification_permission_requested';
Future<bool> _ensureCanNotify() async {
if (!await _ensureInitialized()) return false;
@@ -143,8 +146,9 @@ class NotificationService {
AndroidFlutterLocalNotificationsPlugin
>();
if (androidPlugin != null) {
final enabled = await androidPlugin.areNotificationsEnabled();
return _canNotify = enabled ?? false;
final enabled = await androidPlugin.areNotificationsEnabled() ?? false;
if (enabled) _canNotify = true;
return enabled;
}
// iOS/macOS request permission during initialize(); desktop has no gate.
@@ -163,8 +167,8 @@ class NotificationService {
>();
if (androidPlugin != null) {
final granted = await androidPlugin.requestNotificationsPermission();
_canNotify = granted ?? false;
return _canNotify!;
if (granted == true) _canNotify = true;
return granted ?? false;
}
// iOS permissions are requested during initialization
@@ -178,13 +182,25 @@ class NotificationService {
badge: true,
sound: true,
);
_canNotify = granted ?? false;
return _canNotify!;
if (granted == true) _canNotify = true;
return granted ?? false;
}
return true;
}
/// Asks for the Android 13+ notification permission the first time it is
/// needed. Never re-prompts after the user has answered once; iOS/macOS
/// already prompt during [initialize].
Future<void> requestPermissionsOnce() async {
if (!PlatformInfo.isAndroid || !await _ensureInitialized()) return;
final prefs = PrefsManager.instance;
if (prefs.getBool(_permissionRequestedKey) ?? false) return;
if (await _ensureCanNotify()) return;
await prefs.setBool(_permissionRequestedKey, true);
await requestPermissions();
}
/// Format special message types for human-readable notifications.
static String formatNotificationText(String text) {
final trimmed = text.trim();
+18
View File
@@ -366,6 +366,24 @@ class PathHistoryService extends ChangeNotifier {
notifyListeners();
}
/// Whether this contact's history is in the in-memory cache.
bool isCached(String contactPubKeyHex) =>
_cache.containsKey(contactPubKeyHex);
/// Paths already in memory, without loading from storage or changing the
/// cache order. For bulk readers that must not churn the 50-contact cache.
List<PathRecord> peekRecentPaths(String contactPubKeyHex) =>
_cache[contactPubKeyHex]?.recentPaths ?? const [];
/// Reads saved paths straight from storage without adding them to the
/// cache, evicting anything, or notifying listeners.
Future<List<PathRecord>> readStoredPaths(String contactPubKeyHex) async {
final cached = _cache[contactPubKeyHex];
if (cached != null) return cached.recentPaths;
final stored = await _loadHistoryFromStorage(contactPubKeyHex);
return stored?.recentPaths ?? const [];
}
List<PathRecord> getRecentPaths(String contactPubKeyHex) {
final history = _cache[contactPubKeyHex];
if (history != null) {