diff --git a/lib/helpers/ipfs_link_attach_flow.dart b/lib/helpers/ipfs_link_attach_flow.dart index a63c2534..98bfa828 100644 --- a/lib/helpers/ipfs_link_attach_flow.dart +++ b/lib/helpers/ipfs_link_attach_flow.dart @@ -14,8 +14,10 @@ import 'snack_bar_builder.dart'; /// puts the resulting link at the start of the composer draft. /// /// [maxBytes] is the screen's outbound byte limit and [encodeOutbound] turns -/// draft text into what the radio would actually send, so the limit is -/// checked against the encoded form. +/// draft text into exactly what the send path measures (including any reply +/// prefix), so the limit is checked against that form. The draft is never +/// shortened: if the link won't fit, nothing is uploaded and the user is told +/// to shorten the message. Future attachIpfsLinkToDraft({ required BuildContext context, required TextEditingController controller, @@ -33,6 +35,25 @@ Future attachIpfsLinkToDraft({ return; } + String draftWithLink(String messageUrl) => composeIpfsLinkDraft( + messageUrl: messageUrl, + existingText: controller.text.trim(), + ); + bool fits(String draft) => ipfsLinkDraftFits( + draft, + maxBytes: maxBytes, + encodeOutbound: encodeOutbound, + ); + + final sampleLink = IpfsUploadHelper.linkForCid( + uploadGateway: settings.uploadIpfsGateway, + cid: IpfsUploadHelper.sampleCid, + ); + if (!fits(draftWithLink(sampleLink))) { + showDismissibleSnackBar(context, content: Text(l10n.chat_ipfsLinkNoRoom)); + return; + } + void showFailure(Object error) { if (!context.mounted) return; showDismissibleSnackBar( @@ -73,50 +94,31 @@ Future attachIpfsLinkToDraft({ } if (!context.mounted) return; - final messageText = composeIpfsLinkDraft( - messageUrl: messageUrl, - existingText: controller.text.trim(), - maxBytes: maxBytes, - encodeOutbound: encodeOutbound, - ); - if (messageText == null) { - showDismissibleSnackBar( - context, - content: Text(l10n.chat_messageTooLong(maxBytes)), - ); - return; - } - + final messageText = draftWithLink(messageUrl); controller.value = TextEditingValue( text: messageText, selection: TextSelection.collapsed(offset: messageText.length), ); focusNode.requestFocus(); + if (!fits(messageText)) { + showDismissibleSnackBar( + context, + content: Text(l10n.chat_ipfsLinkOverLimit), + ); + } } -/// Builds the draft with [messageUrl] in front of [existingText], trimming -/// [existingText] from the end until the encoded result fits [maxBytes]. -/// Returns null when even the link alone does not fit. +/// Puts [messageUrl] in front of [existingText], leaving the text intact. @visibleForTesting -String? composeIpfsLinkDraft({ +String composeIpfsLinkDraft({ required String messageUrl, required String existingText, +}) => existingText.isEmpty ? '$messageUrl ' : '$messageUrl\n$existingText'; + +/// Whether [draft], encoded the way the send path encodes it, fits [maxBytes]. +@visibleForTesting +bool ipfsLinkDraftFits( + String draft, { required int maxBytes, required String Function(String text) encodeOutbound, -}) { - bool fits(String text) => - utf8.encode(encodeOutbound(text)).length <= maxBytes; - - final messageText = existingText.isEmpty - ? '$messageUrl ' - : '$messageUrl\n$existingText'; - if (fits(messageText)) return messageText; - if (existingText.isEmpty) return null; - - final originalCharacters = existingText.characters.toList(); - for (var count = originalCharacters.length - 1; count >= 0; count--) { - final candidate = '$messageUrl\n${originalCharacters.take(count).join()}'; - if (fits(candidate)) return candidate; - } - return null; -} +}) => utf8.encode(encodeOutbound(draft.trim())).length <= maxBytes; diff --git a/lib/helpers/ipfs_upload_helper.dart b/lib/helpers/ipfs_upload_helper.dart index 3a1c95dd..84c32e9d 100644 --- a/lib/helpers/ipfs_upload_helper.dart +++ b/lib/helpers/ipfs_upload_helper.dart @@ -22,6 +22,19 @@ class IpfsUploadHelper { static final _kuboAddPath = RegExp(r'/api/v0/add/?$'); + /// A CIDv1 (base32, sha2-256) as long as the CID of every upload, used to + /// size the link before uploading. + static const sampleCid = + 'bafkreihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku'; + + static String linkForCid({ + required String uploadGateway, + required String cid, + }) { + final gateway = normalizeIpfsGateway(uploadGateway); + return gateway.isEmpty ? 'ipfs://$cid' : '$gateway$cid'; + } + static String mimeTypeForFileName(String fileName) { switch (fileName.toLowerCase().split('.').last) { case 'jpg': @@ -149,8 +162,7 @@ class IpfsUploadHelper { ); } - final gateway = normalizeIpfsGateway(uploadGateway); - return gateway.isEmpty ? 'ipfs://$cid' : '$gateway$cid'; + return linkForCid(uploadGateway: uploadGateway, cid: cid); } static Future _copyKuboFileToMfs({ diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 90f4b2a8..dc636bb3 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -953,6 +953,14 @@ } }, "chat_ipfsUploadNotConfigured": "Configure an IPFS upload provider in App Settings first.", + "chat_ipfsLinkNoRoom": "Not enough room for the image link. Shorten your message, then try again.", + "@chat_ipfsLinkNoRoom": { + "description": "Shown before an IPFS upload when the link would push the draft over the message size limit" + }, + "chat_ipfsLinkOverLimit": "Image link added, but the message is now too long. Shorten it before sending.", + "@chat_ipfsLinkOverLimit": { + "description": "Shown after an IPFS upload when the link plus the draft no longer fits the message size limit" + }, "chat_imagePickFailed": "Couldn't open that image", "@chat_imagePickFailed": { "description": "Shown when picking or reading a photo to send fails" diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 5c373c88..f0ef56b2 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -3286,6 +3286,18 @@ abstract class AppLocalizations { /// **'Configure an IPFS upload provider in App Settings first.'** String get chat_ipfsUploadNotConfigured; + /// Shown before an IPFS upload when the link would push the draft over the message size limit + /// + /// In en, this message translates to: + /// **'Not enough room for the image link. Shorten your message, then try again.'** + String get chat_ipfsLinkNoRoom; + + /// Shown after an IPFS upload when the link plus the draft no longer fits the message size limit + /// + /// In en, this message translates to: + /// **'Image link added, but the message is now too long. Shorten it before sending.'** + String get chat_ipfsLinkOverLimit; + /// Shown when picking or reading a photo to send fails /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index 3c2da765..8d8f2062 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -1850,6 +1850,14 @@ class AppLocalizationsBg extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Не мог да откривам та изображин'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index 1702dc5f..66d31e7c 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -1849,6 +1849,14 @@ class AppLocalizationsDe extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Konnte dieses Bild nicht öffnen.'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 6a0d515e..eec87fe4 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -1818,6 +1818,14 @@ class AppLocalizationsEn extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Couldn\'t open that image'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 84d219d6..a5941d81 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -1845,6 +1845,14 @@ class AppLocalizationsEs extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'No pude abrir esa imagen'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index a6ec3d92..116726ec 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -1849,6 +1849,14 @@ class AppLocalizationsFr extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Je n\'ai pas pu ouvrir cette image'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index 3bca928f..2ffb5823 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -1839,6 +1839,14 @@ class AppLocalizationsHu extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Nem tudtam ezt a fenti fényre kapni'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index f42acccf..50025be5 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -1849,6 +1849,14 @@ class AppLocalizationsIt extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Non sono riuscito ad aprire quell\'immagine'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index c92b8eea..e62ca29b 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -1762,6 +1762,14 @@ class AppLocalizationsJa extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'その画像を開けませんでした'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index 98d004f4..e2968f56 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -1767,6 +1767,14 @@ class AppLocalizationsKo extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => '그 이미지를 열 수 없었어요.'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index 8e4c5505..4b64c5f5 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -1835,6 +1835,14 @@ class AppLocalizationsNl extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Kon die afbeelding niet openen'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index c189c51f..6fc4644f 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -1864,6 +1864,14 @@ class AppLocalizationsPl extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Nie mogłem otworzyć tego obrazu'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index 4311bb90..bc7b746e 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -1845,6 +1845,14 @@ class AppLocalizationsPt extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Não consegui abrir essa imagem'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index 06aae2bd..0793eafe 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -1849,6 +1849,14 @@ class AppLocalizationsRu extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Не удалось открыть это изображение'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 614f1129..efa338ae 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -1837,6 +1837,14 @@ class AppLocalizationsSk extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Nesmiela jsem otvoriť tento obrázok'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index b413cb72..87154737 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -1836,6 +1836,14 @@ class AppLocalizationsSl extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Nispeval sem tega ta slik'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index b5901e64..acbc7b41 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -1824,6 +1824,14 @@ class AppLocalizationsSv extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Kunde inte öppna bilden'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index 1c899a8b..65e1df41 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -1839,6 +1839,14 @@ class AppLocalizationsUk extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => 'Неможливо відкрити це изображення'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index b731f733..43354856 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -1742,6 +1742,14 @@ class AppLocalizationsZh extends AppLocalizations { String get chat_ipfsUploadNotConfigured => 'Configure an IPFS upload provider in App Settings first.'; + @override + String get chat_ipfsLinkNoRoom => + 'Not enough room for the image link. Shorten your message, then try again.'; + + @override + String get chat_ipfsLinkOverLimit => + 'Image link added, but the message is now too long. Shorten it before sending.'; + @override String get chat_imagePickFailed => '无法打开该图片'; diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index ea3cce16..f0cbcc19 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -1319,8 +1319,13 @@ class _ChannelChatScreenState extends State { controller: _textController, focusNode: _textFieldFocusNode, maxBytes: maxChannelMessageBytes(connector.selfName), - encodeOutbound: (text) => - connector.prepareChannelOutboundText(widget.channel.index, text), + encodeOutbound: (text) { + final replyTo = _replyingToMessage; + return connector.prepareChannelOutboundText( + widget.channel.index, + replyTo == null ? text : '${_replyPrefix(replyTo)}$text', + ); + }, ); } diff --git a/test/helpers/ipfs_link_attach_flow_test.dart b/test/helpers/ipfs_link_attach_flow_test.dart index 6c8603f1..b07d537d 100644 --- a/test/helpers/ipfs_link_attach_flow_test.dart +++ b/test/helpers/ipfs_link_attach_flow_test.dart @@ -1,76 +1,71 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:meshcore_open/helpers/ipfs_link_attach_flow.dart'; +import 'package:meshcore_open/helpers/ipfs_upload_helper.dart'; void main() { const url = 'ipfs://cid'; String identity(String text) => text; - test('puts the link before an empty draft with a trailing space', () { - expect( - composeIpfsLinkDraft( - messageUrl: url, - existingText: '', - maxBytes: 100, - encodeOutbound: identity, - ), - '$url ', - ); + group('composeIpfsLinkDraft', () { + test('puts the link before an empty draft with a trailing space', () { + expect(composeIpfsLinkDraft(messageUrl: url, existingText: ''), '$url '); + }); + + test('keeps the whole draft after the link', () { + final draft = 'x' * 500; + expect( + composeIpfsLinkDraft(messageUrl: url, existingText: draft), + '$url\n$draft', + ); + }); }); - test('keeps a draft that fits after the link', () { - expect( - composeIpfsLinkDraft( - messageUrl: url, - existingText: 'hello', - maxBytes: 100, - encodeOutbound: identity, - ), - '$url\nhello', - ); + group('ipfsLinkDraftFits', () { + test('accepts a draft at the limit and rejects one byte over', () { + expect( + ipfsLinkDraftFits('$url\nhi', maxBytes: 13, encodeOutbound: identity), + isTrue, + ); + expect( + ipfsLinkDraftFits('$url\nhi', maxBytes: 12, encodeOutbound: identity), + isFalse, + ); + }); + + test('measures the encoded form, including a reply prefix', () { + String withReply(String text) => '@[Alice] $text'; + expect( + ipfsLinkDraftFits('$url\nhi', maxBytes: 13, encodeOutbound: withReply), + isFalse, + ); + expect( + ipfsLinkDraftFits('$url\nhi', maxBytes: 22, encodeOutbound: withReply), + isTrue, + ); + }); + + test('ignores the trailing space the send path trims', () { + expect( + ipfsLinkDraftFits( + '$url ', + maxBytes: url.length, + encodeOutbound: identity, + ), + isTrue, + ); + }); }); - test('trims the draft until the encoded text fits', () { - expect( - composeIpfsLinkDraft( - messageUrl: url, - existingText: 'hello', - maxBytes: url.length + 3, - encodeOutbound: identity, - ), - '$url\nhe', - ); - }); + group('IpfsUploadHelper.linkForCid', () { + test('uses ipfs:// without a gateway', () { + expect( + IpfsUploadHelper.linkForCid(uploadGateway: '', cid: 'abc'), + 'ipfs://abc', + ); + }); - test('measures the encoded form', () { - expect( - composeIpfsLinkDraft( - messageUrl: url, - existingText: 'hello', - maxBytes: url.length + 3, - encodeOutbound: (text) => 'x$text', - ), - '$url\nh', - ); - }); - - test('returns null when the link alone does not fit', () { - expect( - composeIpfsLinkDraft( - messageUrl: url, - existingText: 'hello', - maxBytes: 4, - encodeOutbound: identity, - ), - isNull, - ); - expect( - composeIpfsLinkDraft( - messageUrl: url, - existingText: '', - maxBytes: 4, - encodeOutbound: identity, - ), - isNull, - ); + test('sample CID is CIDv1 base32 length', () { + expect(IpfsUploadHelper.sampleCid.length, 59); + }); }); } diff --git a/untranslated.json b/untranslated.json index 337d70f9..bf46ed3d 100644 --- a/untranslated.json +++ b/untranslated.json @@ -21,6 +21,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -64,6 +66,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -107,6 +111,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -150,6 +156,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -193,6 +201,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -236,6 +246,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -279,6 +291,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -322,6 +336,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -365,6 +381,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -408,6 +426,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -451,6 +471,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -494,6 +516,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -537,6 +561,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -580,6 +606,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -623,6 +651,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -666,6 +696,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint", @@ -709,6 +741,8 @@ "chat_sendImageIpfs", "chat_ipfsUploadFailed", "chat_ipfsUploadNotConfigured", + "chat_ipfsLinkNoRoom", + "chat_ipfsLinkOverLimit", "map_pathTraceAddMoreHint", "map_pathTraceModeRoundTrip", "map_pathTraceModeRoundTripHint",