Skip to content

Commit

Permalink
Fixed bug where opening a chat via url was sending two conversation u…
Browse files Browse the repository at this point in the history
…pdates.
  • Loading branch information
tonyanziano committed Aug 16, 2019
1 parent 54e8cbe commit 142391a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [main] Added End-to-End tests using Spectron in PR [1696](https://github.com/microsoft/BotFramework-Emulator/pull/1696)
- [main] New Conversation: send a single conversation update activity including bot and user as members added [1709](https://github.com/microsoft/BotFramework-Emulator/pull/1709)

## Fixed
- [main] Fixed bug where opening a chat via URL was sending two conversation updates in PR [1735](https://github.com/microsoft/BotFramework-Emulator/pull/1735)

## v4.5.2 - 2019 - 07 - 17
## Fixed
- [client] Fixed some minor styling issues with the JSON inspector in PR [1691](https://github.com/microsoft/BotFramework-Emulator/pull/1691)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,28 @@ export default function startConversation(botEmulator: BotEmulator) {
await conversation.sendConversationUpdate([currentUser, { id: botEndpoint.botId, name: 'Bot' }], undefined);
created = true;
} else if (botEndpoint && !conversationId.endsWith('transcript')) {
if (conversation.members.findIndex(user => user.id === botEndpoint.botId) === -1) {
// Adds bot to conversation and sends "bot added to conversation"
conversation.addMember(botEndpoint.botId, 'Bot');
} else {
// Sends "bot added to conversation"
await conversation.sendConversationUpdate([{ id: botEndpoint.botId, name: 'Bot' }], undefined);
}
const membersToAddInConversationUpdate = [];

const userIsNotInConversation = conversation.members.findIndex(user => user.id === currentUser.id) === -1;
if (userIsNotInConversation) {
// Adds user to conversation and sends "user added to conversation"
conversation.addMember(currentUser.id, currentUser.name);
} else {
// Sends "user added to conversation"
await conversation.sendConversationUpdate([currentUser], undefined);
membersToAddInConversationUpdate.push(currentUser);
}

const botIsNotInConversation = conversation.members.findIndex(user => user.id === botEndpoint.botId) === -1;
if (botIsNotInConversation) {
// Adds bot to conversation and sends "bot added to conversation"
conversation.addMember(botEndpoint.botId, 'Bot');
} else {
// Sends "bot added to conversation"
membersToAddInConversationUpdate.push({ id: botEndpoint.botId, name: 'Bot' });
}

if (membersToAddInConversationUpdate.length) {
await conversation.sendConversationUpdate(membersToAddInConversationUpdate, undefined);
}
}

Expand Down

0 comments on commit 142391a

Please sign in to comment.