mirror of
https://github.com/ascribe/onion.git
synced 2025-02-01 12:29:54 +01:00
fix polling bug
This commit is contained in:
parent
f7618d18f5
commit
3dd5626eb9
@ -48,6 +48,10 @@ let AccordionListItem = React.createClass({
|
||||
}
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
clearInterval(this.state.pollingIntervalIndex);
|
||||
},
|
||||
|
||||
onChange(state) {
|
||||
this.setState(state);
|
||||
},
|
||||
@ -79,11 +83,10 @@ let AccordionListItem = React.createClass({
|
||||
});
|
||||
|
||||
this.toggleCreateEditionsDialog();
|
||||
|
||||
this.startPolling();
|
||||
},
|
||||
|
||||
startPolling() {
|
||||
console.log('start polling');
|
||||
// start polling until editions are defined
|
||||
let pollingIntervalIndex = setInterval(() => {
|
||||
EditionListActions.fetchEditionList(this.props.content.id)
|
||||
@ -150,16 +153,12 @@ let AccordionListItem = React.createClass({
|
||||
</Link>
|
||||
<h3>{getLangText('by %s', this.props.content.artist_name)}</h3>
|
||||
<div>
|
||||
<span>{this.props.content.date_created.split('-')[0]}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="pull-left">{this.props.content.date_created.split('-')[0]}</span>
|
||||
<AccordionListItemEditionWidget
|
||||
className="pull-right"
|
||||
piece={this.props.content}
|
||||
toggleCreateEditionsDialog={this.toggleCreateEditionsDialog}
|
||||
creatingEditions={this.state.creatingEditions}/>
|
||||
{/* <a href={this.props.content.license_type.url} target="_blank" className="pull-right">
|
||||
{getLangText('%s license', this.props.content.license_type.code)}
|
||||
</a> */}
|
||||
</div>
|
||||
</div>
|
||||
<span style={{'clear': 'both'}}></span>
|
||||
|
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import EditionListActions from '../../actions/edition_list_actions';
|
||||
import EditionListStore from '../../stores/edition_list_store';
|
||||
@ -9,6 +10,7 @@ import { getLangText } from '../../utils/lang_utils';
|
||||
|
||||
let AccordionListItemEditionWidget = React.createClass({
|
||||
propTypes: {
|
||||
className: React.PropTypes.string,
|
||||
piece: React.PropTypes.object.isRequired,
|
||||
toggleCreateEditionsDialog: React.PropTypes.func.isRequired,
|
||||
creatingEditions: React.PropTypes.bool.isRequired
|
||||
@ -77,38 +79,38 @@ let AccordionListItemEditionWidget = React.createClass({
|
||||
|
||||
if(numEditions === -1) {
|
||||
return (
|
||||
<span
|
||||
<button
|
||||
onClick={this.props.toggleCreateEditionsDialog}
|
||||
className="ascribe-accordion-list-item-edition-widget">
|
||||
className={classNames('btn', 'btn-default', 'btn-xs', 'ascribe-accordion-list-item-edition-widget', this.props.className)}>
|
||||
+ Editions
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
else if(numEditions === 0) {
|
||||
return (
|
||||
<span>
|
||||
<button className={classNames('btn', 'btn-default', 'btn-xs', this.props.className)}>
|
||||
Creating Editions <span className="glyph-ascribe-spool-chunked ascribe-color spin"/>
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
else if(numEditions === 1) {
|
||||
let editionMapping = piece && piece.firstEdition ? piece.firstEdition.edition_number + '/' + piece.num_editions : '';
|
||||
|
||||
return (
|
||||
<span
|
||||
<button
|
||||
onClick={this.toggleTable}
|
||||
className="ascribe-accordion-list-item-edition-widget">
|
||||
className={classNames('btn', 'btn-default', 'btn-xs', 'ascribe-accordion-list-item-edition-widget', this.props.className)}>
|
||||
{editionMapping + ' ' + getLangText('Edition')} {this.getGlyphicon()}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
else {
|
||||
return (
|
||||
<span
|
||||
<button
|
||||
onClick={this.toggleTable}
|
||||
className="ascribe-accordion-list-item-edition-widget">
|
||||
className={classNames('btn', 'btn-default', 'btn-xs', 'ascribe-accordion-list-item-edition-widget', this.props.className)}>
|
||||
{numEditions + ' ' + getLangText('Editions')} {this.getGlyphicon()}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user