communication-react-19
Version:
React library for building modern communication user experiences utilizing Azure Communication Services (React 19 compatible fork)
16 lines • 792 B
JavaScript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* @private
*/
export const compareMessages = (firstMessage, secondMessage) => {
const firstDate = new Date(firstMessage.createdOn).getTime();
const secondDate = new Date(secondMessage.createdOn).getTime();
// Workaround to get a stable order of message before we can get sequenceId from chat service.
// MessageIds are generated by time order the message persist, a good candidate other than time
const idDelta = firstMessage.messageId && secondMessage.messageId
? Number.parseInt(firstMessage.messageId) - Number.parseInt(secondMessage.messageId)
: 0;
return firstDate - secondDate === 0 ? idDelta : firstDate - secondDate;
};
//# sourceMappingURL=compareMessages.js.map