From 5c76628578d3e0b9e4663b603b4019dd6ff540bc Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 26 Jan 2022 12:25:03 -0800 Subject: [PATCH] Upgrade Cwtch and Display Message Limits --- LIBCWTCH-GO-MACOS.version | 2 +- LIBCWTCH-GO.version | 2 +- lib/notification_manager.dart | 3 +-- lib/views/messageview.dart | 16 +++++++++++++++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/LIBCWTCH-GO-MACOS.version b/LIBCWTCH-GO-MACOS.version index 124e8a8e..7d93107b 100644 --- a/LIBCWTCH-GO-MACOS.version +++ b/LIBCWTCH-GO-MACOS.version @@ -1 +1 @@ -2022-01-20-17-22-v1.5.4-16-ge0e1a4b \ No newline at end of file +2022-01-26-15-10-v1.5.4-18-gd77d7bb \ No newline at end of file diff --git a/LIBCWTCH-GO.version b/LIBCWTCH-GO.version index 3513fd2f..f05d8b3d 100644 --- a/LIBCWTCH-GO.version +++ b/LIBCWTCH-GO.version @@ -1 +1 @@ -2022-01-20-22-22-v1.5.4-16-ge0e1a4b \ No newline at end of file +2022-01-26-20-10-v1.5.4-18-gd77d7bb \ No newline at end of file diff --git a/lib/notification_manager.dart b/lib/notification_manager.dart index f01659be..72712b13 100644 --- a/lib/notification_manager.dart +++ b/lib/notification_manager.dart @@ -63,8 +63,7 @@ NotificationsManager newDesktopNotificationsManager() { client.getCapabilities(); return LinuxNotificationsManager(client); } catch (e) { - EnvironmentConfig.debugLog( - "Attempted to access DBUS for notifications but failed. Switching off notifications."); + EnvironmentConfig.debugLog("Attempted to access DBUS for notifications but failed. Switching off notifications."); } } else if (Platform.isWindows) { try { diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index ade71beb..9437dda8 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -175,8 +175,19 @@ class _MessageViewState extends State { )); } + // todo: legacy groups currently have restricted message + // size because of the additional wrapping end encoding + // hybrid groups should allow these numbers to be the same. + static const P2PMessageLengthMax = 7000; + static const GroupMessageLengthMax = 1800; + void _sendMessage([String? ignoredParam]) { - if (ctrlrCompose.value.text.isNotEmpty) { + var isGroup = Provider.of(context).contactList.getContact(Provider.of(context, listen: false).selectedConversation!)!.isGroup; + + // peers and groups currently have different length constraints (servers can store less)... + var lengthOk = (isGroup && ctrlrCompose.value.text.length < GroupMessageLengthMax) || ctrlrCompose.value.text.length <= P2PMessageLengthMax; + + if (ctrlrCompose.value.text.isNotEmpty && lengthOk) { if (Provider.of(context, listen: false).selectedConversation != null && Provider.of(context, listen: false).selectedIndex != null) { Provider.of(context, listen: false) .cwtch @@ -237,6 +248,7 @@ class _MessageViewState extends State { Widget _buildComposeBox() { bool isOffline = Provider.of(context).isOnline() == false; + bool isGroup = Provider.of(context).isGroup; var composeBox = Container( color: Provider.of(context).theme.backgroundMainColor, @@ -262,6 +274,8 @@ class _MessageViewState extends State { keyboardType: TextInputType.multiline, enableIMEPersonalizedLearning: false, minLines: 1, + maxLength: isGroup ? GroupMessageLengthMax : P2PMessageLengthMax, + maxLengthEnforcement: MaxLengthEnforcement.enforced, maxLines: null, onFieldSubmitted: _sendMessage, enabled: !isOffline,