@ -41,13 +41,15 @@ export const expandConversations = ({ maxId } = {}) => (dispatch, getState) => {
params . since _id = getState ( ) . getIn ( [ 'conversations' , 'items' , 0 , 'last_status' ] ) ;
params . since _id = getState ( ) . getIn ( [ 'conversations' , 'items' , 0 , 'last_status' ] ) ;
}
}
const isLoadingRecent = ! ! params . since _id ;
api ( getState ) . get ( '/api/v1/conversations' , { params } )
api ( getState ) . get ( '/api/v1/conversations' , { params } )
. then ( response => {
. then ( response => {
const next = getLinks ( response ) . refs . find ( link => link . rel === 'next' ) ;
const next = getLinks ( response ) . refs . find ( link => link . rel === 'next' ) ;
dispatch ( importFetchedAccounts ( response . data . reduce ( ( aggr , item ) => aggr . concat ( item . accounts ) , [ ] ) ) ) ;
dispatch ( importFetchedAccounts ( response . data . reduce ( ( aggr , item ) => aggr . concat ( item . accounts ) , [ ] ) ) ) ;
dispatch ( importFetchedStatuses ( response . data . map ( item => item . last _status ) . filter ( x => ! ! x ) ) ) ;
dispatch ( importFetchedStatuses ( response . data . map ( item => item . last _status ) . filter ( x => ! ! x ) ) ) ;
dispatch ( expandConversationsSuccess ( response . data , next ? next . uri : null ) ) ;
dispatch ( expandConversationsSuccess ( response . data , next ? next . uri : null , isLoadingRecent ) ) ;
} )
} )
. catch ( err => dispatch ( expandConversationsFail ( err ) ) ) ;
. catch ( err => dispatch ( expandConversationsFail ( err ) ) ) ;
} ;
} ;
@ -56,10 +58,11 @@ export const expandConversationsRequest = () => ({
type : CONVERSATIONS _FETCH _REQUEST ,
type : CONVERSATIONS _FETCH _REQUEST ,
} ) ;
} ) ;
export const expandConversationsSuccess = ( conversations , next ) => ( {
export const expandConversationsSuccess = ( conversations , next , isLoadingRecent ) => ( {
type : CONVERSATIONS _FETCH _SUCCESS ,
type : CONVERSATIONS _FETCH _SUCCESS ,
conversations ,
conversations ,
next ,
next ,
isLoadingRecent ,
} ) ;
} ) ;
export const expandConversationsFail = error => ( {
export const expandConversationsFail = error => ( {