updateLastMessage: If we don't update last text, clear it
This commit is contained in:
parent
0ffda78ecb
commit
22f7a352f9
3 changed files with 3 additions and 9 deletions
|
@ -1157,7 +1157,6 @@
|
|||
? lastMessageModel.getMessagePropStatus()
|
||||
: null;
|
||||
const lastMessageUpdate = Conversation.createLastMessageUpdate({
|
||||
currentLastMessageText: this.get('lastMessage') || null,
|
||||
currentTimestamp: this.get('timestamp') || null,
|
||||
lastMessage: lastMessageJSON,
|
||||
lastMessageStatus: lastMessageStatusModel,
|
||||
|
|
|
@ -24,7 +24,6 @@ describe('Conversation', () => {
|
|||
context('for regular message', () => {
|
||||
it('should update last message text and timestamp', () => {
|
||||
const input = {
|
||||
currentLastMessageText: 'Existing message',
|
||||
currentTimestamp: 555,
|
||||
lastMessageStatus: 'read',
|
||||
lastMessage: {
|
||||
|
@ -48,7 +47,6 @@ describe('Conversation', () => {
|
|||
context('for verified change message', () => {
|
||||
it('should skip update', () => {
|
||||
const input = {
|
||||
currentLastMessageText: 'bingo',
|
||||
currentTimestamp: 555,
|
||||
lastMessage: {
|
||||
type: 'verified-change',
|
||||
|
@ -59,7 +57,7 @@ describe('Conversation', () => {
|
|||
lastMessageNotificationText: 'Verified Changed',
|
||||
};
|
||||
const expected = {
|
||||
lastMessage: 'bingo',
|
||||
lastMessage: '',
|
||||
lastMessageStatus: null,
|
||||
timestamp: 555,
|
||||
};
|
||||
|
@ -72,7 +70,6 @@ describe('Conversation', () => {
|
|||
context('for expire timer update from sync', () => {
|
||||
it('should update message but not timestamp (to prevent bump to top)', () => {
|
||||
const input = {
|
||||
currentLastMessageText: 'I am expired',
|
||||
currentTimestamp: 555,
|
||||
lastMessage: {
|
||||
type: 'incoming',
|
||||
|
|
|
@ -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 || '',
|
||||
|
|
Loading…
Reference in a new issue