UNPKG

communication-react-19

Version:

React library for building modern communication user experiences utilizing Azure Communication Services (React 19 compatible fork)

24 lines 1.08 kB
/** * Sorts the captions and real time texts based on their timestamp. * * @private */ export function sortCaptionsAndRealTimeTexts(captions, realTimeTexts) { const combinedList = [ ...(Array.isArray(captions) ? captions.map((caption) => (Object.assign({}, caption))) : []), ...(realTimeTexts ? realTimeTexts.map((realTimeText) => (Object.assign({}, realTimeText))) : []) ]; // Sort the combined list by comparing caption's timestamp with realTimeText's updatedTimestamp combinedList.sort((a, b) => { var _a, _b; const timestampA = 'captionText' in a ? new Date((_a = a.createdTimeStamp) !== null && _a !== void 0 ? _a : 0).getTime() : new Date(a.finalizedTimeStamp).getTime(); const timestampB = 'captionText' in b ? new Date((_b = b.createdTimeStamp) !== null && _b !== void 0 ? _b : 0).getTime() : new Date(b.finalizedTimeStamp).getTime(); return timestampA - timestampB; }); return combinedList; } //# sourceMappingURL=sortCaptionsAndRealTimeTexts.js.map