@ -1,6 +1,11 @@
import api from '../api' ;
import api from '../api' ;
import { updateTimeline } from './timelines' ;
import {
updateTimeline ,
refreshHomeTimeline ,
refreshCommunityTimeline ,
refreshPublicTimeline ,
} from './timelines' ;
export const COMPOSE _CHANGE = 'COMPOSE_CHANGE' ;
export const COMPOSE _CHANGE = 'COMPOSE_CHANGE' ;
export const COMPOSE _SUBMIT _REQUEST = 'COMPOSE_SUBMIT_REQUEST' ;
export const COMPOSE _SUBMIT _REQUEST = 'COMPOSE_SUBMIT_REQUEST' ;
@ -95,16 +100,20 @@ export function submitCompose() {
dispatch ( submitComposeSuccess ( { ... response . data } ) ) ;
dispatch ( submitComposeSuccess ( { ... response . data } ) ) ;
// To make the app more responsive, immediately get the status into the columns
// To make the app more responsive, immediately get the status into the columns
dispatch ( updateTimeline ( 'home' , { ... response . data } ) ) ;
if ( response . data . in _reply _to _id === null && response . data . visibility === 'public' ) {
const insertOrRefresh = ( timelineId , refreshAction ) => {
if ( getState ( ) . getIn ( [ 'timelines' , 'community' , 'loaded' ] ) ) {
if ( getState ( ) . getIn ( [ 'timelines' , timelineId , 'online' ] ) ) {
dispatch ( updateTimeline ( 'community' , { ... response . data } ) ) ;
dispatch ( updateTimeline ( timelineId , { ... response . data } ) ) ;
} else if ( getState ( ) . getIn ( [ 'timelines' , timelineId , 'loaded' ] ) ) {
dispatch ( refreshAction ( ) ) ;
}
}
} ;
if ( getState ( ) . getIn ( [ 'timelines' , 'public' , 'loaded' ] ) ) {
insertOrRefresh ( 'home' , refreshHomeTimeline ) ;
dispatch ( updateTimeline ( 'public' , { ... response . data } ) ) ;
}
if ( response . data . in _reply _to _id === null && response . data . visibility === 'public' ) {
insertOrRefresh ( 'community' , refreshCommunityTimeline ) ;
insertOrRefresh ( 'public' , refreshPublicTimeline ) ;
}
}
} ) . catch ( function ( error ) {
} ) . catch ( function ( error ) {
dispatch ( submitComposeFail ( error ) ) ;
dispatch ( submitComposeFail ( error ) ) ;