So here I would like to have a feature that activates only once a day, I explain, for example, I would like that we can pressing a button “sent a heart” on the profile of another user but we can not click at infinity! That is, we can send a heart once a day!
hello, it is easy, you have to make some date variable:
public HeartClickDate: Date;
and let’s say clicking on heart triggers event like this one:
heartClick(){
if(this.HeartClickDate != null &&
HeartClickDate.getYear() != new Date().getYear() &&
HeartClickDate.getMonth() != new Date().getMonth() &&
HeartClickDate.getDate() != new Date().getDate())
{
//here goes some function that makes the heart clicked
this.HeartClickDate = new Date();
}
}
or you can disable this heart button using similiar logic but with [disabled] flag on button