Compare commits
No commits in common. "master" and "user-votes" have entirely different histories.
master
...
user-votes
@ -1,10 +1,12 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {connect} from 'react-redux'
|
import {connect} from 'react-redux'
|
||||||
import { Navbar, Nav, NavDropdown, FormControl, Form, Button } from 'react-bootstrap'
|
import { Navbar, Nav, NavDropdown, FormControl, Form, Button } from 'react-bootstrap'
|
||||||
|
import {LinkContainer} from 'react-router-bootstrap'
|
||||||
import {NavLink} from 'react-router-dom'
|
import {NavLink} from 'react-router-dom'
|
||||||
|
|
||||||
const MainNav = (props) => {
|
const MainNav = (props) => {
|
||||||
const { episodes } = props
|
const {episodes, captions} = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Navbar bg="dark" variant="dark" expand="lg">
|
<Navbar bg="dark" variant="dark" expand="lg">
|
||||||
<Navbar.Brand href="/">Anarchy Planet</Navbar.Brand>
|
<Navbar.Brand href="/">Anarchy Planet</Navbar.Brand>
|
||||||
@ -18,7 +20,7 @@ const MainNav = (props) => {
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
)}
|
)}
|
||||||
</NavDropdown>
|
</NavDropdown>
|
||||||
<NavLink className="navbar-nav" to="/audio">Player</NavLink>
|
<Nav.Link href="/audio">Player</Nav.Link>
|
||||||
</Nav>
|
</Nav>
|
||||||
|
|
||||||
<Form inline>
|
<Form inline>
|
||||||
|
@ -2,15 +2,6 @@ import React from 'react'
|
|||||||
import CommentRow from './CommentRow'
|
import CommentRow from './CommentRow'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { ListGroup } from 'react-bootstrap'
|
import { ListGroup } from 'react-bootstrap'
|
||||||
const sum = (a,b) => a + b
|
|
||||||
|
|
||||||
const sumVotes = voteArray => {
|
|
||||||
if(voteArray.length===0) return 0
|
|
||||||
if(voteArray.length===1) return voteArray[0].upvote===1 ? 1 : -1
|
|
||||||
const upvotes = voteArray.map(vote=>+vote.upvote).reduce(sum)
|
|
||||||
const downvotes = voteArray.map(vote=>+vote.downvote).reduce(sum)
|
|
||||||
return upvotes - downvotes
|
|
||||||
}
|
|
||||||
|
|
||||||
const CommentList = props => {
|
const CommentList = props => {
|
||||||
|
|
||||||
@ -21,7 +12,6 @@ const CommentList = props => {
|
|||||||
key={comment.id}
|
key={comment.id}
|
||||||
userId={props.user.id}
|
userId={props.user.id}
|
||||||
userVote={props.votes.find(vote=>vote.commentId===comment.id && vote.userId===props.user.id)}
|
userVote={props.votes.find(vote=>vote.commentId===comment.id && vote.userId===props.user.id)}
|
||||||
voteSum={sumVotes(props.votes.filter(vote=>vote.commentId===comment.id))}
|
|
||||||
updateSongPos={props.updateSongPos}
|
updateSongPos={props.updateSongPos}
|
||||||
comment={comment}
|
comment={comment}
|
||||||
/>
|
/>
|
||||||
|
@ -1,7 +1,40 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Row, Col, Media } from 'react-bootstrap'
|
import { Row, Col, Media } from 'react-bootstrap'
|
||||||
import CommentVotes from './CommentVotes'
|
import CommentVotes from './CommentVotes'
|
||||||
import parseTime from './parseTime'
|
|
||||||
|
const parseTime = secs => {
|
||||||
|
var hours = Math.floor(secs / 3600)
|
||||||
|
var minutes = Math.floor((secs - hours * 3600) / 60)
|
||||||
|
var seconds = secs - hours * 3600 - minutes * 60
|
||||||
|
|
||||||
|
if (hours < 10) {
|
||||||
|
hours = '0' + hours
|
||||||
|
}
|
||||||
|
if (minutes < 10) {
|
||||||
|
minutes = '0' + minutes
|
||||||
|
}
|
||||||
|
if (seconds < 10) {
|
||||||
|
seconds = '0' + seconds
|
||||||
|
}
|
||||||
|
return minutes + ':' + seconds
|
||||||
|
}
|
||||||
|
|
||||||
|
// const toggleVote = (vote) => {
|
||||||
|
// const userVote = this.props.user.votes.find(vote=>vote.commentId===this.props.id)
|
||||||
|
// userVote.upvote = vote === 'up' ? (userVote.upvote === 1 ? 0 : 1) : 0
|
||||||
|
// userVote.downvote = vote === 'down' ? (userVote.downvote === 1 ? 0 : 1) : 0
|
||||||
|
// const sendThisToBackend = {
|
||||||
|
// userId: this.props.user.id,
|
||||||
|
// commentId: this.props.id,
|
||||||
|
// userUpvote: userVote.upvote,
|
||||||
|
// userDownvote: userVote.downvote,
|
||||||
|
// prevUpvote: userVote.upvote,
|
||||||
|
// prevDownvote: userVote.downvote
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// this.props.saveVote(sendThisToBackend)
|
||||||
|
// }
|
||||||
|
|
||||||
const CommentRow = props => {
|
const CommentRow = props => {
|
||||||
console.log(props)
|
console.log(props)
|
||||||
|
|
||||||
@ -15,21 +48,30 @@ const CommentRow = props => {
|
|||||||
<a href="#" onClick={() => props.updateSongPos(props.comment.secs)}>
|
<a href="#" onClick={() => props.updateSongPos(props.comment.secs)}>
|
||||||
{parseTime(props.comment.secs)}
|
{parseTime(props.comment.secs)}
|
||||||
</a>
|
</a>
|
||||||
<Row>
|
|
||||||
<Col>{props.comment.text}</Col>
|
|
||||||
</Row>
|
|
||||||
</Col>
|
</Col>
|
||||||
<CommentVotes
|
<CommentVotes
|
||||||
commentId={props.comment.id}
|
commentId={props.comment.id}
|
||||||
userId={props.userId}
|
userId={props.userId}
|
||||||
userVote={props.userVote}
|
userVote={props.userVote}
|
||||||
voteSum={props.voteSum}
|
|
||||||
/>
|
/>
|
||||||
</Row>
|
</Row>
|
||||||
|
<Row>
|
||||||
|
<Col>{props.comment.text}</Col>
|
||||||
|
</Row>
|
||||||
</Media.Body>
|
</Media.Body>
|
||||||
</Media>
|
</Media>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// const mapState = state => {
|
||||||
|
// return {
|
||||||
|
// user: state.user
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// const mapDispatch = dispatch => {
|
||||||
|
// return {
|
||||||
|
// saveVote: vote => dispatch(addVote(vote))
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//export default connect(mapState)(CommentRow)
|
||||||
export default CommentRow
|
export default CommentRow
|
||||||
|
@ -4,8 +4,8 @@ import { connect } from 'react-redux'
|
|||||||
import { destroyVote, updateVote, addUpvote, addDownvote } from '../../store'
|
import { destroyVote, updateVote, addUpvote, addDownvote } from '../../store'
|
||||||
|
|
||||||
const CommentVotes = props => {
|
const CommentVotes = props => {
|
||||||
const {commentId, userId, voteSum, userVote} = props
|
const {commentId, userId, userVote} = props
|
||||||
console.log('COMMENT VOTES!!!!!', props)
|
|
||||||
const upvote = () => {
|
const upvote = () => {
|
||||||
console.log('userVote',userVote)
|
console.log('userVote',userVote)
|
||||||
userVote
|
userVote
|
||||||
@ -39,11 +39,6 @@ const CommentVotes = props => {
|
|||||||
</a>
|
</a>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
|
||||||
<Col>
|
|
||||||
{voteSum}
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col>
|
<Col>
|
||||||
<a
|
<a
|
||||||
@ -58,7 +53,6 @@ const CommentVotes = props => {
|
|||||||
</a>
|
</a>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
</Col>
|
</Col>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
export default secs => {
|
|
||||||
var hours = Math.floor(secs / 3600)
|
|
||||||
var minutes = Math.floor((secs - hours * 3600) / 60)
|
|
||||||
var seconds = secs - hours * 3600 - minutes * 60
|
|
||||||
|
|
||||||
if (hours < 10) {
|
|
||||||
hours = '0' + hours
|
|
||||||
}
|
|
||||||
if (minutes < 10) {
|
|
||||||
minutes = '0' + minutes
|
|
||||||
}
|
|
||||||
if (seconds < 10) {
|
|
||||||
seconds = '0' + seconds
|
|
||||||
}
|
|
||||||
return minutes + ':' + seconds
|
|
||||||
}
|
|
@ -2,8 +2,6 @@ const createHistory = require('history').createBrowserHistory
|
|||||||
const createMemoryHistory = require('history').createMemoryHistory
|
const createMemoryHistory = require('history').createMemoryHistory
|
||||||
|
|
||||||
const history =
|
const history =
|
||||||
process.env.NODE_ENV === 'test'
|
process.env.NODE_ENV === 'test' ? createMemoryHistory() : createHistory()
|
||||||
? createMemoryHistory()
|
|
||||||
: createHistory()
|
|
||||||
|
|
||||||
export default history
|
export default history
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import ReactDOM from 'react-dom'
|
import ReactDOM from 'react-dom'
|
||||||
import {Provider} from 'react-redux'
|
import {Provider} from 'react-redux'
|
||||||
import { BrowserRouter as Router } from 'react-router-dom'
|
import {Router} from 'react-router-dom'
|
||||||
import history from './history'
|
import history from './history'
|
||||||
import store from './store'
|
import store from './store'
|
||||||
import App from './app'
|
import App from './app'
|
||||||
|
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<Router basename="/waveform" history={history}>
|
<Router history={history}>
|
||||||
<App />
|
<App />
|
||||||
</Router>
|
</Router>
|
||||||
</Provider>,
|
</Provider>,
|
||||||
|
@ -4,28 +4,26 @@ import { connect } from 'react-redux'
|
|||||||
import {Episodes} from './components/episodes'
|
import {Episodes} from './components/episodes'
|
||||||
import {Captions} from './components/captions'
|
import {Captions} from './components/captions'
|
||||||
import Audio from './components/waveform'
|
import Audio from './components/waveform'
|
||||||
import { Main, Navbar } from './components'
|
import Main from './components'
|
||||||
import { Login, Signup } from './components/auth-form'
|
class Routes extends Component {
|
||||||
|
componentDidMount() {
|
||||||
const Routes = () => {
|
}
|
||||||
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Route path="/login" component={Login} />
|
<Route exact path="/" component = {Main} />
|
||||||
<Route path="/signup" component={Signup} />
|
<Route path="/episodes" component={Episodes} />
|
||||||
<Route path='/navbar' component={Navbar} />
|
<Route path="/captions/:slug" component={Captions} />
|
||||||
<Route exact path='/' component={Main} />
|
<Route path="/audio" component={Audio} />
|
||||||
<Route path='/episodes' component={Episodes} />
|
|
||||||
<Route path='/captions/:slug' component={Captions} />
|
|
||||||
<Route path='/audio' component={Audio} />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapState = state => {
|
const mapState = state => {
|
||||||
return {
|
return {
|
||||||
episodes: state.episodes,
|
episodes: state.episodes,
|
||||||
captions: state.captions,
|
captions: state.captions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,10 +3,6 @@ const path = require('path')
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: ['@babel/polyfill', './src/index.js'],
|
entry: ['@babel/polyfill', './src/index.js'],
|
||||||
output: {
|
|
||||||
path: path.resolve(__dirname, '/dist'),
|
|
||||||
filename: 'bundle.js',
|
|
||||||
},
|
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
@ -19,6 +15,10 @@ module.exports = {
|
|||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['*', '.js', '.jsx'],
|
extensions: ['*', '.js', '.jsx'],
|
||||||
},
|
},
|
||||||
|
output: {
|
||||||
|
path: __dirname + '/dist',
|
||||||
|
filename: 'bundle.js',
|
||||||
|
},
|
||||||
plugins: [new webpack.HotModuleReplacementPlugin()],
|
plugins: [new webpack.HotModuleReplacementPlugin()],
|
||||||
devServer: {
|
devServer: {
|
||||||
contentBase: path.join(__dirname, 'dist'),
|
contentBase: path.join(__dirname, 'dist'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user