feat(ui): Added StreamMessageInput.ogPreviewFilter to allow users to filter out the og preview links.
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -7,19 +7,41 @@
|
|||||||
- [#1505](https://github.com/GetStream/stream-chat-flutter/issues/1505) Fixed Message bubble disappears for Hangul
|
- [#1505](https://github.com/GetStream/stream-chat-flutter/issues/1505) Fixed Message bubble disappears for Hangul
|
||||||
Consonants.
|
Consonants.
|
||||||
|
|
||||||
|
✅ Added
|
||||||
|
|
||||||
|
- Added `StreamMessageInput.ogPreviewFilter` to allow users to filter out the og preview
|
||||||
|
links. [#1338](https://github.com/GetStream/stream-chat-flutter/issues/1338)
|
||||||
|
|
||||||
|
```dart
|
||||||
|
StreamMessageInput(
|
||||||
|
ogPreviewFilter: (matchedUri, messageText) {
|
||||||
|
final url = matchedUri.toString();
|
||||||
|
if (url.contains('giphy.com')) {
|
||||||
|
// Return false to prevent the OG preview from being built.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Return true to build the OG preview.
|
||||||
|
return true;
|
||||||
|
),
|
||||||
|
```
|
||||||
|
|
||||||
## 6.0.0
|
## 6.0.0
|
||||||
|
|
||||||
🐞 Fixed
|
🐞 Fixed
|
||||||
|
|
||||||
- [#1456](https://github.com/GetStream/stream-chat-flutter/issues/1456) Fixed logic for showing that a message was read using sending indicator.
|
- [#1456](https://github.com/GetStream/stream-chat-flutter/issues/1456) Fixed logic for showing that a message was read
|
||||||
- [#1462](https://github.com/GetStream/stream-chat-flutter/issues/1462) Fixed support for iPad in the share button for images.
|
using sending indicator.
|
||||||
|
- [#1462](https://github.com/GetStream/stream-chat-flutter/issues/1462) Fixed support for iPad in the share button for
|
||||||
|
images.
|
||||||
- [#1475](https://github.com/GetStream/stream-chat-flutter/issues/1475) Fixed typo to fix compilation.
|
- [#1475](https://github.com/GetStream/stream-chat-flutter/issues/1475) Fixed typo to fix compilation.
|
||||||
|
|
||||||
✅ Added
|
✅ Added
|
||||||
|
|
||||||
- Now it is possible to customize the max lines of the title of a url attachment. Before it was always 1 line.
|
- Now it is possible to customize the max lines of the title of a url attachment. Before it was always 1 line.
|
||||||
- Added `attachmentActionsModalBuilder` parameter to `StreamMessageWidget` that allows to customize `AttachmentActionsModal`.
|
- Added `attachmentActionsModalBuilder` parameter to `StreamMessageWidget` that allows to
|
||||||
- Added `StreamMessageInput.sendMessageKeyPredicate` and `StreamMessageInput.clearQuotedMessageKeyPredicate` to customize the keys used to send and clear the quoted message.
|
customize `AttachmentActionsModal`.
|
||||||
|
- Added `StreamMessageInput.sendMessageKeyPredicate` and `StreamMessageInput.clearQuotedMessageKeyPredicate` to
|
||||||
|
customize the keys used to send and clear the quoted message.
|
||||||
|
|
||||||
🔄 Changed
|
🔄 Changed
|
||||||
|
|
||||||
@@ -27,6 +49,7 @@
|
|||||||
|
|
||||||
🚀 Improved
|
🚀 Improved
|
||||||
-
|
-
|
||||||
|
|
||||||
- Improved draw of reaction options. [#1455](https://github.com/GetStream/stream-chat-flutter/pull/1455)
|
- Improved draw of reaction options. [#1455](https://github.com/GetStream/stream-chat-flutter/pull/1455)
|
||||||
|
|
||||||
## 5.3.0
|
## 5.3.0
|
||||||
@@ -36,17 +59,22 @@
|
|||||||
- Updated `photo_manager` dependency to `^2.5.2`
|
- Updated `photo_manager` dependency to `^2.5.2`
|
||||||
|
|
||||||
🐞 Fixed
|
🐞 Fixed
|
||||||
- [[#1424]](https://github.com/GetStream/stream-chat-flutter/issues/1424) Fixed a render issue when showing messages starting with 4 whitespaces.
|
|
||||||
|
- [[#1424]](https://github.com/GetStream/stream-chat-flutter/issues/1424) Fixed a render issue when showing messages
|
||||||
|
starting with 4 whitespaces.
|
||||||
- Fixed a bug where the `AttachmentPickerBottomSheet` was not able to identify the mobile browser.
|
- Fixed a bug where the `AttachmentPickerBottomSheet` was not able to identify the mobile browser.
|
||||||
- Fixed uploading files on Windows - fixed temp file path.
|
- Fixed uploading files on Windows - fixed temp file path.
|
||||||
|
|
||||||
✅ Added
|
✅ Added
|
||||||
|
|
||||||
- New `noPhotoOrVideoLabel` displayed when there is no files to choose.
|
- New `noPhotoOrVideoLabel` displayed when there is no files to choose.
|
||||||
|
|
||||||
## 5.2.0
|
## 5.2.0
|
||||||
|
|
||||||
✅ Added
|
✅ Added
|
||||||
- Added a new `bottomRowBuilderWithDefaultWidget` parameter to `StreamMessageWidget` which contains a third parameter (default `BottomRow` widget with `copyWith` method available) to allow easier customization.
|
|
||||||
|
- Added a new `bottomRowBuilderWithDefaultWidget` parameter to `StreamMessageWidget` which contains a third parameter (
|
||||||
|
default `BottomRow` widget with `copyWith` method available) to allow easier customization.
|
||||||
|
|
||||||
🔄 Changed
|
🔄 Changed
|
||||||
|
|
||||||
@@ -56,14 +84,20 @@
|
|||||||
- Updated `dart_vlc` dependency to `^0.4.0`
|
- Updated `dart_vlc` dependency to `^0.4.0`
|
||||||
- Updated `file_picker` dependency to `^5.2.4`
|
- Updated `file_picker` dependency to `^5.2.4`
|
||||||
- Deprecated `StreamMessageWidget.bottomRowBuilder` in favor of `StreamMessageWidget.bottomRowBuilderWithDefaultWidget`.
|
- Deprecated `StreamMessageWidget.bottomRowBuilder` in favor of `StreamMessageWidget.bottomRowBuilderWithDefaultWidget`.
|
||||||
- Deprecated `StreamMessageWidget.deletedBottomRowBuilder` in favor of `StreamMessageWidget.bottomRowBuilderWithDefaultWidget`.
|
- Deprecated `StreamMessageWidget.deletedBottomRowBuilder` in favor
|
||||||
|
of `StreamMessageWidget.bottomRowBuilderWithDefaultWidget`.
|
||||||
- Deprecated `StreamMessageWidget.usernameBuilder` in favor of `StreamMessageWidget.bottomRowBuilderWithDefaultWidget`.
|
- Deprecated `StreamMessageWidget.usernameBuilder` in favor of `StreamMessageWidget.bottomRowBuilderWithDefaultWidget`.
|
||||||
|
|
||||||
🐞 Fixed
|
🐞 Fixed
|
||||||
- [[#1379]](https://github.com/GetStream/stream-chat-flutter/issues/1379) Fixed "Issues with photo attachments on web", where the cached image attachment would not render while uploading.
|
|
||||||
- Fix render overflow issue with `MessageSearchListTileTitle`. It now uses `Text.rich` instead of `Row`. Better default behaviour and allows `TextOverflow`.
|
- [[#1379]](https://github.com/GetStream/stream-chat-flutter/issues/1379) Fixed "Issues with photo attachments on web",
|
||||||
- [[1346]](https://github.com/GetStream/stream-chat-flutter/issues/1346) Fixed a render issue while uploading video on web.
|
where the cached image attachment would not render while uploading.
|
||||||
- [[#1347]](https://github.com/GetStream/stream-chat-flutter/issues/1347) `onReply` not working in `AttachmentActionsModal` which is used by `StreamImageAttachment` and `StreamImageGroup`.
|
- Fix render overflow issue with `MessageSearchListTileTitle`. It now uses `Text.rich` instead of `Row`. Better default
|
||||||
|
behaviour and allows `TextOverflow`.
|
||||||
|
- [[1346]](https://github.com/GetStream/stream-chat-flutter/issues/1346) Fixed a render issue while uploading video on
|
||||||
|
web.
|
||||||
|
- [[#1347]](https://github.com/GetStream/stream-chat-flutter/issues/1347) `onReply` not working
|
||||||
|
in `AttachmentActionsModal` which is used by `StreamImageAttachment` and `StreamImageGroup`.
|
||||||
|
|
||||||
## 5.1.0
|
## 5.1.0
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|||||||
const _kCommandTrigger = '/';
|
const _kCommandTrigger = '/';
|
||||||
const _kMentionTrigger = '@';
|
const _kMentionTrigger = '@';
|
||||||
|
|
||||||
|
/// Signature for the function that determines if a [matchedUri] should be
|
||||||
|
/// previewed as an OG Attachment.
|
||||||
|
typedef OgPreviewFilter = bool Function(
|
||||||
|
Uri matchedUri,
|
||||||
|
String messageText,
|
||||||
|
);
|
||||||
|
|
||||||
/// Inactive state:
|
/// Inactive state:
|
||||||
///
|
///
|
||||||
/// 
|
/// 
|
||||||
@@ -114,6 +121,7 @@ class StreamMessageInput extends StatefulWidget {
|
|||||||
this.sendMessageKeyPredicate = _defaultSendMessageKeyPredicate,
|
this.sendMessageKeyPredicate = _defaultSendMessageKeyPredicate,
|
||||||
this.clearQuotedMessageKeyPredicate =
|
this.clearQuotedMessageKeyPredicate =
|
||||||
_defaultClearQuotedMessageKeyPredicate,
|
_defaultClearQuotedMessageKeyPredicate,
|
||||||
|
this.ogPreviewFilter = _defaultOgPreviewFilter,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The predicate used to send a message on desktop/web
|
/// The predicate used to send a message on desktop/web
|
||||||
@@ -259,6 +267,18 @@ class StreamMessageInput extends StatefulWidget {
|
|||||||
/// Callback for when the quoted message is cleared
|
/// Callback for when the quoted message is cleared
|
||||||
final VoidCallback? onQuotedMessageCleared;
|
final VoidCallback? onQuotedMessageCleared;
|
||||||
|
|
||||||
|
/// The filter used to determine if a link should be shown as an OpenGraph
|
||||||
|
/// preview.
|
||||||
|
final OgPreviewFilter ogPreviewFilter;
|
||||||
|
|
||||||
|
static bool _defaultOgPreviewFilter(
|
||||||
|
Uri matchedUri,
|
||||||
|
String messageText,
|
||||||
|
) {
|
||||||
|
// Show the preview for all links
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool _defaultValidator(Message message) =>
|
static bool _defaultValidator(Message message) =>
|
||||||
message.text?.isNotEmpty == true || message.attachments.isNotEmpty;
|
message.text?.isNotEmpty == true || message.attachments.isNotEmpty;
|
||||||
|
|
||||||
@@ -990,11 +1010,13 @@ class StreamMessageInputState extends State<StreamMessageInput>
|
|||||||
if (_lastSearchedContainsUrlText == value) return;
|
if (_lastSearchedContainsUrlText == value) return;
|
||||||
_lastSearchedContainsUrlText = value;
|
_lastSearchedContainsUrlText = value;
|
||||||
|
|
||||||
final matchedUrls = _urlRegex.allMatches(value).toList()
|
final matchedUrls = _urlRegex.allMatches(value).where((it) {
|
||||||
..removeWhere((it) {
|
final _parsedMatch = Uri.tryParse(it.group(0) ?? '')?.withScheme;
|
||||||
final _parsedMatch = Uri.tryParse(it.group(0) ?? '')?.withScheme;
|
if (_parsedMatch == null) return false;
|
||||||
return _parsedMatch?.host.split('.').last.isValidTLD() == false;
|
|
||||||
});
|
return _parsedMatch.host.split('.').last.isValidTLD() &&
|
||||||
|
widget.ogPreviewFilter.call(_parsedMatch, value);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
// Reset the og attachment if the text doesn't contain any url
|
// Reset the og attachment if the text doesn't contain any url
|
||||||
if (matchedUrls.isEmpty ||
|
if (matchedUrls.isEmpty ||
|
||||||
|
|||||||
Reference in New Issue
Block a user