i wanna hide message like hide channel with hide previous messages, can i hide just one message which i want?
Are you wanting to simply hide it from view or remove it entirely?
Looking at this a bit more, it looks like you could possibly hide messages on load as it supports MessageTypeFilter
, CustomTypeFilter
and SenderUserIdsFilter
.
Using the example code, you could use this idea.
Change the default send behavior to add a customType of something like Visible
:
const params = new sb.UserMessageParams();
params.message = TEXT_MESSAGE;
params.customType = "Visible";
params.data = DATA;
params.mentionType = 'users'; // Either 'users' or 'channel'
params.mentionedUserIds = ['Jeff', 'Julia']; // Or mentionedUsers = Array<User>;
params.metaArrayKeys = ['linkTo', 'itemType'];
params.translationTargetLanguages = ['fe', 'de']; // French and German
params.pushNotificationDeliveryOption = 'default'; // Either 'default' or 'suppress'
groupChannel.sendUserMessage(params, function(message, error) {
if (error) {
return;
}
console.log(message);
});
Then when loading messages, you could ensure you add a CustomTypeFilter
for Visible
so that if a message does not have Visible
, we don’t show it.
// There should only be one single instance per channel view.
var prevMessageListQuery = groupChannel.createPreviousMessageListQuery();
prevMessageListQuery.limit = LIMIT;
prevMessageListQuery.reverse = REVERSE;
prevMessageListQuery.includeMetaArray = true; // Retrieve a list of messages along with their metaarrays.
prevMessageListQuery.includeReaction = true; // Retrieve a list of messages along with their reactions.
prevMessageListQuery.customTypeFilter = ["Visible"]
...
// Retrieving previous messages.
prevMessageListQuery.load(function(messages, error) {
if (error) {
return;
}
console.log(messages);
});
When you want to hide a message, you could update the CustomType to either remove Visible
or, for better clarify, update the CustomType to Hidden
thus effectively removing it from their view.
I should note that this would hide it for all users in the chat, so you could make the logic a bit more complex if you were looking to only hide it from a specific user and not the rest.
Documents used:
Thanks for your replies, i got your advises, but i wanna hide the messages just for sender user, or not set custom type for messages, like function resetMyChatHistory, just for sender user, don’t influence the channel, i use syncManager framework in my project
Could you expand on the rational as to why you would want to hide a message just for the sender and not for the entire channel? That may allow us to come up with a better solution for you. I’m not sure I completely understand what you’re attempting to hide, if it be a singular message or the entirety of the chat.
Because we added recall messages function in the app, so we use delete message function replace recall message, then we wanna delete message function just in sender app. if not, we can’t do it both
I’m still having trouble understanding the use case here. To me it sounds like you only want to hide/delete the message on the senders side, but not on the receivers side. From what I can grasp about your overall goals, deletion isn’t the answer because deletion would remove it from both sides. In terms of hiding messages, it doesn’t appear that you’ll be able to hide any messages without using one of the filters I mentioned earlier, and it seems like CustomTypeFilter
would be the most inline with what you’re trying to achieve.
Using CustomTypeFilter
would require some complex logic though since it will only show items in the prevMessageListQuery.customTypeFilter = []
. So you couldn’t add a custom ID to the message and then filter out that ID, you’d have to include every customType you have EXCEPT for the customType on this specific message.
Ultimately I don’t believe the functionality you require exists, yet.