Welcome back, ladies and gentlemen, and let's do the final part of this project, so our final will
be like so when whenever we like a movie and after that we can dislike that movie, we can remove that
flag and stuff like that.
No, we have after this one or two lectures, saving, storing something in the local storage.
And pretty much we are done now.
Congratulations if you're about to hear your Golden True-Blue now, first things first.
I want Indy views.
Actually, let's start with a model not being used.
We never started with a view, so I'm going to say it like that.
Jazz and same as the cards here.
We're going to do something similar.
Right?
So I'm not going to copy and paste this one here because they are very much alike.
But let's create it together now.
First things first.
I want to export default class.
Like by now, you know how to do this, right?
And inside I will have the constructor that will be empty and these that likes it will be like this.
Right.
So we will create these that likes area that will set back to empty whenever we create or we call this
one from the index from the main controller.
Right.
And that will go here and we'll say, OK, yeah, we don't have anything, no parameters to parse.
We're just going to create an object for from that class.
Nice.
The second thing that we need to do is actually we seem to add like a movie.
Right.
So here I have the idea, the poster.
What else?
I will have the title The Year.
Now you can include as much as many things, but I.
I don't think so for this is more this is more than enough for this course is more than enough to include
all of this.
Now inside I will create an object called like and remember last time we just call those things in the
poster without setting the dates right.
Tyto
here in the last one was I am DBI really cool.
Now semicolon on that one.
So let's continue working.
So but we need actually to push this like back to the like stage so we're not finished quite yet.
OK, now how we do this, these, that likes that push, we've got to push this like the same as we
did with item for the car.
We're going to push this like here.
And after that we need to return the leg.
Nice.
So we are done with this.
Add like now the second thing that it will be for delete delete like a movie in here we need to pass
the ID remember.
So it's a pretty much complete list scene const.
So I'm just going to be or go through this because you already know this, these that likes.
So I'm calling the the, the error here and I'm using the find index.
So what this will do, it will loop through all of them.
It will fine.
So I have the access to the current element and if I say current idee is equal to the ID.
Nice.
Last time we just made a huge mistake here.
I had one.
Only one equals sign.
Right.
So it will find and it will store the current index here now this that likes that spliffs.
So we're going to use against list in.
You already know that we need to pass the index in how many positions.
Actually I want only that to be deleted right now.
That's pretty much it.
Now what's next.
OK, let's create no.
So last time I promise you that I'm going to have show likes before what show list.
And now it will be show likes.
And now here what we can do is actually return this that likes the entire one or we can return the length.
Right.
But for the length I'm going to create additional function and that will be number of likes in here.
I will say this, that likes that length.
Nice.
So I have two functions.
Maybe for some reason you want the entire array.
That's why I'm just leaving over there.
It's not going to kill me if I tried to create another function.
OK, that's pretty much it.
No, no, no, it's not pretty much.
We need to just check to do one additional function.
And that will actually check the movie like status now, life status, so these will be super useful.
But here we need to pass in the idea as well and it will return to the false right.
But you will see something interesting here.
So these not like and I'm going to search for to find the index.
Right.
And I'm going to do the exactly same like like exactly like this.
But look what I will do now if this is different than minus one.
Right.
So means that if you couldn't find any of the index I'm searching for that it will return minus one
and minus one is false.
So true.
There always it's like that.
So that will return me instead of passing here.
False, I can just pass minus one.
If I pass one it will return.
True.
But this will never go here actually if this finds it right.
So you will see what I'm trying to say here.
Now that is pretty much it for this picture.
So that was super short.
And I promise that I'm going to do a separate lecture for models, views, controllers.
Sometimes it's not possible, but this is the time when it's possible.
So I just want to make this super short and I will see you in the next one where we are going to build
the likes of you.