@ -12,11 +12,15 @@ import ColumnBackButton from '../../components/column_back_button';
import { List as ImmutableList } from 'immutable' ;
import { List as ImmutableList } from 'immutable' ;
import ImmutablePureComponent from 'react-immutable-pure-component' ;
import ImmutablePureComponent from 'react-immutable-pure-component' ;
const mapStateToProps = ( state , props ) => ( {
const mapStateToProps = ( state , { params : { accountId } , withReplies = false } ) => {
statusIds : state . getIn ( [ 'timelines' , ` account: ${ props . params . accountId } ` , 'items' ] , ImmutableList ( ) ) ,
const path = withReplies ? ` ${ accountId } :with_replies ` : accountId ;
isLoading : state . getIn ( [ 'timelines' , ` account: ${ props . params . accountId } ` , 'isLoading' ] ) ,
hasMore : ! ! state . getIn ( [ 'timelines' , ` account: ${ props . params . accountId } ` , 'next' ] ) ,
return {
} ) ;
statusIds : state . getIn ( [ 'timelines' , ` account: ${ path } ` , 'items' ] , ImmutableList ( ) ) ,
isLoading : state . getIn ( [ 'timelines' , ` account: ${ path } ` , 'isLoading' ] ) ,
hasMore : ! ! state . getIn ( [ 'timelines' , ` account: ${ path } ` , 'next' ] ) ,
} ;
} ;
@ connect ( mapStateToProps )
@ connect ( mapStateToProps )
export default class AccountTimeline extends ImmutablePureComponent {
export default class AccountTimeline extends ImmutablePureComponent {
@ -27,23 +31,24 @@ export default class AccountTimeline extends ImmutablePureComponent {
statusIds : ImmutablePropTypes . list ,
statusIds : ImmutablePropTypes . list ,
isLoading : PropTypes . bool ,
isLoading : PropTypes . bool ,
hasMore : PropTypes . bool ,
hasMore : PropTypes . bool ,
withReplies : PropTypes . bool ,
} ;
} ;
componentWillMount ( ) {
componentWillMount ( ) {
this . props . dispatch ( fetchAccount ( this . props . params . accountId ) ) ;
this . props . dispatch ( fetchAccount ( this . props . params . accountId ) ) ;
this . props . dispatch ( refreshAccountTimeline ( this . props . params . accountId )) ;
this . props . dispatch ( refreshAccountTimeline ( this . props . params . accountId , this . props . withReplies )) ;
}
}
componentWillReceiveProps ( nextProps ) {
componentWillReceiveProps ( nextProps ) {
if ( nextProps . params . accountId !== this . props . params . accountId && nextProps . params . accountId ) {
if ( ( nextProps . params . accountId !== this . props . params . accountId && nextProps . params . accountId ) || nextProps . withReplies !== this . props . withReplies ) {
this . props . dispatch ( fetchAccount ( nextProps . params . accountId ) ) ;
this . props . dispatch ( fetchAccount ( nextProps . params . accountId ) ) ;
this . props . dispatch ( refreshAccountTimeline ( nextProps . params . accountId )) ;
this . props . dispatch ( refreshAccountTimeline ( nextProps . params . accountId , nextProps . params . withReplies )) ;
}
}
}
}
handleScrollToBottom = ( ) => {
handleScrollToBottom = ( ) => {
if ( ! this . props . isLoading && this . props . hasMore ) {
if ( ! this . props . isLoading && this . props . hasMore ) {
this . props . dispatch ( expandAccountTimeline ( this . props . params . accountId )) ;
this . props . dispatch ( expandAccountTimeline ( this . props . params . accountId , this . props . withReplies )) ;
}
}
}
}