Conversation.updateLastMessage: Properly clear timestamp/status
This commit is contained in:
@@ -13,6 +13,8 @@ describe('Conversation', () => {
|
|||||||
const input = {};
|
const input = {};
|
||||||
const expected = {
|
const expected = {
|
||||||
lastMessage: '',
|
lastMessage: '',
|
||||||
|
lastMessageStatus: null,
|
||||||
|
timestamp: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const actual = Conversation.createLastMessageUpdate(input);
|
const actual = Conversation.createLastMessageUpdate(input);
|
||||||
@@ -58,7 +60,7 @@ describe('Conversation', () => {
|
|||||||
};
|
};
|
||||||
const expected = {
|
const expected = {
|
||||||
lastMessage: 'bingo',
|
lastMessage: 'bingo',
|
||||||
lastMessageStatus: undefined,
|
lastMessageStatus: null,
|
||||||
timestamp: 555,
|
timestamp: 555,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -87,7 +89,7 @@ describe('Conversation', () => {
|
|||||||
};
|
};
|
||||||
const expected = {
|
const expected = {
|
||||||
lastMessage: 'Last message before expired',
|
lastMessage: 'Last message before expired',
|
||||||
lastMessageStatus: undefined,
|
lastMessageStatus: null,
|
||||||
timestamp: 555,
|
timestamp: 555,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -2,8 +2,8 @@ import { Message } from './Message';
|
|||||||
|
|
||||||
interface ConversationLastMessageUpdate {
|
interface ConversationLastMessageUpdate {
|
||||||
lastMessage: string;
|
lastMessage: string;
|
||||||
lastMessageStatus?: string;
|
lastMessageStatus: string | null;
|
||||||
timestamp?: number;
|
timestamp: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createLastMessageUpdate = ({
|
export const createLastMessageUpdate = ({
|
||||||
@@ -22,6 +22,8 @@ export const createLastMessageUpdate = ({
|
|||||||
if (!lastMessage) {
|
if (!lastMessage) {
|
||||||
return {
|
return {
|
||||||
lastMessage: '',
|
lastMessage: '',
|
||||||
|
lastMessageStatus: null,
|
||||||
|
timestamp: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +47,7 @@ export const createLastMessageUpdate = ({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
lastMessage: newLastMessageText || '',
|
lastMessage: newLastMessageText || '',
|
||||||
lastMessageStatus,
|
lastMessageStatus: lastMessageStatus || null,
|
||||||
timestamp: newTimestamp,
|
timestamp: newTimestamp || null,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user