Skip to content

Commit ed04990

Browse files
[Chat] Fix for a race condition for "The message is deleted" announcement (#3946)
1 parent 54784d8 commit ed04990

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "Accessibility",
5+
"comment": "Fix for a race condition for \"The message is deleted\" announcement",
6+
"packageName": "@azure/communication-react",
7+
"email": "98852890+vhuseinova-msft@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "Accessibility",
5+
"comment": "Fix for a race condition for \"The message is deleted\" announcement",
6+
"packageName": "@azure/communication-react",
7+
"email": "98852890+vhuseinova-msft@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}

packages/react-components/src/components/MessageThread.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,10 +728,12 @@ export const MessageThreadWrapper = (props: MessageThreadProps): JSX.Element =>
728728
return;
729729
}
730730
try {
731-
await onDeleteMessage(messageId);
732731
// reset deleted message label in case if there was a value already (messages are deleted 1 after another)
733732
setDeletedMessageAriaLabel(undefined);
734733
setLatestDeletedMessageId(messageId);
734+
// we should set up latestDeletedMessageId before the onDeleteMessage call
735+
// as otherwise in very rare cases the messages array can be updated before latestDeletedMessageId
736+
await onDeleteMessage(messageId);
735737
} catch (e) {
736738
console.log('onDeleteMessage failed: messageId', messageId, 'error', e);
737739
}

0 commit comments

Comments
 (0)