getstream.io - How do I set the Channel.Config to disable reactions? - getstream-io

Im using the iOS SDK and I would like to turn off reactions for my users in chat.
In my subclass of ChatViewController I have overridden defaultMessageActions:
override var defaultMessageActions: ChatViewController.MessageAction {
return [.delete, .copy, .flagMessage, .flagUser]
}
However, when a user taps on a message cell, the reaction window still pops up. I found where there is happening in ChatViewController+Cells.swift:
if let presenter = presenter, presenter.channel.config.reactionsEnabled {
showReactions(from: cell, in: message, locationInView: tapGesture.location(in: cell))
}
reactionsEnabled is true here and so the reactions view is popping up. I tried to find a away to set Channel.Config.reactionsEnabled to false, but had no success.
How do I set reactionsEnabled to false? Any help would be appreciated.

The correct way to disable reactions is to go to your Stream Chat dashboard, select the channel types you don't want reactions enabled for, disable it and save. After that, the reactions UI will not be displayed.
Disabling just from client-side like you were trying to do is not supported with the provided UI components.

Related

Discord.js collector collects button interaction 2 times when I run the same command twice?

I am currently working on a /inventory command, the way it works is that the user does /inventory and I saved that user.id with the page they are on { user.id: page } and based on that generate the page. The way you move from page to page is with buttons and collectors, but my problem is that when the same user does /inventory twice so that there is 2 inventory embeds both with the exact same buttons whenever the user presses one button, the code checks if I am the user who did the /inventory commands (so true) and what customId the button has (both embeds have the same button customId). Due to this both inv embeds are updated and I get an error "Interaction has already been acknowledged."
Is there anyway to differentiate which button has been pressed to update the corresponding embed correctly?
Since there is no actual bug with the code I am not posting the code here, if you need the code just ask. I just want to know what I should do to avoid this.
I encountered a similar issue right now. You should create your collector on a message instead of a channel. You can use fetchReply: true on your reply() method to fetch a message and then use it to call createMessageComponentCollector() method from it.
I know this question is 4 months old, but maybe it'll help someone anyway.
The best way to do this is to create your collector on the message you want to send.
// For example:
const MSG = await message.channel.send({embeds: [yourEmbed]});
const collector = await MSG.createMessageComponentCollector({ filter, idle: 20000 });
Another way to solve this is to create a random ID for your buttons. Like this:
const randomID = Math.floor(100000 + Math.random() * 900000);
const button = new MessageButton()
.setCustomId(`button${randomID}`)
.setLabel('Just a button')
.setStyle('PRIMARY')
There is still a small possibility of getting the same ID on two interactions, but it's really low. You can also create longer IDs to lower the chances even further.
And lastly, another way would be to prevent the user from using the command again while your inventory command is active. This would be achievable by creating a
Map and when the user triggers the command you add user's ID and the command's name.
After the collector ends or the command is stopped you can clear the Map.

How to stop QnAMaker dialog from returning to parent dialog?

Trying to understand MS Bot Framework and build my first bot.
The default dialog is a Prompts.choice. First choice passes to new dialog that asks for Prompts.text.
User enters text which then passes that to my QnAMaker, which looks for the answer and returns it. This works as expected.
After answer is returned, my bot closes the QnAMaker dialog and then returns to the default dialog where the bot starts over from the beginning. I don't want this to happen.
How do I keep the user in the QnAMaker dialog so that they can continually ask QNAMaker questions until they are done and want to do something else in the bot?
Screenshot of terminal output. Code below. Thanks!
bot.dialog('rentalHelp', [
function(session) {
builder.Prompts.text(session, "In which state do you live? (please spell out)");
},
function(session, results) {
// start the QnA bot dialog
session.beginDialog('QnAMaker');
}
]);
I think I figured out the reason it was doing this from Bot SDK chat reference library
Excerpt:
note: Waterfalls have a hidden last step which will automatically end the current dialog if if you call a prompt or dialog from the last step. This is useful where you have a deep stack of dialogs and want a call to session.endDialog() from the last child on the stack to end the entire stack. The close of the last child will trigger all of its parents to move to this hidden step which will cascade the close all the way up the stack. This is typically a desired behavior but if you want to avoid it or stop it somewhere in the middle you'll need to add a step to the end of your waterfall that either does nothing or calls something like session.send() which isn't going to advance the waterfall forward.
It would be great if someone could confirm this is the problem or help me to improve my code.

XPages: possible bug with enableModifiedFlag in Release 9.0.1FP3 HF241, and workaround

I have a page where I wanted to use the "enableModifiedFlag" property, to let users know that their edit was not saved if they want to leave a page before saving.
I also have a search box in that page, and when I set the field to the static value "true", the message was popping because the search box was considered part of the page, and the field was modified. This all makes sense.
Since the "enableModifiedFlag" property can be computed, I decieded to set it to true only if the document was in edit mode, as the search box is not available at that time. The behaviour I got was that the message was not appearing anymore. I then tested with returning true as the value of the property, and it didn't change anything: the message was just gone. I then used the static values and set it to true, and the message was then appearing.
My conclusion is that there is a bug that prevents any computed value to be considered for that property.
So I had to find a workaround to prevent the message from popping up when users used the serach box. Here is the solution I came up with.
On the client side, we have access to the XSP object. One of its method is XSP._setDirty(). you can either set it to true or false, and it will affect if the page diplays the popup message or not. So in my search button, I added this code on the onclick event, on the client side:
XSP._setDirty(false,""); //so we don't get the "do you want to leave this page" message
showStandBy(); //show standby in case search is long or slow
return true;
That way, I tell my page not to show the message and the popup is not displayed.
It's still a shame you can't use the computed value for that property, but at least we have a workaround. Hope this will be useful to somebody!!!
GOT SOMETHING WORKING I THINK
This is what I have now, that controls teh flag:
<xp:this.enableModifiedFlag><![CDATA[${javascript:context.getUrlParameter("action")=="editDocument";}]]></xp:this.enableModifiedFlag>
I would rather use the document1.isEditable() function, but I wasn't successful with it so far, neither computed dynamically nor on page load.
At leaset I have something that seems to be working. Time to submit that code to the end users!

MonoTouch: How to update a view [duplicate]

I have a problem that the ViewWillAppear method for a UIView does not fire when the application returns from the background. This is a problem, as my main application screen is showing values that are retrieved from the user settings, and if the user has changed these while the application was in the background I need to have the screen refreshed. I have read that one should register for the UIApplicationWillEnterForegroundNotification using NSNotificationCenter.
How do you do this in MonoTouch? Or does anyone know an alternate way of ensuring that the screen is always kept up to date, even when returning from the background?
You could try something along the lines of:
//Register for the notification somewhere in the app
NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.WillEnterForegroundNotification, EnteredForeground);
//snip
void EnteredForeground (NSNotification notification)
{
// do your stuff here
}
Bear in mind you would need to do this for every view controller you'd like to update when enterting from the background!

How do I send a custom error message to the client a Telerik MVC Grid Ajax Insert/Update/Delete?

I am working with Ajax Editing within a Telerik Grid extension. I would like to handle errors/exceptions on Insert/Update/Delete and display a user friendly message in the message box that is displayed back to the client, instead of the default message of "Error! The requested URL returned 500 - Internal Server Error" or the like.
Is there a way to tell the grid to display a custom text message?
Someone customized the alert here: http://www.telerik.com/community/forums/aspnet-mvc/grid/how-to-return-error-information-to-grid-in-ajax-editing-mode.aspx, but I'm still searching for a way to actually update the grid itself...
There's a little hope in the client-side grid's noRecordsTemplate property, but we still need a way to clear the grid of any records that may have already been there.
Edit:
Found it: To clear the grid, and set your message, do the following:
var grid = $('#Grid').data('tGrid');
grid.total = 0;
grid.dataBind(Array());
$('#Grid').find('.t-no-data td').text('My Custom Error Message');
Of course, you can figure out on your own how to combine the my example and the example from the link above.

Resources