fix: Retry message not working if the conversation has an external issue (#8529)
This commit is contained in:
@@ -2,7 +2,7 @@ import fromUnixTime from 'date-fns/fromUnixTime';
|
||||
import format from 'date-fns/format';
|
||||
import isToday from 'date-fns/isToday';
|
||||
import isYesterday from 'date-fns/isYesterday';
|
||||
import { endOfDay, getUnixTime, startOfDay } from 'date-fns';
|
||||
import { endOfDay, getUnixTime, startOfDay, differenceInDays } from 'date-fns';
|
||||
|
||||
export const formatUnixDate = (date, dateFormat = 'MMM dd, yyyy') => {
|
||||
const unixDate = fromUnixTime(date);
|
||||
@@ -45,3 +45,8 @@ export const generateRelativeTime = (value, unit, languageCode) => {
|
||||
});
|
||||
return rtf.format(value, unit);
|
||||
};
|
||||
|
||||
export const getDayDifferenceFromNow = (now, timestampInSeconds) => {
|
||||
const date = new Date(timestampInSeconds * 1000);
|
||||
return differenceInDays(now, date);
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
formatDigitToString,
|
||||
isTimeAfter,
|
||||
generateRelativeTime,
|
||||
getDayDifferenceFromNow,
|
||||
} from '../DateHelper';
|
||||
|
||||
describe('#DateHelper', () => {
|
||||
@@ -120,3 +121,25 @@ describe('generateRelativeTime', () => {
|
||||
expect(actualResult).toBe(expectedResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getDayDifferenceFromNow', () => {
|
||||
it('should return the difference if in same day', () => {
|
||||
const now = new Date('2023-12-08T00:00:00.000Z');
|
||||
const timestampInSeconds = 1702020305; // 08/12/2023, 12:55:05 (GMT+05:30)
|
||||
const expectedResult = 0;
|
||||
|
||||
const actualResult = getDayDifferenceFromNow(now, timestampInSeconds);
|
||||
|
||||
expect(actualResult).toBe(expectedResult);
|
||||
});
|
||||
|
||||
it('should return the difference if in different day', () => {
|
||||
const now = new Date('2023-12-11T00:00:00.000Z');
|
||||
const timestampInSeconds = 1702020305; // 08/12/2023, 12:55:05 (GMT+05:30)
|
||||
const expectedResult = 2;
|
||||
|
||||
const actualResult = getDayDifferenceFromNow(now, timestampInSeconds);
|
||||
|
||||
expect(actualResult).toBe(expectedResult);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user