Observable < ChatResult > synchroniseStore ( ) { if ( isSynchronising . getAndSet ( true ) ) { log . i ( "Synchronisation in progress." ) ; return Observable . fromCallable ( ( ) -> new ChatResult ( true , null ) ) ; } log . i ( "Synchronising store." ) ; return synchroniseConversations ( ) . onErrorReturn ( t -> new ChatResult ( false , new ChatResult . Error ( 0 , t ) ) ) . doOnNext ( i -> { if ( i . isSuccessful ( ) ) { log . i ( "Synchronisation successfully finished." ) ; } else { log . e ( "Synchronisation finished with error. " + ( i . getError ( ) != null ? i . getError ( ) . getDetails ( ) : "" ) ) ; } isSynchronising . compareAndSet ( true , false ) ; } ) ; }
Check state for all conversations and update from services .