Skip to content

Commit

Permalink
Added hide message functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Decoder07 committed Jan 11, 2024
1 parent a4fbe5a commit a89a2e4
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
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

0 comments on commit a89a2e4

Please sign in to comment.