diff --git a/package-lock.json b/package-lock.json index 5646b11..ee5ab49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5854,7 +5854,8 @@ }, "safe-buffer": { "version": "5.1.1", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -5946,7 +5947,8 @@ }, "yallist": { "version": "3.0.2", - "bundled": true + "bundled": true, + "optional": true } } }, diff --git a/src/TopBar.js b/src/TopBar.js index e0b9372..312bd70 100644 --- a/src/TopBar.js +++ b/src/TopBar.js @@ -44,7 +44,7 @@ class TopBar extends Component {
{ - this.setState({ - VideoDetails: response.data.items[0], - isLoaded: true}); - }, error => { - console.error(error); - this.setState({ - isLoaded: true, - error + } + } + + componentDidMount() { + axios.get('https://www.googleapis.com/youtube/v3/videos', { + params: { + 'part': 'snippet,contentDetails,statistics,topicDetails', + 'id': this.state.videoId, + 'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig' + } + }).then(response => { + this.setState({ + VideoDetails: response.data.items[0], + isLoaded: true}); + }, error => { + console.error(error); + this.setState({ + isLoaded: true, + error + }); }); - }); - } + } - // componentWillReceiveProps(nextProps) { + // componentWillReceiveProps(nextProps) { - // } + // } - // shouldComponentUpdate(nextProps, nextState) { + // shouldComponentUpdate(nextProps, nextState) { - // } + // } - componentWillUpdate(nextProps, nextState) { - // console.info('nextProps',nextProps); - // console.info('nextState',nextState); - if(nextProps.match.params.id === this.state.videoId){} - else{ - this.setState({videoId: nextProps.match.params.id}); - + componentWillUpdate(nextProps, nextState) { + // console.info('nextProps',nextProps); + // console.info('nextState',nextState); + if(nextProps.match.params.id === this.state.videoId){} + else{ + this.setState({videoId: nextProps.match.params.id}); + + } + } + + componentDidUpdate(prevProps, prevState) { + console.info('prevProps',prevProps); + console.info('prevState',prevState); + } + + // componentWillUnmount() { + + // } + + render() { + const { error, isLoaded, VideoDetails } = this.state; + if (error) { + return ( + + Error: {error.message} -- Cannot get {error.config.url} + + ); + } else if (!isLoaded) { + return Loading...; + } else { + return ( + + + {/* codice per tabs reccomenders */} + + + + + +

{}

+
+ +

C

+
+
+ + +

2

+ +
+ ); + } } } - componentDidUpdate(prevProps, prevState) { - console.info('prevProps',prevProps); - console.info('prevState',prevState); - } + VideoInfo.propTypes = { - // componentWillUnmount() { + }; - // } - - render() { - const { error, isLoaded, VideoDetails } = this.state; - if (error) { - return ( - - Error: {error.message} -- Cannot get {error.config.url} - - ); - } else if (!isLoaded) { - return Loading...; - } else { - return ( - - - {/* codice per tabs reccomenders */} - - - - - -

B

-
- -

C

-
-
- - -

2

- -
- ); - } - } -} - -VideoInfo.propTypes = { - -}; - -export default VideoInfo; \ No newline at end of file + export default VideoInfo; \ No newline at end of file diff --git a/src/VideoList.js b/src/VideoList.js index eb285cf..c098398 100644 --- a/src/VideoList.js +++ b/src/VideoList.js @@ -125,18 +125,25 @@ class VideoList extends React.Component { {items.map(item => ( - + {/* {item.artist} - {item.title} {item.videoID} {item.category} */} {item.artist} - {item.title} +

{item.category}

- ))} + ))} ); } diff --git a/src/VideoPlayer.js b/src/VideoPlayer.js index 0601ce7..8c5eb00 100644 --- a/src/VideoPlayer.js +++ b/src/VideoPlayer.js @@ -27,7 +27,7 @@ class VideoPlayer extends Component { } - componentDidMount(){ + componentWillMount(){ if(this.props.match.params.id) this.setState((state, props) => { return { videoId: props.match.params.id }}); @@ -70,7 +70,7 @@ class VideoPlayer extends Component { // console.warn(event.target.getDuration()); } _onStateChange(event) { - // console.info('statechange: ', event) + // console.info('statechange: ', event.data) } } diff --git a/src/areainfo/Wikipedia.js b/src/areainfo/Wikipedia.js index 4ce1e04..b0b47f6 100644 --- a/src/areainfo/Wikipedia.js +++ b/src/areainfo/Wikipedia.js @@ -12,29 +12,36 @@ class Wikipedia extends Component { isLoaded: false }; this.getWikiBox = this.getWikiBox.bind(this); +this.raffina = this.raffina.bind(this); } getWikiBox(name){ wikijs() .page(name) .then(page => page.fullInfo()) - .then(infobox => console.log(infobox) + .then(infobox => console.log('infobox', infobox) //this.setState({ infobox }) ); //console.log('infobox', this.state.infobox) } + raffina(results){ + console.log('raffina',results); + return results[0]; + } + // componentWillMount() { // } - componentDidMount() { - wikijs().search(this.props.query).then(data => { + componentWillMount() { + wikijs().find(this.props.query, this.raffina).then(data => { this.setState({ data, isLoaded: true }); - console.log(data); + console.log(data.html()); + //this.getWikiBox(data.results[0]); }, error => { console.error(error); this.setState({ @@ -77,7 +84,7 @@ this.getWikiBox = this.getWikiBox.bind(this); } else { return (
-

risultato ricerca wikipedia: { data.results[0] }

+ {/*

risultato ricerca wikipedia: { data.results[0] }

*/}
); }