For everyone.
The last method will be mark seen messages.
So I will show you how we can do that.
I will create a method called Mark message.
Message.
Okay.
For example like this.
Right here we need the array.
And we also need the current user.
Okay I feel like we need to find the message right here.
After we find the message we will create the variable.
I will call already.
The.
Railways.
I will look through the message right here.
Not seen by dot sub Stop method.
I will take a look at user log on screen.
Okay.
Equal with the current user underscore ID.
Okay.
If it becomes true, it means we already see the message and we not know anything if we haven't seen.
We will check.
If we haven't seen method.
We will boost that into the object.
Okay.
Seen by and boost.
Here I will boost that with.
The user ID.
And password.
You saved us.
Right here.
We need to convert converse right here into the user document.
So for that reason in this case we should inject the user.
Okay.
So inside the message module I will improve the user module.
We already spoke last.
Over user service.
User service over here.
And let's find us.
Right here we will call user equal.
Why this dot user service .51 and the current user dot over here.
Okay.
And the user over here okay.
So let me summarize.
rightfully.
We need to check the current user already seen the message or not.
If we haven't seen the message, we will seen that right?
If we already seen, we will not do anything.
Okay, that's the charm of this method.
And let's create controllers.
Let me copy over here.
And this is the batch method right.
Versus array and map.
Same message array and current user.
Something like that.
And let's.
React.
Right now.
I will start the conversion.
Let me show you.
Firstly.
I will start a conversation between two accounts.
You can see right here.
These are the conversations.
We have some user in here, right?
Let me show you.
Firstly I will sign in.
With this account I will say okay.
I will copy this token and I will.
Go to now send message both over here and with the body.
I will send.
Hello.
But before that, let me look inside the message.
I will remove every message right here.
Now let me remove everything.
I want to build this from scratch.
Okay.
I will send this with this.
Here is the conversation.
Like a conversation ID?
Exact.
Okay.
After we already send the message, I will sign in with ID for the account log one over here.
Okay.
say.
And I want the John one right here.
We will sing the message after John account.
Right.
If you got the message right here.
You can say we have a message.
Let's invite only the current user.
Okay.
Only the sender.
I want it will boost.
One more thing.
By will be the account one into here.
That's what I want to do, right?
So what reason is this?
Okay, go to the message.
I will click duplicate.
See message over here.
And make sure we change slot same.
And schedule match method.
And lastly and I will update with the message are they right?
I will copy the message array here.
Moved over here.
What are they.
Okay.
And remove the body.
We don't want.
This is the authentication.
We should sign in with zone one account.
I will.
Click here and move the token and say.
Now you can see we already have a success.
Let me refresh.
Now you can see the symbol.
Here we have a two element.
The first one will be the sender and the second one will be the current user already logged in.
If I send one more time, I don't expect it will duplicate.
Right.
Over its duplicate.
The reason?
Because we already right allows it to check over here.
Okay, so I hope you understand this logic and you may ask me when the front end will call that API.
Okay.
Well, we will call this API whenever the user clicks into the conversation okay.
And maybe we will handle the scroll for example right here we will scroll.
After we scroll we will apply the technique like debounce okay.
Every we scroll we will mark all of that with the margin message over here okay.
Not a job right?
I hope you will understand this video and I will see you in.