-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move check if is thread main message to other hook
- Loading branch information
1 parent
7c5a1c4
commit 08230fe
Showing
5 changed files
with
48 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
apps/meteor/client/views/room/MessageList/lib/isPreviousThreadMainMessage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { IMessage, isThreadMessage } from '@rocket.chat/core-typings'; | ||
|
||
export const isPreviousThreadMainMessage = (previous: IMessage | undefined): boolean => | ||
!!previous && !!previous.tshow && isThreadMessage(previous); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
apps/meteor/tests/unit/client/views/room/MessageList/lib/isPreviousThreadShowMessage.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* eslint-env mocha */ | ||
import type { IThreadMessage } from '@rocket.chat/core-typings'; | ||
import { expect } from 'chai'; | ||
|
||
import { isPreviousThreadMainMessage } from '../../../../../../../client/views/room/MessageList/lib/isPreviousThreadMainMessage'; | ||
|
||
const date = new Date('2021-10-27T00:00:00.000Z'); | ||
const baseMessage = { | ||
ts: date, | ||
u: { | ||
_id: 'userId', | ||
name: 'userName', | ||
username: 'userName', | ||
}, | ||
msg: 'message', | ||
rid: 'roomId', | ||
_id: 'messageId', | ||
_updatedAt: date, | ||
urls: [], | ||
}; | ||
|
||
describe('isPreviousThreadMainMessage', () => { | ||
it('should return false if no previous message', () => { | ||
expect(isPreviousThreadMainMessage(undefined)).to.be.false; | ||
}); | ||
|
||
it('should return false if previous message is not thread preview', () => { | ||
expect(isPreviousThreadMainMessage(baseMessage)).to.be.false; | ||
}); | ||
|
||
it('should return true if previous message is thread preview', () => { | ||
const previous: IThreadMessage = { | ||
...baseMessage, | ||
tmid: 'threadId', | ||
tshow: true, | ||
}; | ||
expect(isPreviousThreadMainMessage(previous)).to.be.true; | ||
}); | ||
}); |