Files
Signal-Desktop/ts/types/Conversation.ts
Scott Nonnenberg 643739f65d Responding to feedback on the updated visuals (#2549)
* Conversation List Item: timestamp bold only when convo has unread

* Preserve the positioning of overlays on re-entry into convo

* ConversationListItem: Handle missing and broken thumbnails

* Shorten timestamp in left pane for better Android consistency

* Update convo last updated if last was expire timer change

But not if it was from a sync instead of from you or from a contact.

* Make links in quotes the same color as the text

* MediaGridItem: Update placeholder icon colors for dark theme

* Ensure turning off timer shows 'Timer set to off' in left pane

* ConversationListItem: Show unread count in blue circle

* Add one pixel margin to blue indicator for text alignment

* Ensure replies to voice message can bet sent successfully
2018-07-20 16:37:57 -07:00

52 lines
1.4 KiB
TypeScript

import { Message } from './Message';
interface ConversationLastMessageUpdate {
lastMessage: string | null;
lastMessageStatus: string | null;
timestamp: number | null;
}
export const createLastMessageUpdate = ({
currentLastMessageText,
currentTimestamp,
lastMessage,
lastMessageStatus,
lastMessageNotificationText,
}: {
currentLastMessageText: string | null;
currentTimestamp: number | null;
lastMessage: Message | null;
lastMessageStatus: string | null;
lastMessageNotificationText: string | null;
}): ConversationLastMessageUpdate => {
if (lastMessage === null) {
return {
lastMessage: '',
lastMessageStatus: null,
timestamp: null,
};
}
const { type, expirationTimerUpdate } = lastMessage;
const isVerifiedChangeMessage = type === 'verified-change';
const isExpireTimerUpdateFromSync =
expirationTimerUpdate && expirationTimerUpdate.fromSync;
const shouldUpdateTimestamp =
!isVerifiedChangeMessage && !isExpireTimerUpdateFromSync;
const newTimestamp = shouldUpdateTimestamp
? lastMessage.sent_at
: currentTimestamp;
const shouldUpdateLastMessageText = !isVerifiedChangeMessage;
const newLastMessageText = shouldUpdateLastMessageText
? lastMessageNotificationText
: currentLastMessageText;
return {
lastMessage: newLastMessageText,
lastMessageStatus,
timestamp: newTimestamp,
};
};