Archived
Recenti messi in ordine di data (funzione su videoplayer)
This commit is contained in:
@@ -107,6 +107,9 @@ class VideoPlayer extends React.Component {
|
|||||||
tmp[j].timesWatched++;
|
tmp[j].timesWatched++;
|
||||||
tmp[j].lastWatched= new Date();
|
tmp[j].lastWatched= new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tmp.sort((a, b) => new Date(b.lastWatched).getTime() - new Date(a.lastWatched).getTime());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
localStorage.setItem('lastWatched', JSON.stringify(tmp));
|
localStorage.setItem('lastWatched', JSON.stringify(tmp));
|
||||||
|
|||||||
@@ -29,7 +29,17 @@ class Recent extends React.Component {
|
|||||||
// response => {
|
// response => {
|
||||||
// //this.shuffleArray(response.data);
|
// //this.shuffleArray(response.data);
|
||||||
// console.info ('a',response.data);
|
// console.info ('a',response.data);
|
||||||
|
// let lastWatchedList = JSON.parse(localStorage.getItem('lastWatched')).map(x =>x.lastWatched)
|
||||||
|
// lastWatchedList.sort((a,b)=> new Date(b.lastWatched).getTime() - new Date(a.lastWatched).getTime());
|
||||||
|
|
||||||
this.getThumbnailsNames(JSON.parse(localStorage.getItem('lastWatched')));
|
this.getThumbnailsNames(JSON.parse(localStorage.getItem('lastWatched')));
|
||||||
|
|
||||||
|
|
||||||
|
// let now = moment(new Date()); // riferimento unico temporale
|
||||||
|
// let timePast = lastWatchedList.map(item => now.diff(item)) // differenza in secondi tra adesso e lastWatched
|
||||||
|
//console.info(lastWatchedList, timePast.sort((a, b) => a - b))
|
||||||
|
|
||||||
|
|
||||||
// console.info(response.data.recommended);
|
// console.info(response.data.recommended);
|
||||||
// // this.setState({
|
// // this.setState({
|
||||||
// // isLoaded: true,
|
// // isLoaded: true,
|
||||||
@@ -95,7 +105,6 @@ class Recent extends React.Component {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const recentVideoList = JSON.parse(localStorage.getItem('lastWatched'))
|
|
||||||
const { error, isLoaded, items } = this.state;
|
const { error, isLoaded, items } = this.state;
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Col, Card } from 'react-bootstrap'; // eslint-disable-line no-unused-va
|
|||||||
import axios from 'axios'; // eslint-disable-line no-unused-vars
|
import axios from 'axios'; // eslint-disable-line no-unused-vars
|
||||||
import { Link } from 'react-router-dom'; // eslint-disable-line no-unused-vars
|
import { Link } from 'react-router-dom'; // eslint-disable-line no-unused-vars
|
||||||
/*eslint no-console: ["error", { allow: ["warn", "error", "info"] }] */
|
/*eslint no-console: ["error", { allow: ["warn", "error", "info"] }] */
|
||||||
import moment from "moment";
|
|
||||||
|
|
||||||
class fvitali extends React.Component {
|
class fvitali extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
|
|||||||
Reference in New Issue
Block a user