Skip to content

Commit 6d1c5ec

Browse files
committed
feat: add preview text for channel with last message with shared location
1 parent a04df26 commit 6d1c5ec

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/components/ChannelPreview/__tests__/utils.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from 'mock-builders';
1414

1515
import { getDisplayImage, getDisplayTitle, getLatestMessagePreview } from '../utils';
16+
import { generateStaticLocationResponse } from '../../../mock-builders';
1617

1718
describe('ChannelPreview utils', () => {
1819
const clientUser = generateUser();
@@ -37,6 +38,15 @@ describe('ChannelPreview utils', () => {
3738
const channelWithDeletedMessage = generateChannel({
3839
messages: [generateMessage({ deleted_at: new Date() })],
3940
});
41+
const channelWithLocationMessage = generateChannel({
42+
messages: [
43+
generateMessage({
44+
attachments: [],
45+
shared_location: generateStaticLocationResponse(),
46+
text: '',
47+
}),
48+
],
49+
});
4050
const channelWithAttachmentMessage = generateChannel({
4151
messages: [
4252
generateMessage({
@@ -50,6 +60,7 @@ describe('ChannelPreview utils', () => {
5060
['Nothing yet...', 'channelWithEmptyMessage', channelWithEmptyMessage],
5161
['Message deleted', 'channelWithDeletedMessage', channelWithDeletedMessage],
5262
['🏙 Attachment...', 'channelWithAttachmentMessage', channelWithAttachmentMessage],
63+
['🧭 Live location', 'channelWithLocationMessage', channelWithLocationMessage],
5364
])('should return %s for %s', async (expectedValue, testCaseName, c) => {
5465
const t = (text) => text;
5566
const channel = await getQueriedChannelInstance(c);

src/components/ChannelPreview/utils.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ export const getLatestMessagePreview = (
8888
return t('🏙 Attachment...');
8989
}
9090

91+
if (latestMessage.shared_location) {
92+
return t('🧭 Live location');
93+
}
94+
9195
return t('Empty message...');
9296
};
9397

0 commit comments

Comments
 (0)