WEBVTT

00:00.280 --> 00:01.640
For everyone.

00:01.680 --> 00:06.160
The last method will be mark seen messages.

00:06.920 --> 00:10.160
So I will show you how we can do that.

00:10.840 --> 00:17.400
I will create a method called Mark message.

00:17.440 --> 00:17.960
Message.

00:18.000 --> 00:18.440
Okay.

00:18.480 --> 00:19.640
For example like this.

00:21.800 --> 00:24.000
Right here we need the array.

00:24.760 --> 00:26.680
And we also need the current user.

00:29.960 --> 00:32.720
Okay I feel like we need to find the message right here.

00:37.160 --> 00:43.080
After we find the message we will create the variable.

00:45.200 --> 00:46.920
I will call already.

00:49.320 --> 00:49.720
The.

00:54.640 --> 00:55.560
Railways.

00:56.880 --> 00:59.200
I will look through the message right here.

00:59.480 --> 01:03.550
Not seen by dot sub Stop method.

01:04.870 --> 01:09.750
I will take a look at user log on screen.

01:10.670 --> 01:11.270
Okay.

01:18.110 --> 01:21.830
Equal with the current user underscore ID.

01:22.350 --> 01:22.830
Okay.

01:23.470 --> 01:31.750
If it becomes true, it means we already see the message and we not know anything if we haven't seen.

01:32.350 --> 01:33.030
We will check.

01:33.070 --> 01:37.550
If we haven't seen method.

01:37.750 --> 01:40.670
We will boost that into the object.

01:40.710 --> 01:41.230
Okay.

01:41.990 --> 01:43.750
Seen by and boost.

01:44.230 --> 01:47.990
Here I will boost that with.

01:50.310 --> 01:53.310
The user ID.

01:56.670 --> 01:57.510
And password.

01:57.550 --> 01:58.830
You saved us.

02:00.110 --> 02:00.710
Right here.

02:00.710 --> 02:06.700
We need to convert converse right here into the user document.

02:09.500 --> 02:15.860
So for that reason in this case we should inject the user.

02:16.500 --> 02:17.060
Okay.

02:17.900 --> 02:22.260
So inside the message module I will improve the user module.

02:23.740 --> 02:25.420
We already spoke last.

02:28.940 --> 02:32.140
Over user service.

02:34.060 --> 02:36.060
User service over here.

02:40.580 --> 02:41.900
And let's find us.

02:44.900 --> 02:48.980
Right here we will call user equal.

02:49.940 --> 02:58.740
Why this dot user service .51 and the current user dot over here.

03:01.260 --> 03:01.740
Okay.

03:01.780 --> 03:05.340
And the user over here okay.

03:05.700 --> 03:06.740
So let me summarize.

03:06.740 --> 03:07.290
rightfully.

03:07.650 --> 03:12.130
We need to check the current user already seen the message or not.

03:13.370 --> 03:19.890
If we haven't seen the message, we will seen that right?

03:20.610 --> 03:24.410
If we already seen, we will not do anything.

03:24.450 --> 03:27.650
Okay, that's the charm of this method.

03:28.210 --> 03:30.410
And let's create controllers.

03:33.130 --> 03:35.090
Let me copy over here.

03:36.250 --> 03:39.650
And this is the batch method right.

03:43.570 --> 03:46.730
Versus array and map.

03:46.970 --> 03:52.610
Same message array and current user.

03:55.970 --> 03:56.890
Something like that.

03:57.930 --> 03:59.010
And let's.

04:01.250 --> 04:01.850
React.

04:05.770 --> 04:06.650
Right now.

04:07.570 --> 04:10.200
I will start the conversion.

04:13.640 --> 04:14.520
Let me show you.

04:14.880 --> 04:15.520
Firstly.

04:18.760 --> 04:25.080
I will start a conversation between two accounts.

04:26.240 --> 04:28.200
You can see right here.

04:28.640 --> 04:30.240
These are the conversations.

04:32.200 --> 04:35.280
We have some user in here, right?

04:39.240 --> 04:40.240
Let me show you.

04:40.760 --> 04:42.600
Firstly I will sign in.

04:57.880 --> 05:01.880
With this account I will say okay.

05:07.440 --> 05:11.540
I will copy this token and I will.

05:14.140 --> 05:22.940
Go to now send message both over here and with the body.

05:23.420 --> 05:24.180
I will send.

05:24.180 --> 05:24.660
Hello.

05:25.100 --> 05:28.580
But before that, let me look inside the message.

05:28.580 --> 05:31.300
I will remove every message right here.

05:33.060 --> 05:34.700
Now let me remove everything.

05:40.660 --> 05:43.460
I want to build this from scratch.

05:46.620 --> 05:47.140
Okay.

05:47.460 --> 05:48.940
I will send this with this.

05:48.940 --> 05:51.740
Here is the conversation.

05:53.740 --> 05:55.500
Like a conversation ID?

06:00.460 --> 06:01.340
Exact.

06:02.660 --> 06:03.180
Okay.

06:03.420 --> 06:09.740
After we already send the message, I will sign in with ID for the account log one over here.

06:12.780 --> 06:13.340
Okay.

06:14.130 --> 06:14.690
say.

06:16.170 --> 06:20.810
And I want the John one right here.

06:21.290 --> 06:26.370
We will sing the message after John account.

06:26.850 --> 06:27.370
Right.

06:28.450 --> 06:30.450
If you got the message right here.

06:33.050 --> 06:34.650
You can say we have a message.

06:35.170 --> 06:37.490
Let's invite only the current user.

06:38.010 --> 06:38.570
Okay.

06:39.170 --> 06:40.370
Only the sender.

06:40.890 --> 06:42.210
I want it will boost.

06:42.250 --> 06:43.010
One more thing.

06:43.010 --> 06:46.290
By will be the account one into here.

06:46.770 --> 06:48.250
That's what I want to do, right?

06:48.770 --> 06:50.050
So what reason is this?

06:50.090 --> 06:53.010
Okay, go to the message.

06:53.050 --> 06:54.970
I will click duplicate.

06:59.090 --> 07:01.330
See message over here.

07:02.810 --> 07:07.330
And make sure we change slot same.

07:13.330 --> 07:15.960
And schedule match method.

07:17.160 --> 07:25.040
And lastly and I will update with the message are they right?

07:25.560 --> 07:28.120
I will copy the message array here.

07:29.840 --> 07:30.680
Moved over here.

07:32.480 --> 07:33.280
What are they.

07:33.760 --> 07:34.280
Okay.

07:34.760 --> 07:36.360
And remove the body.

07:36.600 --> 07:37.360
We don't want.

07:37.360 --> 07:39.640
This is the authentication.

07:39.640 --> 07:43.400
We should sign in with zone one account.

07:45.120 --> 07:45.480
I will.

07:48.000 --> 07:51.560
Click here and move the token and say.

07:52.560 --> 07:54.680
Now you can see we already have a success.

07:54.920 --> 07:56.040
Let me refresh.

08:04.600 --> 08:06.040
Now you can see the symbol.

08:06.080 --> 08:07.960
Here we have a two element.

08:08.200 --> 08:14.840
The first one will be the sender and the second one will be the current user already logged in.

08:15.080 --> 08:19.070
If I send one more time, I don't expect it will duplicate.

08:19.070 --> 08:19.510
Right.

08:28.310 --> 08:30.350
Over its duplicate.

08:30.870 --> 08:31.430
The reason?

08:31.430 --> 08:35.550
Because we already right allows it to check over here.

08:36.750 --> 08:45.990
Okay, so I hope you understand this logic and you may ask me when the front end will call that API.

08:46.030 --> 08:46.510
Okay.

08:47.110 --> 08:54.390
Well, we will call this API whenever the user clicks into the conversation okay.

08:54.870 --> 09:00.150
And maybe we will handle the scroll for example right here we will scroll.

09:00.590 --> 09:05.670
After we scroll we will apply the technique like debounce okay.

09:05.710 --> 09:14.230
Every we scroll we will mark all of that with the margin message over here okay.

09:14.270 --> 09:15.390
Not a job right?

09:15.830 --> 09:20.510
I hope you will understand this video and I will see you in.
