Add a global switch to stop loading images from links
'Load images from links' (default on) gates every link image fetch in MessageUrlImageHelper: chat previews, notification images, ipfs:// resolution and pyx/ibb scraping. Per-chat toggles keep their values but are disabled while it is off. IPFS uploads are unaffected.
This commit is contained in:
1 parent
7f5f71d070
commit
79e3668c18
31 files changed
+381
-33
No files matched your search
@@ -685,6 +685,18 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
) {
|
||||
return Column(
|
||||
children: [
|
||||
SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
secondary: const Icon(Icons.image_search_outlined, size: 24),
|
||||
title: Text(context.l10n.appSettings_loadLinkImages),
|
||||
subtitle: Text(context.l10n.appSettings_loadLinkImagesSubtitle),
|
||||
value: settingsService.settings.loadLinkImages,
|
||||
onChanged: settingsService.setLoadLinkImages,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
|
||||
@@ -815,9 +815,10 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (MessageUrlImageHelper.hasPotentialImageUrl(
|
||||
message.text,
|
||||
))
|
||||
if (settingsService.settings.loadLinkImages &&
|
||||
MessageUrlImageHelper.hasPotentialImageUrl(
|
||||
message.text,
|
||||
))
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: Text(
|
||||
|
||||
@@ -1650,6 +1650,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
bool smazEnabled = connector.isChannelSmazEnabled(channel.index);
|
||||
bool cyr2latEnabled = connector.isChannelCyr2LatEnabled(channel.index);
|
||||
bool urlImagesEnabled = connector.isChannelUrlImagesEnabled(channel.index);
|
||||
final loadLinkImages = appSettingsService.settings.loadLinkImages;
|
||||
String? selectedCyr2LatProfileId = connector.getChannelCyr2LatProfileId(
|
||||
channel.index,
|
||||
);
|
||||
@@ -1769,9 +1770,19 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(sheetContext.l10n.urlImage_enable),
|
||||
subtitle: loadLinkImages
|
||||
? null
|
||||
: Text(
|
||||
sheetContext
|
||||
.l10n
|
||||
.urlImage_disabledInAppSettings,
|
||||
),
|
||||
value: urlImagesEnabled,
|
||||
onChanged: (value) =>
|
||||
setSheetState(() => urlImagesEnabled = value),
|
||||
onChanged: loadLinkImages
|
||||
? (value) => setSheetState(
|
||||
() => urlImagesEnabled = value,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
|
||||
@@ -782,6 +782,10 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
bool urlImagesEnabled = connector.isContactUrlImagesEnabled(
|
||||
contact.publicKeyHex,
|
||||
);
|
||||
final loadLinkImages = context
|
||||
.read<AppSettingsService>()
|
||||
.settings
|
||||
.loadLinkImages;
|
||||
String? selectedCyr2LatProfileId = connector.getContactCyr2LatProfileId(
|
||||
contact.publicKeyHex,
|
||||
);
|
||||
@@ -896,14 +900,19 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(context.l10n.urlImage_enable),
|
||||
subtitle: loadLinkImages
|
||||
? null
|
||||
: Text(context.l10n.urlImage_disabledInAppSettings),
|
||||
value: urlImagesEnabled,
|
||||
onChanged: (value) {
|
||||
connector.setContactUrlImagesEnabled(
|
||||
contact.publicKeyHex,
|
||||
value,
|
||||
);
|
||||
setDialogState(() => urlImagesEnabled = value);
|
||||
},
|
||||
onChanged: loadLinkImages
|
||||
? (value) {
|
||||
connector.setContactUrlImagesEnabled(
|
||||
contact.publicKeyHex,
|
||||
value,
|
||||
);
|
||||
setDialogState(() => urlImagesEnabled = value);
|
||||
}
|
||||
: null,
|
||||
),
|
||||
const Divider(height: 8),
|
||||
SwitchListTile(
|
||||
@@ -1432,9 +1441,10 @@ class _MessageBubble extends StatelessWidget {
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (MessageUrlImageHelper.hasPotentialImageUrl(
|
||||
message.text,
|
||||
))
|
||||
if (settingsService.settings.loadLinkImages &&
|
||||
MessageUrlImageHelper.hasPotentialImageUrl(
|
||||
message.text,
|
||||
))
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: Text(
|
||||
|
||||
Reference in new issue
Block a user