Add Contact and Channelsettings to explicitly enable Picture preview.

This commit is contained in:
ericz committed 2026-08-10 22:21:10 +02:00
1 parent b137dd8fe1
commit d920449cbb
31 files changed
+421 -56

No files matched your search

+45
View File
@@ -356,12 +356,14 @@ class MeshCoreConnector extends ChangeNotifier {
List<Channel> _cachedChannels = [];
final Map<int, bool> _channelSmazEnabled = {};
final Map<int, bool> _channelCyr2LatEnabled = {};
final Map<int, bool> _channelImagesEnabled = {};
final Map<int, String?> _channelCyr2LatProfileId = {};
final Map<int, Region> _channelRegions = {};
bool _lastSentWasCliCommand =
false; // Track if last sent message was a CLI command
final Map<String, bool> _contactSmazEnabled = {};
final Map<String, bool> _contactCyr2LatEnabled = {};
final Map<String, bool> _contactImagesEnabled = {};
final Map<String, String?> _contactCyr2LatProfileId = {};
final Set<String> _knownContactKeys = {};
final Map<String, int> _contactUnreadCount = {};
@@ -756,6 +758,15 @@ class MeshCoreConnector extends ChangeNotifier {
return _contactSmazEnabled[contactKeyHex] ?? false;
}
bool isChannelImagesEnabled(int channelIndex) {
return _channelImagesEnabled[channelIndex] ?? false;
}
bool isContactImagesEnabled(String contactKeyHex) {
_ensureContactImagesSettingLoaded(contactKeyHex);
return _contactImagesEnabled[contactKeyHex] ?? false;
}
bool hasChannelRegion(int channelIndex) {
return (_channelRegions[channelIndex] ?? '').isNotEmpty;
}
@@ -898,6 +909,21 @@ class MeshCoreConnector extends ChangeNotifier {
notifyListeners();
}
Future<void> setChannelImagesEnabled(int channelIndex, bool enabled) async {
_channelImagesEnabled[channelIndex] = enabled;
await _channelSettingsStore.saveImagesEnabled(channelIndex, enabled);
notifyListeners();
}
Future<void> setContactImagesEnabled(
String contactKeyHex,
bool enabled,
) async {
_contactImagesEnabled[contactKeyHex] = enabled;
await _contactSettingsStore.saveImagesEnabled(contactKeyHex, enabled);
notifyListeners();
}
Future<void> setChannelCyr2LatEnabled(int channelIndex, bool enabled) async {
_channelCyr2LatEnabled[channelIndex] = enabled;
if (enabled) {
@@ -1070,6 +1096,7 @@ class MeshCoreConnector extends ChangeNotifier {
for (final contact in cached) {
_ensureContactSmazSettingLoaded(contact.publicKeyHex);
_ensureContactCyr2LatSettingLoaded(contact.publicKeyHex);
_ensureContactImagesSettingLoaded(contact.publicKeyHex);
}
}
@@ -1090,12 +1117,16 @@ class MeshCoreConnector extends ChangeNotifier {
Future<void> loadChannelSettings({int? maxChannels}) async {
_channelSmazEnabled.clear();
_channelCyr2LatEnabled.clear();
_channelImagesEnabled.clear();
_channelRegions.clear();
final channelCount = maxChannels ?? _maxChannels;
for (int i = 0; i < channelCount; i++) {
_channelSmazEnabled[i] = await _channelSettingsStore.loadSmazEnabled(i);
_channelCyr2LatEnabled[i] = await _channelSettingsStore
.loadCyr2LatEnabled(i);
_channelImagesEnabled[i] = await _channelSettingsStore.loadImagesEnabled(
i,
);
_channelRegions[i] = await _channelRegionStore.loadRegion(i);
}
}
@@ -5151,6 +5182,8 @@ class MeshCoreConnector extends ChangeNotifier {
await _notificationService.showMessageNotification(
contactName: c?.name ?? 'Unknown',
message: resolvedText,
imagesEnabled:
c != null && isContactImagesEnabled(c.publicKeyHex),
contactId: msg.senderKeyHex,
badgeCount: getTotalUnreadCount(),
);
@@ -5165,6 +5198,8 @@ class MeshCoreConnector extends ChangeNotifier {
await _notificationService.showMessageNotification(
contactName: c?.name ?? 'Unknown Room',
message: resolvedText,
imagesEnabled:
c != null && isContactImagesEnabled(c.publicKeyHex),
contactId: msg.senderKeyHex,
badgeCount: getTotalUnreadCount(),
);
@@ -5315,6 +5350,15 @@ class MeshCoreConnector extends ChangeNotifier {
});
}
void _ensureContactImagesSettingLoaded(String contactKeyHex) {
if (_contactImagesEnabled.containsKey(contactKeyHex)) return;
_contactSettingsStore.loadImagesEnabled(contactKeyHex).then((enabled) {
if (_contactImagesEnabled[contactKeyHex] == enabled) return;
_contactImagesEnabled[contactKeyHex] = enabled;
notifyListeners();
});
}
void _ensureContactCyr2LatProfileLoaded(String contactKeyHex) {
if (_contactCyr2LatProfileId.containsKey(contactKeyHex)) return;
_contactSettingsStore.loadCyr2LatProfileId(contactKeyHex).then((profileId) {
@@ -5469,6 +5513,7 @@ class MeshCoreConnector extends ChangeNotifier {
channelName: label,
senderName: message.senderName,
message: resolvedText,
imagesEnabled: isChannelImagesEnabled(channelIndex),
channelIndex: message.channelIndex,
badgeCount: getTotalUnreadCount(),
);
+10
View File
@@ -33,6 +33,16 @@ class MessageImageHelper {
caseSensitive: false,
);
/// Checks locally whether [text] contains a URL format this helper supports.
/// This deliberately does not resolve sharing pages or fetch image data.
static bool hasPotentialImageUrl(String text) {
return _pyxPattern.hasMatch(text) ||
_ipfsUrlPattern.hasMatch(text) ||
_ipfsCidPattern.hasMatch(text) ||
_ibbSharePattern.hasMatch(text) ||
_imagePattern.hasMatch(text);
}
static Future<String?> parse(String text) async {
final trimmed = text.trim();
if (trimmed.isEmpty) return null;
+2
View File
@@ -2625,6 +2625,8 @@
"messageStatus_pending": "Wird gesendet",
"messageStatus_failed": "Senden fehlgeschlagen",
"messageStatus_repeated": "Mehrfach gehört",
"messageImage_enable": "Erlaube Bilder",
"messageImage_possible": "Mögliches Bild, erlaube in Einstellungen.",
"contacts_moreOptions": "Weitere Optionen",
"contacts_searchOpen": "Suche öffnen",
"contacts_searchClose": "Suche schließen",
+2
View File
@@ -34,6 +34,8 @@
"messageStatus_pending": "Sending",
"messageStatus_failed": "Failed to send",
"messageStatus_repeated": "Heard repeated",
"messageImage_enable": "Enable Images",
"messageImage_possible": "Possible Image, enable in Settings.",
"common_reboot": "Reboot",
"common_loading": "Loading...",
"common_notAvailable": "—",
+12
View File
@@ -334,6 +334,18 @@ abstract class AppLocalizations {
/// **'Heard repeated'**
String get messageStatus_repeated;
/// No description provided for @messageImage_enable.
///
/// In en, this message translates to:
/// **'Enable Images'**
String get messageImage_enable;
/// No description provided for @messageImage_possible.
///
/// In en, this message translates to:
/// **'Possible Image, enable in Settings.'**
String get messageImage_possible;
/// No description provided for @common_reboot.
///
/// In en, this message translates to:
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsBg extends AppLocalizations {
@override
String get messageStatus_repeated => 'Повторно чуто';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Рестартирай';
+7
View File
@@ -110,6 +110,13 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get messageStatus_repeated => 'Mehrfach gehört';
@override
String get messageImage_enable => 'Erlaube Bilder';
@override
String get messageImage_possible =>
'Mögliches Bild, erlaube in Einstellungen.';
@override
String get common_reboot => 'Neustart';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get messageStatus_repeated => 'Heard repeated';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Reboot';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get messageStatus_repeated => 'Escuchado repetidamente';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Reiniciar';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsFr extends AppLocalizations {
@override
String get messageStatus_repeated => 'Reçu plusieurs fois';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Redémarrer';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsHu extends AppLocalizations {
@override
String get messageStatus_repeated => '– ismételte Heard';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Indítsa újra';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsIt extends AppLocalizations {
@override
String get messageStatus_repeated => 'Ricevuto ripetutamente';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Riavvia';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get messageStatus_repeated => '何度も聞いた';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => '再起動';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsKo extends AppLocalizations {
@override
String get messageStatus_repeated => '반복 수신됨';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => '재부팅';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsNl extends AppLocalizations {
@override
String get messageStatus_repeated => 'Hearsay, herhaald';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Herstarten';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsPl extends AppLocalizations {
@override
String get messageStatus_repeated => 'Usłyszałem to wielokrotnie';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Uruchom ponownie';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get messageStatus_repeated => 'Ouvi repetidamente';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Reiniciar';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsRu extends AppLocalizations {
@override
String get messageStatus_repeated => 'Услышал несколько раз';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Перезагрузить';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsSk extends AppLocalizations {
@override
String get messageStatus_repeated => 'Slyšal som to opakovane';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Restartovať';
+6
View File
@@ -111,6 +111,12 @@ class AppLocalizationsSl extends AppLocalizations {
@override
String get messageStatus_repeated => 'Slišal sem večkrat';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Ponoviti';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsSv extends AppLocalizations {
@override
String get messageStatus_repeated => 'Hördes upprepade gånger';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Start om';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsUk extends AppLocalizations {
@override
String get messageStatus_repeated => 'Почув неодноразово';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => 'Перезавантажити';
+6
View File
@@ -110,6 +110,12 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get messageStatus_repeated => '多次听到';
@override
String get messageImage_enable => 'Enable Images';
@override
String get messageImage_possible => 'Possible Image, enable in Settings.';
@override
String get common_reboot => '重启';
+57 -27
View File
@@ -393,6 +393,9 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
// Reverse messages so newest appear at bottom with reverse: true
final reversedMessages = messages.reversed.toList();
final imagesEnabled = connector.isChannelImagesEnabled(
widget.channel.index,
);
final itemCount =
reversedMessages.length + (_isLoadingOlder ? 1 : 0);
@@ -473,6 +476,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
final bubble = _buildMessageBubble(
message,
textScale,
imagesEnabled,
);
if (isUnreadAnchor) {
return Column(
@@ -512,7 +516,11 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
connector.setChannelUnreadCount(widget.channel.index, count);
}
Widget _buildMessageBubble(ChannelMessage message, double textScale) {
Widget _buildMessageBubble(
ChannelMessage message,
double textScale,
bool imagesEnabled,
) {
final settingsService = context.watch<AppSettingsService>();
final enableTracing = settingsService.settings.enableMessageTracing;
final isOutgoing = message.isOutgoing;
@@ -552,6 +560,33 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
final metaColor = textColor.withValues(alpha: 0.65);
const bodyFontSize = 14.0;
Widget buildTextContent() {
return Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Flexible(
child: TranslatedMessageContent(
displayText: translatedDisplayText,
originalText: originalDisplayText,
style: TextStyle(
color: textColor,
fontSize: bodyFontSize * textScale,
),
originalStyle: TextStyle(
fontSize: bodyFontSize * textScale,
fontStyle: FontStyle.italic,
color: textColor.withValues(alpha: 0.72),
),
onSecondaryTap: PlatformInfo.isDesktop
? () => _showMessageActions(message)
: null,
),
),
],
);
}
// Asymmetric radius matching chat_screen bubbles.
final borderRadius = isOutgoing
? const BorderRadius.only(
@@ -657,7 +692,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
),
],
)
else
else if (imagesEnabled)
FutureBuilder<String?>(
future: MessageImageHelper.parseVerified(
message.text,
@@ -702,33 +737,28 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
);
}
return Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Flexible(
child: TranslatedMessageContent(
displayText: translatedDisplayText,
originalText: originalDisplayText,
style: TextStyle(
color: textColor,
fontSize: bodyFontSize * textScale,
),
originalStyle: TextStyle(
fontSize: bodyFontSize * textScale,
fontStyle: FontStyle.italic,
color: textColor.withValues(
alpha: 0.72,
),
),
onSecondaryTap: PlatformInfo.isDesktop
? () => _showMessageActions(message)
: null,
return buildTextContent();
},
)
else
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (MessageImageHelper.hasPotentialImageUrl(
message.text,
))
Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Text(
context.l10n.messageImage_possible,
style: TextStyle(
color: metaColor,
fontSize: 11 * textScale,
),
),
],
);
},
),
buildTextContent(),
],
),
if (enableTracing && displayPath.isNotEmpty) ...[
const SizedBox(height: 3),
+12
View File
@@ -1533,6 +1533,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
final pskController = TextEditingController(text: channel.pskHex);
bool smazEnabled = connector.isChannelSmazEnabled(channel.index);
bool cyr2latEnabled = connector.isChannelCyr2LatEnabled(channel.index);
bool imagesEnabled = connector.isChannelImagesEnabled(channel.index);
String? selectedCyr2LatProfileId = connector.getChannelCyr2LatProfileId(
channel.index,
);
@@ -1635,6 +1636,13 @@ class _ChannelsScreenState extends State<ChannelsScreen>
),
),
],
SwitchListTile(
contentPadding: EdgeInsets.zero,
title: Text(sheetContext.l10n.messageImage_enable),
value: imagesEnabled,
onChanged: (value) =>
setSheetState(() => imagesEnabled = value),
),
const SizedBox(height: 24),
],
),
@@ -1684,6 +1692,10 @@ class _ChannelsScreenState extends State<ChannelsScreen>
channel.index,
cyr2latEnabled,
);
await connector.setChannelImagesEnabled(
channel.index,
imagesEnabled,
);
await connector.setChannelCyr2LatProfileId(
channel.index,
selectedCyr2LatProfileId,
+62 -25
View File
@@ -868,6 +868,7 @@ class _ChatScreenState extends State<ChatScreen> {
bool cyr2latEnabled = connector.isContactCyr2LatEnabled(
contact.publicKeyHex,
);
bool imagesEnabled = connector.isContactImagesEnabled(contact.publicKeyHex);
String? selectedCyr2LatProfileId = connector.getContactCyr2LatProfileId(
contact.publicKeyHex,
);
@@ -967,6 +968,19 @@ class _ChatScreenState extends State<ChatScreen> {
),
],
const Divider(height: 8),
SwitchListTile(
contentPadding: EdgeInsets.zero,
title: Text(context.l10n.messageImage_enable),
value: imagesEnabled,
onChanged: (value) {
connector.setContactImagesEnabled(
contact.publicKeyHex,
value,
);
setDialogState(() => imagesEnabled = value);
},
),
const Divider(height: 8),
SwitchListTile(
contentPadding: EdgeInsets.zero,
title: Text(context.l10n.contact_teleBase),
@@ -1307,6 +1321,9 @@ class _MessageBubble extends StatelessWidget {
final gifId = GifHelper.parseGif(message.text);
final poi = parseMarkerText(message.text);
final isFailed = message.status == MessageStatus.failed;
final imagesEnabled = context.select<MeshCoreConnector, bool>(
(connector) => connector.isContactImagesEnabled(sourceId),
);
// Bubble colors — outgoing uses MeshPalette.me / meBorder / meInk.
final bubbleColor = isFailed
@@ -1354,6 +1371,30 @@ class _MessageBubble extends StatelessWidget {
? message.originalText
: (translatedDisplayText != messageText ? messageText : null);
Widget buildTextContent() {
return Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Flexible(
child: TranslatedMessageContent(
displayText: translatedDisplayText,
originalText: originalDisplayText,
style: TextStyle(
color: textColor,
fontSize: bodyFontSize * textScale,
),
originalStyle: TextStyle(
color: textColor.withValues(alpha: 0.72),
fontSize: bodyFontSize * textScale,
),
onSecondaryTap: PlatformInfo.isDesktop ? onLongPress : null,
),
),
],
);
}
return Padding(
padding: const EdgeInsets.symmetric(vertical: 3),
child: Column(
@@ -1441,7 +1482,7 @@ class _MessageBubble extends StatelessWidget {
),
],
)
else
else if (imagesEnabled)
FutureBuilder<String?>(
future: MessageImageHelper.parseVerified(
message.text,
@@ -1486,32 +1527,28 @@ class _MessageBubble extends StatelessWidget {
);
}
return Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Flexible(
child: TranslatedMessageContent(
displayText: translatedDisplayText,
originalText: originalDisplayText,
style: TextStyle(
color: textColor,
fontSize: bodyFontSize * textScale,
),
originalStyle: TextStyle(
color: textColor.withValues(
alpha: 0.72,
),
fontSize: bodyFontSize * textScale,
),
onSecondaryTap: PlatformInfo.isDesktop
? onLongPress
: null,
return buildTextContent();
},
)
else
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (MessageImageHelper.hasPotentialImageUrl(
message.text,
))
Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Text(
context.l10n.messageImage_possible,
style: TextStyle(
color: metaColor,
fontSize: 11 * textScale,
),
),
],
);
},
),
buildTextContent(),
],
),
if (enableTracing &&
isOutgoing &&
+24 -3
View File
@@ -198,7 +198,12 @@ class NotificationService {
return text;
}
Future<String?> _resolveNotificationImagePath(String text) async {
Future<String?> _resolveNotificationImagePath(
String text, {
required bool imagesEnabled,
}) async {
if (!imagesEnabled) return null;
final imageUrl = await MessageImageHelper.parseVerified(text);
if (imageUrl == null) return null;
@@ -216,12 +221,16 @@ class NotificationService {
Future<void> _showMessageNotificationImpl({
required String contactName,
required String message,
required bool imagesEnabled,
String? contactId,
int? badgeCount,
}) async {
if (!await _ensureCanNotify()) return;
final imagePath = await _resolveNotificationImagePath(message);
final imagePath = await _resolveNotificationImagePath(
message,
imagesEnabled: imagesEnabled,
);
final androidDetails = AndroidNotificationDetails(
'messages',
@@ -334,12 +343,16 @@ class NotificationService {
Future<void> _showChannelMessageNotificationImpl({
required String channelName,
required String message,
required bool imagesEnabled,
int? channelIndex,
int? badgeCount,
}) async {
if (!await _ensureCanNotify()) return;
final imagePath = await _resolveNotificationImagePath(message);
final imagePath = await _resolveNotificationImagePath(
message,
imagesEnabled: imagesEnabled,
);
final androidDetails = AndroidNotificationDetails(
'channel_messages',
@@ -501,6 +514,7 @@ class NotificationService {
Future<void> showMessageNotification({
required String contactName,
required String message,
required bool imagesEnabled,
String? contactId,
int? badgeCount,
}) async {
@@ -511,6 +525,7 @@ class NotificationService {
type: _NotificationType.message,
title: contactName,
body: message,
imagesEnabled: imagesEnabled,
id: contactId,
badgeCount: badgeCount,
),
@@ -538,6 +553,7 @@ class NotificationService {
required String channelName,
required String senderName,
required String message,
required bool imagesEnabled,
int? channelIndex,
int? badgeCount,
}) async {
@@ -548,6 +564,7 @@ class NotificationService {
type: _NotificationType.channelMessage,
title: channelName,
body: '$senderName: $message',
imagesEnabled: imagesEnabled,
id: channelIndex?.toString(),
badgeCount: badgeCount,
),
@@ -609,6 +626,7 @@ class NotificationService {
await _showMessageNotificationImpl(
contactName: notification.title,
message: notification.body,
imagesEnabled: notification.imagesEnabled,
contactId: notification.id,
badgeCount: notification.badgeCount,
);
@@ -624,6 +642,7 @@ class NotificationService {
await _showChannelMessageNotificationImpl(
channelName: notification.title,
message: notification.body,
imagesEnabled: notification.imagesEnabled,
channelIndex: int.tryParse(notification.id ?? ''),
badgeCount: notification.badgeCount,
);
@@ -700,6 +719,7 @@ class _PendingNotification {
final _NotificationType type;
final String title;
final String body;
final bool imagesEnabled;
final String? id;
final int? badgeCount;
@@ -707,6 +727,7 @@ class _PendingNotification {
required this.type,
required this.title,
required this.body,
this.imagesEnabled = false,
this.id,
this.badgeCount,
});
+22
View File
@@ -4,6 +4,7 @@ import 'prefs_manager.dart';
class ChannelSettingsStore {
static const String _keyPrefix = 'channel_smaz_';
static const String _cyr2latKeyPrefix = 'channel_cyr2lat_';
static const String _imagesKeyPrefix = 'channel_images_';
String publicKeyHex = '';
set setPublicKeyHex(String value) =>
@@ -11,6 +12,7 @@ class ChannelSettingsStore {
String get keyFor => '$_keyPrefix$publicKeyHex';
String get keyForCyr2Lat => '$_cyr2latKeyPrefix$publicKeyHex';
String get keyForImages => '$_imagesKeyPrefix$publicKeyHex';
Future<bool> loadSmazEnabled(int channelIndex) async {
if (publicKeyHex.isEmpty) {
@@ -73,6 +75,26 @@ class ChannelSettingsStore {
await prefs.setBool(key, enabled);
}
Future<bool> loadImagesEnabled(int channelIndex) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
'Public key hex is not set. Cannot load channel image settings.',
);
return false;
}
return PrefsManager.instance.getBool('$keyForImages$channelIndex') ?? false;
}
Future<void> saveImagesEnabled(int channelIndex, bool enabled) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
'Public key hex is not set. Cannot save channel image settings.',
);
return;
}
await PrefsManager.instance.setBool('$keyForImages$channelIndex', enabled);
}
Future<String?> loadCyr2LatProfileId(int channelIndex) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
+23
View File
@@ -4,6 +4,7 @@ import 'prefs_manager.dart';
class ContactSettingsStore {
static const String _keyPrefix = 'contact_smaz_';
static const String _cyr2latKeyPrefix = 'contact_cyr2lat_';
static const String _imagesKeyPrefix = 'contact_images_';
String publicKeyHex = '';
set setPublicKeyHex(String value) =>
@@ -11,6 +12,7 @@ class ContactSettingsStore {
String get keyFor => '$_keyPrefix$publicKeyHex';
String get keyForCyr2Lat => '$_cyr2latKeyPrefix$publicKeyHex';
String get keyForImages => '$_imagesKeyPrefix$publicKeyHex';
Future<bool> loadSmazEnabled(String contactKeyHex) async {
if (publicKeyHex.isEmpty) {
@@ -73,6 +75,27 @@ class ContactSettingsStore {
await prefs.setBool(key, enabled);
}
Future<bool> loadImagesEnabled(String contactKeyHex) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
'Public key hex is not set. Cannot load contact image settings.',
);
return false;
}
return PrefsManager.instance.getBool('$keyForImages$contactKeyHex') ??
false;
}
Future<void> saveImagesEnabled(String contactKeyHex, bool enabled) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
'Public key hex is not set. Cannot save contact image settings.',
);
return;
}
await PrefsManager.instance.setBool('$keyForImages$contactKeyHex', enabled);
}
Future<String?> loadCyr2LatProfileId(String contactKeyHex) async {
if (publicKeyHex.isEmpty) {
appLogger.warn(
+9 -1
View File
@@ -58,7 +58,15 @@ void main() {
expect(await MessageImageHelper.parse('hello world'), isNull);
});
test('returns null for non-image ipfs gateway url', () async {
test('detects supported image URLs without resolving them', () {
expect(
MessageImageHelper.hasPotentialImageUrl('https://pyx.li/?i=RzmdkTsE'),
isTrue,
);
expect(MessageImageHelper.hasPotentialImageUrl('hello world'), isFalse);
});
test('returns null for non-image ipfs gateway URL', () async {
final attachment = await MessageImageHelper.parseVerified(
'https://lime-famous-rat-748.mypinata.cloud/ipfs/bafybeih3jqv36rsxqx7yw3k3ixhganrevrk7xmcxgkr2zuzjegxdytb3nq',
);
+32
View File
@@ -1,5 +1,7 @@
{
"bg": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -55,6 +57,8 @@
],
"es": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -89,6 +93,8 @@
],
"fr": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -123,6 +129,8 @@
],
"hu": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -157,6 +165,8 @@
],
"it": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -191,6 +201,8 @@
],
"ja": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -225,6 +237,8 @@
],
"ko": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -259,6 +273,8 @@
],
"nl": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -293,6 +309,8 @@
],
"pl": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -327,6 +345,8 @@
],
"pt": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -361,6 +381,8 @@
],
"ru": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -395,6 +417,8 @@
],
"sk": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -429,6 +453,8 @@
],
"sl": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -463,6 +489,8 @@
],
"sv": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -497,6 +525,8 @@
],
"uk": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",
@@ -531,6 +561,8 @@
],
"zh": [
"messageImage_enable",
"messageImage_possible",
"settings_regionSettings",
"settings_regionSettingsSubtitle",
"settings_regionManagement_screenTitle",