Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added hide message functionality #1689

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/hms_room_kit/lib/src/assets/icons/hide.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ class _OverlayChatComponentState extends State<OverlayChatComponent> {

///This function scrolls to the end of the list
void _scrollToEnd() {
WidgetsBinding.instance.addPostFrameCallback((_) =>
_scrollController.animateTo(_scrollController.position.maxScrollExtent,
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut));
if (_scrollController.hasClients) {
WidgetsBinding.instance.addPostFrameCallback((_) => _scrollController
.animateTo(_scrollController.position.maxScrollExtent,
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut));
}
}

///This function updates the selected value
Expand Down
23 changes: 23 additions & 0 deletions packages/hms_room_kit/lib/src/meeting/meeting_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ class MeetingStore extends ChangeNotifier
///[pinnedMessages] is the list of pinned messages
List<dynamic> pinnedMessages = [];

///[hiddenMessages] is the list of hidden messages
List<String> hiddenMessages = [];

///[blackListedUserIds] is the list of user ids which are blacklisted from chat
List<String> blackListedUserIds = [];

Expand Down Expand Up @@ -1812,6 +1815,16 @@ class MeetingStore extends ChangeNotifier
}
break;
case SessionStoreKey.chatMessageBlacklist:
hiddenMessages.clear();
if (value != null) {
var data = jsonDecode(value);
if (data != null && data.isNotEmpty) {
data.forEach((element) {
hiddenMessages.add(element);
messages.removeWhere((message) => message.messageId == element);
});
}
}
break;
case SessionStoreKey.unknown:
break;
Expand Down Expand Up @@ -2011,6 +2024,16 @@ class MeetingStore extends ChangeNotifier
metadata: data);
}

void hideMessage(HMSMessage message) {
hiddenMessages.add(message.messageId);
unpinMessage(message.messageId);
setSessionMetadataForKey(
key: SessionStoreKeyValues.getNameFromMethod(
SessionStoreKey.chatMessageBlacklist),
metadata: hiddenMessages);
notifyListeners();
}

///[setReipientSelectorValue] method is used to set the value of recipient selector
void setRecipientSelectorValue() {
if (HMSRoomLayout.chatData?.isPublicChatEnabled ?? false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class _ChatBottomSheetState extends State<ChatBottomSheet> {
}

void _scrollToEnd() {
if (_scrollController.positions.isNotEmpty) {
if (_scrollController.hasClients) {
WidgetsBinding.instance.addPostFrameCallback((_) => _scrollController
.animateTo(_scrollController.position.maxScrollExtent,
duration: const Duration(milliseconds: 200),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,30 @@ class _ChatUtilitiesBottomSheetState extends State<ChatUtilitiesBottomSheet> {
fontWeight: FontWeight.w600,
textColor: HMSThemeColors.onSurfaceHighEmphasis)),

if ((HMSRoomLayout.chatData?.realTimeControls?.canHideMessage ??
false) &&
(widget.message.sender?.isLocal ?? false))
ListTile(
horizontalTitleGap: 2,
onTap: () async {
Navigator.pop(context);
context.read<MeetingStore>().hideMessage(widget.message);
},
contentPadding: EdgeInsets.zero,
leading: SvgPicture.asset(
"packages/hms_room_kit/lib/src/assets/icons/hide.svg",
semanticsLabel: "fl_copy_message_icon",
height: 20,
width: 20,
colorFilter: ColorFilter.mode(
HMSThemeColors.onSurfaceHighEmphasis, BlendMode.srcIn),
),
title: HMSSubheadingText(
text: "Hide for Everyone",
letterSpacing: 0.1,
fontWeight: FontWeight.w600,
textColor: HMSThemeColors.onSurfaceHighEmphasis)),

if (HMSRoomLayout.chatData?.realTimeControls?.canBlockUser ?? false)
ListTile(
horizontalTitleGap: 2,
Expand Down
Loading