-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #213 from bemusic/clean
Moar stuffs
- Loading branch information
Showing
13 changed files
with
210 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,58 @@ | ||
|
||
import './MusicInfoTabStats.scss' | ||
|
||
import React from 'react' | ||
import React from 'react' | ||
|
||
export default React.createClass({ | ||
import withPersonalRecord from './withPersonalRecord' | ||
import { formattedAccuracyForRecord } from 'bemuse/rules/accuracy' | ||
|
||
export const MusicInfoTabStats = React.createClass({ | ||
|
||
render () { | ||
const chart = this.props.chart | ||
const record = this.props.record | ||
return <div className="MusicInfoTabStats"> | ||
{this.renderMessage()} | ||
<dl className="MusicInfoTabStatsのcolumn is-left"> | ||
<dt>Notes</dt> | ||
<dd>{chart.noteCount}</dd> | ||
<dt>BPM</dt> | ||
<dd>{chart.bpm.median}</dd> | ||
<dt>Play Count</dt> | ||
<dd>{record ? record.playCount : (this.props.user ? '0' : '-')}</dd> | ||
</dl> | ||
<dl className="MusicInfoTabStatsのcolumn is-right"> | ||
<dt>Best Score</dt> | ||
<dd>-</dd> | ||
<dd>{record ? record.score : '-'}</dd> | ||
|
||
<dt>Accuracy</dt> | ||
<dd>{record | ||
? formattedAccuracyForRecord(record) | ||
: '-' | ||
}</dd> | ||
|
||
<dt>Max Combo</dt> | ||
<dd>-</dd> | ||
<dd>{record | ||
? <span>{record.combo} <small>/ {record.total}</small></span> | ||
: '-' | ||
}</dd> | ||
</dl> | ||
</div> | ||
}, | ||
|
||
renderMessage () { | ||
|
||
if (!this.props.user) { | ||
return ( | ||
<div className="MusicInfoTabStatsのmessage"> | ||
Please log in or create an account to save your play statistics. | ||
</div> | ||
) | ||
} | ||
|
||
return null | ||
} | ||
|
||
}) | ||
|
||
export default withPersonalRecord(MusicInfoTabStats) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,22 @@ | ||
|
||
import React from 'react' | ||
|
||
import id from 'bemuse/online/id' | ||
import online from 'bemuse/online/instance' | ||
import * as DataStore from 'bemuse/online/data-store' | ||
import { getGrade } from 'bemuse/rules/grade' | ||
|
||
import { getGrade } from 'bemuse/rules/grade' | ||
import withPersonalRecord from './withPersonalRecord' | ||
import MusicListItemChart from './MusicListItemChart' | ||
|
||
export default React.createClass({ | ||
|
||
getInitialState () { | ||
return { data: DataStore.INITIAL_STATE } | ||
}, | ||
|
||
componentDidMount () { | ||
online.seen(this.getDescriptor()) | ||
this.unsubscribe = online.records川.onValue(data => this.setState({ data })) | ||
}, | ||
|
||
componentWillUnmount () { | ||
if (this.unsubscribe) this.unsubscribe() | ||
}, | ||
export const MusicListItemChartContainer = React.createClass({ | ||
|
||
shouldComponentUpdate (nextProps, nextState) { | ||
if (this.props.chart !== nextProps.chart) return true | ||
if (this.props.selected !== nextProps.selected) return true | ||
if (this.props.playMode !== nextProps.playMode) return true | ||
if (this.getRecord(this.state) !== this.getRecord(nextState)) return true | ||
return false | ||
}, | ||
|
||
getRecord (state) { | ||
return DataStore.get(state.data, id(this.getDescriptor())).value | ||
}, | ||
|
||
getDescriptor () { | ||
return { md5: this.props.chart.md5, playMode: this.props.playMode } | ||
}, | ||
mixins: [React.addons.PureRenderMixin], | ||
|
||
render () { | ||
let record = this.getRecord(this.state) | ||
let record = this.props.record | ||
let played = !!record | ||
let grade = played ? getGrade(record) : null | ||
if (grade === 'F') grade = null | ||
return <MusicListItemChart {...this.props} played={played} grade={grade} /> | ||
} | ||
|
||
}) | ||
|
||
export default withPersonalRecord(MusicListItemChartContainer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.