Fix isDateLine function to check for null and undefined (#4142)
* Fix isDateLine function to check for null and undefined * use optional chaining instead Co-Authored-By: Amit Uttam <changingrainbows@gmail.com> Co-authored-by: Amit Uttam <changingrainbows@gmail.com>
This commit is contained in:
parent
b450c4ac9a
commit
f6defc8cc6
2 changed files with 5 additions and 3 deletions
|
|
@ -836,6 +836,8 @@ describe('makeCombineUserActivityPosts', () => {
|
|||
|
||||
describe('isDateLine', () => {
|
||||
test('should correctly identify date line items', () => {
|
||||
expect(isDateLine(undefined)).toBe(false);
|
||||
expect(isDateLine(null)).toBe(false);
|
||||
expect(isDateLine('')).toBe(false);
|
||||
expect(isDateLine('date')).toBe(false);
|
||||
expect(isDateLine('date-')).toBe(true);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ export function makeFilterPostsAndAddSeparators() {
|
|||
|
||||
// Flip it back to newest to oldest
|
||||
return out.reverse();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ export function isStartOfNewMessages(item: string) {
|
|||
}
|
||||
|
||||
export function isDateLine(item: string) {
|
||||
return item.startsWith(DATE_LINE);
|
||||
return Boolean(item?.startsWith(DATE_LINE));
|
||||
}
|
||||
|
||||
export function getDateForDateLine(item: string) {
|
||||
|
|
@ -290,7 +290,7 @@ export function makeGenerateCombinedPost() {
|
|||
user_id: '',
|
||||
metadata: {},
|
||||
};
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue