session-desktop/ts/types/Conversation.ts
Audric Ackermann cf44896a03
Minor call tweaks (#2051)
* show missed-call,started-call and answered call notification in chat

* fix types for createLastMessageUpdate

* show incoming dialog if we have a pending call when enable call receptio

* simplify a bit the avatar component

* move disableDrag to a custom hook

* speed up hash colors of avatarPlaceHolders

* fixup text selection and double click reply on message

* keep avatar decoded items longer before releasing memory

* add incoming/outgoing/missed call notification

also, merge that notification with the timer and group notification
component

* hangup call if no answer after 30sec

* refactor SessionInput using hook + add testid field for recovery

* disable message request feature flag for now

* fix merge issue

* force loading screen to be black instead of white

for our dark theme user's eyes safety
2021-11-29 17:40:46 +11:00

42 lines
1.2 KiB
TypeScript

import { LastMessageStatusType } from '../state/ducks/conversations';
import { Message } from './Message';
interface ConversationLastMessageUpdate {
lastMessage: string;
lastMessageStatus: LastMessageStatusType;
timestamp: number | undefined;
}
export const createLastMessageUpdate = ({
currentTimestamp,
lastMessage,
lastMessageStatus,
lastMessageNotificationText,
}: {
currentTimestamp?: number;
lastMessage?: Message;
lastMessageStatus?: LastMessageStatusType;
lastMessageNotificationText?: string;
}): ConversationLastMessageUpdate => {
if (!lastMessage) {
return {
lastMessage: '',
lastMessageStatus: undefined,
timestamp: undefined,
};
}
const { expirationTimerUpdate } = lastMessage;
const isExpireTimerUpdateFromSync = Boolean(
expirationTimerUpdate && expirationTimerUpdate.fromSync
);
const shouldUpdateTimestamp = Boolean(!isExpireTimerUpdateFromSync);
const newTimestamp = shouldUpdateTimestamp ? lastMessage.sent_at : currentTimestamp;
return {
lastMessage: lastMessageNotificationText || '',
lastMessageStatus: lastMessageStatus || undefined,
timestamp: newTimestamp || undefined,
};
};