1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-03 18:35:09 +01:00

fix polling bug

This commit is contained in:
Tim Daubenschütz 2015-07-13 10:07:22 +02:00
parent f7618d18f5
commit 3dd5626eb9
2 changed files with 20 additions and 19 deletions

View File

@ -48,6 +48,10 @@ let AccordionListItem = React.createClass({
} }
}, },
componentWillUnmount() {
clearInterval(this.state.pollingIntervalIndex);
},
onChange(state) { onChange(state) {
this.setState(state); this.setState(state);
}, },
@ -79,11 +83,10 @@ let AccordionListItem = React.createClass({
}); });
this.toggleCreateEditionsDialog(); this.toggleCreateEditionsDialog();
this.startPolling();
}, },
startPolling() { startPolling() {
console.log('start polling');
// start polling until editions are defined // start polling until editions are defined
let pollingIntervalIndex = setInterval(() => { let pollingIntervalIndex = setInterval(() => {
EditionListActions.fetchEditionList(this.props.content.id) EditionListActions.fetchEditionList(this.props.content.id)
@ -150,16 +153,12 @@ let AccordionListItem = React.createClass({
</Link> </Link>
<h3>{getLangText('by %s', this.props.content.artist_name)}</h3> <h3>{getLangText('by %s', this.props.content.artist_name)}</h3>
<div> <div>
<span>{this.props.content.date_created.split('-')[0]}</span> <span className="pull-left">{this.props.content.date_created.split('-')[0]}</span>
</div>
<div>
<AccordionListItemEditionWidget <AccordionListItemEditionWidget
className="pull-right"
piece={this.props.content} piece={this.props.content}
toggleCreateEditionsDialog={this.toggleCreateEditionsDialog} toggleCreateEditionsDialog={this.toggleCreateEditionsDialog}
creatingEditions={this.state.creatingEditions}/> 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>
</div> </div>
<span style={{'clear': 'both'}}></span> <span style={{'clear': 'both'}}></span>

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import classNames from 'classnames';
import EditionListActions from '../../actions/edition_list_actions'; import EditionListActions from '../../actions/edition_list_actions';
import EditionListStore from '../../stores/edition_list_store'; import EditionListStore from '../../stores/edition_list_store';
@ -9,6 +10,7 @@ import { getLangText } from '../../utils/lang_utils';
let AccordionListItemEditionWidget = React.createClass({ let AccordionListItemEditionWidget = React.createClass({
propTypes: { propTypes: {
className: React.PropTypes.string,
piece: React.PropTypes.object.isRequired, piece: React.PropTypes.object.isRequired,
toggleCreateEditionsDialog: React.PropTypes.func.isRequired, toggleCreateEditionsDialog: React.PropTypes.func.isRequired,
creatingEditions: React.PropTypes.bool.isRequired creatingEditions: React.PropTypes.bool.isRequired
@ -77,38 +79,38 @@ let AccordionListItemEditionWidget = React.createClass({
if(numEditions === -1) { if(numEditions === -1) {
return ( return (
<span <button
onClick={this.props.toggleCreateEditionsDialog} 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 + Editions
</span> </button>
); );
} }
else if(numEditions === 0) { else if(numEditions === 0) {
return ( return (
<span> <button className={classNames('btn', 'btn-default', 'btn-xs', this.props.className)}>
Creating Editions <span className="glyph-ascribe-spool-chunked ascribe-color spin"/> Creating Editions <span className="glyph-ascribe-spool-chunked ascribe-color spin"/>
</span> </button>
); );
} }
else if(numEditions === 1) { else if(numEditions === 1) {
let editionMapping = piece && piece.firstEdition ? piece.firstEdition.edition_number + '/' + piece.num_editions : ''; let editionMapping = piece && piece.firstEdition ? piece.firstEdition.edition_number + '/' + piece.num_editions : '';
return ( return (
<span <button
onClick={this.toggleTable} 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()} {editionMapping + ' ' + getLangText('Edition')} {this.getGlyphicon()}
</span> </button>
); );
} }
else { else {
return ( return (
<span <button
onClick={this.toggleTable} 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()} {numEditions + ' ' + getLangText('Editions')} {this.getGlyphicon()}
</span> </button>
); );
} }
} }