add send-links capability with translation
This commit is contained in:
@@ -144,6 +144,12 @@ abstract class Translations {
|
||||
/// The label for "OK"
|
||||
String get okLabel;
|
||||
|
||||
/// The label for a link disabled error
|
||||
String get linkDisabledError;
|
||||
|
||||
/// The additional info on a link disabled error
|
||||
String get linkDisabledDetails;
|
||||
|
||||
/// The label for "add more files"
|
||||
String get addMoreFilesLabel;
|
||||
|
||||
@@ -692,4 +698,11 @@ class DefaultTranslations implements Translations {
|
||||
@override
|
||||
String attachmentLimitExceedError(int limit) => """
|
||||
Attachment limit exceeded: it's not possible to add more than $limit attachments""";
|
||||
|
||||
@override
|
||||
String get linkDisabledDetails =>
|
||||
'Sending links is not allowed in this conversation.';
|
||||
|
||||
@override
|
||||
String get linkDisabledError => 'Links are disabled';
|
||||
}
|
||||
|
||||
@@ -928,7 +928,9 @@ class MessageInputState extends State<MessageInput>
|
||||
_actionsShrunk = value.isNotEmpty && actionsLength > 1;
|
||||
});
|
||||
|
||||
_checkContainsUrl(value, context);
|
||||
if (channel.ownCapabilities.contains(PermissionType.sendLinks)) {
|
||||
_checkContainsUrl(value, context);
|
||||
}
|
||||
_checkCommands(value, context);
|
||||
_checkMentions(value, context);
|
||||
_checkEmoji(value, context);
|
||||
@@ -1646,9 +1648,25 @@ class MessageInputState extends State<MessageInput>
|
||||
|
||||
/// Sends the current message
|
||||
Future<void> sendMessage() async {
|
||||
final skipEnrichUrl = _effectiveController.ogAttachment == null;
|
||||
|
||||
final streamChannel = StreamChannel.of(context);
|
||||
var message = _effectiveController.value;
|
||||
if (!streamChannel.channel.ownCapabilities
|
||||
.contains(PermissionType.sendLinks) &&
|
||||
_urlRegex.hasMatch(message.text ?? '')) {
|
||||
showInfoDialog(
|
||||
context,
|
||||
icon: StreamSvgIcon.error(
|
||||
color: StreamChatTheme.of(context).colorTheme.accentError,
|
||||
size: 24,
|
||||
),
|
||||
title: 'Links are disabled',
|
||||
details: 'Sending links is not allowed in this conversation.',
|
||||
okText: context.translations.okLabel,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final skipEnrichUrl = _effectiveController.ogAttachment == null;
|
||||
|
||||
var shouldKeepFocus = widget.shouldKeepFocusAfterMessage;
|
||||
|
||||
@@ -1660,7 +1678,6 @@ class MessageInputState extends State<MessageInput>
|
||||
message = await widget.preMessageSending!(message);
|
||||
}
|
||||
|
||||
final streamChannel = StreamChannel.of(context);
|
||||
final channel = streamChannel.channel;
|
||||
if (!channel.state!.isUpToDate) {
|
||||
await streamChannel.reloadChannel();
|
||||
|
||||
Reference in New Issue
Block a user