-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPodcast.js
More file actions
82 lines (64 loc) · 2.32 KB
/
Podcast.js
File metadata and controls
82 lines (64 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import React, {Component} from "react";
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import Episode from "../Components/Episode";
import Loading from "../../Common/Components/Loading"
import YearSelector from '../../components/YearSelector.js'
import Container from '../../Layout/Components/Container/Container';
import Content from '../../Layout/Components/Content/Content';
import SideBar from '../../Layout/Components/SideBar/SideBar';
import {get_podcasts} from '../../utils/redux_loader'
import {year_from_path} from '../../utils/redux_loader'
import {changePageTitle} from '../../Layout/Actions/LayoutActions';
class Podcast extends Component {
constructor(props) {
super(props)
}
componentDidMount() {
const dispatch = this.props.dispatch;
const {isLoaded} = this.props;
const pathname = this.props.location.pathname;
get_podcasts(dispatch, pathname);
const {title} = Podcast.getPageMeta();
dispatch(changePageTitle(title));
}
static getPageMeta() {
return {
title: `Podcasts | Data Skeptic`
}
}
render() {
const pathname = this.props.location.pathname;
const {list = [], years = [], isLoaded = false} = this.props;
let year = year_from_path(pathname);
if (year === -1) {
year = years[0]
}
return (
<div className="podcasts-page">
<Container>
<Content>
{ !isLoaded ?
<div className="loading-area"><Loading/></div>
:
list.map(function (episode, index) {
return <Episode key={index} episode={episode}/>
})
}
</Content>
<SideBar title="Year">
<YearSelector years={years} year={year}/>
</SideBar>
</Container>
</div>
)
}
}
export default connect(
state => ({
eps: state.episodes.toJS(),
list: state.episodes.getIn(['episodes']).toJS(),
years: state.episodes.getIn(['years']).toJS(),
isLoaded: state.episodes.getIn(['loaded'])
})
)(Podcast)