Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.6 kB
1
Indexable
Never
  _deleteChat = async(chat_id:any) => {
    console.log('deleteChat', chat_id?.id)
    const token = await StorageProvider.get('USER_TOKEN')
 

    const header = {
      'Content-Type': 'application/json',
      token
    }
    const requestMessage = new Message(
      getName(MessageEnum.RestAPIRequestMessage),
    )
    this.deleteChatApi = requestMessage.messageId
    requestMessage.addData(
      getName(MessageEnum.RestAPIResponceEndPointMessage),
      // configJSON.getPostListApiEndPoint,
      `bx_block_chat/chats/${chat_id}`
    )
    requestMessage.addData(
      getName(MessageEnum.RestAPIRequestHeaderMessage),
      JSON.stringify(header),
    )
    requestMessage.addData(
      getName(MessageEnum.RestAPIRequestMethodMessage),
      'DELETE',
    )

    runEngine.sendMessage(requestMessage.id, requestMessage)
    return true
  }

if (
      getName(MessageEnum.RestAPIResponceMessage) === message.id &&
      this.deleteChatApi != null &&
      this.deleteChatApi === message.getData(getName(MessageEnum.RestAPIResponceDataMessage))
    ) {
      var responseJson = message.getData(
        getName(MessageEnum.RestAPIResponceSuccessMessage)
      );
      if (responseJson !== undefined && responseJson?.errors === undefined) {
        
        this.props.navigation.navigate('ChatListScreen')  
      } else {
        var errorReponse = message.getData(
          getName(MessageEnum.RestAPIResponceErrorMessage)
        );
        console.log("eeefenwenfiewnf", errorReponse)
        console.log(responseJson)
        // this.parseApiCatchErrorResponse(errorReponse);
      }
    }