updateLastMessage: If we don't update last text, clear it

This commit is contained in:
Scott Nonnenberg
2019-04-12 14:06:34 -07:00
parent 0ffda78ecb
commit 22f7a352f9
3 changed files with 3 additions and 9 deletions

View File

@@ -7,13 +7,11 @@ interface ConversationLastMessageUpdate {
}
export const createLastMessageUpdate = ({
currentLastMessageText,
currentTimestamp,
lastMessage,
lastMessageStatus,
lastMessageNotificationText,
}: {
currentLastMessageText?: string;
currentTimestamp?: number;
lastMessage?: Message;
lastMessageStatus?: string;
@@ -32,10 +30,10 @@ export const createLastMessageUpdate = ({
const isExpireTimerUpdateFromSync = Boolean(
expirationTimerUpdate && expirationTimerUpdate.fromSync
);
const shouldUpdateTimestamp = Boolean(
!isVerifiedChangeMessage && !isExpireTimerUpdateFromSync
);
const newTimestamp = shouldUpdateTimestamp
? lastMessage.sent_at
: currentTimestamp;
@@ -43,7 +41,7 @@ export const createLastMessageUpdate = ({
const shouldUpdateLastMessageText = !isVerifiedChangeMessage;
const newLastMessageText = shouldUpdateLastMessageText
? lastMessageNotificationText
: currentLastMessageText;
: '';
return {
lastMessage: newLastMessageText || '',