code: public Observable<Boolean> updateStoreWithNewMessage(final ChatMessage message, final ChatController.NoConversationListener noConversationListener) {
  
          return asObservable(new Executor<Boolean>() {
              @Override
              protected void execute(ChatStore store, Emitter<Boolean> emitter) {
  
                  boolean isSuccessful = true;
  
                  store.beginTransaction();
  
                  ChatConversationBase conversation = store.getConversation(message.getConversationId());
  
                  String tempId = (String) (message.getMetadata() != null ? message.getMetadata().get(MESSAGE_METADATA_TEMP_ID) : null);
                  if (!TextUtils.isEmpty(tempId)) {
                      store.deleteMessage(message.getConversationId(), tempId);
                  }
  
                  if (message.getSentEventId() == null) {
                      message.setSentEventId(-1L);
                  }
  
                  if (message.getSentEventId() == -1L) {
                      if (conversation != null && conversation.getLastLocalEventId() != -1L) {
                          message.setSentEventId(conversation.getLastLocalEventId() + 1);
                      }
                      message.addStatusUpdate(ChatMessageStatus.builder().populate(message.getConversationId(), message.getMessageId(), message.getFromWhom().getId(), LocalMessageStatus.sent, System.currentTimeMillis(), null).build());
                      isSuccessful = store.upsert(message);
                  } else {
                      isSuccessful = store.upsert(message);
                  }
  
                  if (!doUpdateConversationFromEvent(store, message.getConversationId(), message.getSentEventId(), message.getSentOn()) && noConversationListener != null) {
                      noConversationListener.getConversation(message.getConversationId());
                  }
  
                  store.endTransaction();
  
                  emitter.onNext(isSuccessful);
                  emitter.onCompleted();
              }
          });
      }
docs: Deletes temporary message and inserts provided one. If no associated conversation exists will trigger GET from server.
  
  @param message                Message to save.
  @param noConversationListener Listener for the chat controller to get conversation if no local copy is present.
  @return Observable emitting result.