Observable < ChatResult > handleConversationDeleted ( String conversationId , ComapiResult < Void > result ) { if ( result . getCode ( ) != ETAG_NOT_VALID ) { return persistenceController . deleteConversation ( conversationId ) . map ( success -> adapter . adaptResult ( result , success ) ) ; } else { return checkState ( ) . flatMap ( client -> client . service ( ) . messaging ( ) . getConversation ( conversationId ) . flatMap ( newResult -> { if ( newResult . isSuccessful ( ) ) { return persistenceController . upsertConversation ( ChatConversation . builder ( ) . populate ( newResult . getResult ( ) , newResult . getETag ( ) ) . build ( ) ) . flatMap ( success -> Observable . fromCallable ( ( ) -> new ChatResult ( false , success ? new ChatResult . Error ( ETAG_NOT_VALID , "Conversation updated, try delete again." , "Conversation " + conversationId + " updated in response to wrong eTag error when deleting." ) : new ChatResult . Error ( 0 , "Error updating custom store." , null ) ) ) ) ; } else { return Observable . fromCallable ( ( ) -> adapter . adaptResult ( newResult ) ) ; } } ) ) ; } }
Handles conversation delete service response .