So in this video we will write the logic to update the reaction count.
But before that, let me test this guy.
Okay.
For example, if I send with the light one more time, another one, it will create the light.
Okay I want it will give light normal.
Reactions okay.
We will not create one more thing.
It would.
And let me try to update if we have a new reaction.
Say and let me refresh.
Okay.
It's already changed.
So that is his early work.
And right now we need to update the reaction.
So how we can do that?
Well, what we need to know right now, we need to somehow decrease.
Decrease the count or increase the count inside the schema over here.
Right inside the schema over here.
Okay.
So how to do that.
And now let's think a little bit when we will decrease the count.
Well we will decrease the count if it goes to this guy.
Right.
If we update the new reaction.
Now for example right here we have a object.
Possibly like one.
One one.
One zero.
Okay.
Furthermore, we have some stuff like that.
First of all, we have some stuff like that.
The lines right here will be one.
Right?
When we update with a new reaction I want it will decrease the curve right here and increase the curve
right here, right now the mean of the sacred cow and increase the cow.
So let's write it into that here to the sacred cow.
Now you can say right here, in order to decrease the cow, we need to find the old the old reaction
times.
Right.
So in this guide I will create one more variable called also as all reaction.
Part will be no.
And if we update right here, we will run it with the existing reaction time.
And right here we need to add a little bit of script to screen.
Uh no.
Uh let me say okay.
Now after we already have our all reaction type, we need to recreate as.
Well, in order to this screencast we need to find the boss also.
Okay.
With the boss.
Well, let's try this.
Uh.
Right here.
We already have A51 method, which we can reuse that.
Put the five one and both three.
And right here, right here, we can, uh, we can check the.
Over here.
Okay.
Provide us.
Okay.
We need to throw the error in here.
I don't want to throw the error in here.
It will increase the code base of the function.
I don't want that.
So after we already got the boss.
We need to.
Close.
Okay.
From the boss dot projection.
Right?
This is the map.
And we will use this create account.
Reaction count dot set with the case.
The case right here will be the tie.
Right where the tie.
The tie.
It closes this case right.
So we need to call the operation tie from Here.
And the value.
Well, what's the value?
We need to get the current value and minus one.
Right.
So right here I need to get the current value.
Current reaction.
How value.
Railways.
Reaction Kyle.
Dot get.
We need to look the case.
Right.
Over here.
Uh.
Right here.
It can be known for a reason.
We need to write a logic a little bit.
If the our reaction time, we will boost it.
K?
Mm.
Ah.
Reason?
Because we need to use AI.
Reaction time over here is much better.
I think I will call this here directly the value.
Right.
And we need to use the value over here minus one okay.
Now let me summarize.
If we find the overall reaction time we will get the value of plus and minus one okay.
That is.
And after that we need to increase with the increase.
We don't need to check that because we will disagree and we need to increase at the same time.
Right.
So for that reason in this case we will.
You must somehow undervalue him.
Right here.
I think I will use the zero.
But if if we have a some problem, it means zero right here will be somehow minus one.
Okay, that's not what we want on.
For that reason, we need to check a little bit over here.
Value minus one.
Keep the value minus one.
Uh.
Greater than or equal to zero.
We will.
Uh.
You does.
If not, we will put zero right here to make sure it's bit on why the zero will be the minimum value.
Okay.
And increase the count.
We waste something like that.
We have some count set right here.
We will set with the new.
The new tie.
Right.
Will be the tie right here.
And the value we define the value.
Plus one.
Okay.
So that is.
And after that we need to save into the database.
Right.
We will split this thing.
Too.
We already perform the action Directly over here.
I think we should override.
Okay.
We override equal.
And we will say goodbye.
Okay.
Let me go to the database and I will remove.
Okay.
Make sure we remove that.
If not, if we will.
Inconsistency.
Now let me add reactions.
Success.
Refresh.
Halfway over here.
And click inside the box.
Uh, the ration card, click here.
Okay.
We already got with the hubby will be, uh, one.
Very, very good.
Let me change.
Let me click one more time to make sure it will not somehow.
Increase.
Okay.
It's the one.
The reason.
Because we already return immediately over here.
Okay, now let's remove us to like.
Let's refresh.
Okay.
The hubby already become a zero and the like we will increase by one.
And so the reaction's.
Over with the like.
So that is just how we can add the reaction into the box, right?
And for sure in later when we get on a box we want will return the the count.
Right.
I will leave that aside for you.
Okay.
Let's return the object reaction count right here in the UI.
So I will do that in the next video.
I hope you understand this video.
Okay, so if not, let's take a closer look at the logic.
I already commented in very detail and explain the detail also, right?
So I hope you very clear.
I will see you in the next one.