Observable < ChatResult > handleNoLocalConversation ( String conversationId ) { return checkState ( ) . flatMap ( client -> client . service ( ) . messaging ( ) . getConversation ( conversationId ) . flatMap ( result -> { if ( result . isSuccessful ( ) && result . getResult ( ) != null ) { return persistenceController . upsertConversation ( ChatConversation . builder ( ) . populate ( result . getResult ( ) , result . getETag ( ) ) . build ( ) ) . map ( success -> new ChatResult ( success , success ? null : new ChatResult . Error ( 0 , "External store reported failure." , "Error when inserting conversation " + conversationId ) ) ) ; } else { return Observable . fromCallable ( ( ) -> adapter . adaptResult ( result ) ) ; } } ) ) ; }
When SDK detects missing conversation it makes query in services and saves in the saves locally .