使用 Skype SDK 聊天消息出现两次

Message appears twice using Skype SDK chat

我使用 skype sdk Here 这是我在

之后的代码片段
config.conversation.historyService.activityItems.added(function(newMsg) {
  if(typeof newMsg.direction != 'function') {} else {
    if(newMsg.direction() == 'Incoming') {
      direction = "black";
    } else if(newMsg.direction() == 'Outgoing' && newMsg.status() === "Succeeded") {
      direction = "green";
    } else {}
    $("#conversationText").append('<br/><div class="chat-user-info"><h1 class="chat-user-name">' + newMsg.sender.displayName() + '</h1><h2 class="chat-user-time">' + new Date() + '</h2></div><div class="chat-user-message"><h3 style="color:' + direction + ';">' + newMsg.text() + '</h3></div><br/>');
  }
});

但是,当它处于挂起状态或即使失败时,消息也会出现,在此之后我尝试将消息放入其中,但它只出现在另一边,而不是我的。

Github 相关问题 Here

为什么要添加 typeof newMsg.direction != 'function' 条件,它是否更正了某些内容? 您的代码的行为在这里似乎是正确的,因为仅当消息是 "Outgoing" 而不是 "Succeeded" 时才附加消息。 您是否有原始解决方案的任何错误或日志

conversation.historyService.activityItems.added(function(message) {
if (message.type() == 'TextMessage') {
    if (message.direction() == 'Incoming' ) {
        historyAppend(XMessage(message));
    } else if (message.direction() == 'Outgoing' && message.status() === "Succeeded") {
            historyAppend(XMessage(message));
    }
}
});

我确实解决了这个问题,方法是先附加消息而不考虑 message.direction() 值