From 2c59c718727ce7ddb7e75baff15a9bf1ae60f145 Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Wed, 21 Jul 2021 14:21:16 -0500 Subject: [PATCH] Show read/viewed even after read receipts disabled --- ts/models/conversations.ts | 6 +- ts/models/messages.ts | 4 +- ts/state/selectors/conversations.ts | 5 +- ts/state/selectors/items.ts | 5 -- ts/state/selectors/message.ts | 14 +---- .../state/selectors/messages_test.ts | 56 +++++-------------- 6 files changed, 20 insertions(+), 70 deletions(-) diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index e9ee532f8..47a49ba85 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -3850,11 +3850,7 @@ export class ConversationModel extends window.Backbone (previewMessage ? previewMessage.getNotificationText() : '') || '', lastMessageStatus: (previewMessage - ? getMessagePropStatus( - previewMessage.attributes, - ourConversationId, - window.storage.get('read-receipt-setting', false) - ) + ? getMessagePropStatus(previewMessage.attributes, ourConversationId) : null) || null, timestamp, lastMessageDeletedForEveryone: previewMessage diff --git a/ts/models/messages.ts b/ts/models/messages.ts index 5d9bbbebf..784af8ff7 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -367,7 +367,6 @@ export class MessageModel extends window.Backbone.Model { this.OUR_UUID, undefined, undefined, - window.storage.get('read-receipt-setting', false), window.storage.get('regionCode', 'ZZ'), (identifier?: string) => { const state = window.reduxStore.getState(); @@ -3336,8 +3335,7 @@ export class MessageModel extends window.Backbone.Model { (isIncoming(attributes) || getMessagePropStatus( attributes, - window.ConversationController.getOurConversationIdOrThrow(), - window.storage.get('read-receipt-setting', false) + window.ConversationController.getOurConversationIdOrThrow() ) !== 'partial-sent') ) { return undefined; diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 54a6cd2d2..08b0f0920 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -35,7 +35,7 @@ import { getUserNumber, getUserUuid, } from './user'; -import { getPinnedConversationIds, getReadReceiptSetting } from './items'; +import { getPinnedConversationIds } from './items'; import { getPropsForBubble } from './message'; import { CallSelectorType, @@ -671,7 +671,6 @@ export const getMessageSelector = createSelector( getSelectedMessage, getConversationSelector, getRegionCode, - getReadReceiptSetting, getUserNumber, getUserUuid, getUserConversationId, @@ -684,7 +683,6 @@ export const getMessageSelector = createSelector( selectedMessage: SelectedMessageType | undefined, conversationSelector: GetConversationByIdType, regionCode: string, - readReceiptSetting: boolean, ourNumber: string, ourUuid: string, ourConversationId: string, @@ -705,7 +703,6 @@ export const getMessageSelector = createSelector( ourNumber, ourUuid, regionCode, - readReceiptSetting, selectedMessage ? selectedMessage.id : undefined, selectedMessage ? selectedMessage.counter : undefined, callSelector, diff --git a/ts/state/selectors/items.ts b/ts/state/selectors/items.ts index 3d1033f31..d94f1c082 100644 --- a/ts/state/selectors/items.ts +++ b/ts/state/selectors/items.ts @@ -20,11 +20,6 @@ export const getUserAgent = createSelector( (state: ItemsStateType): string => state.userAgent as string ); -export const getReadReceiptSetting = createSelector( - getItems, - (state: ItemsStateType): boolean => Boolean(state['read-receipt-setting']) -); - export const getPinnedConversationIds = createSelector( getItems, (state: ItemsStateType): Array => diff --git a/ts/state/selectors/message.ts b/ts/state/selectors/message.ts index 0794e3416..1511c0ff0 100644 --- a/ts/state/selectors/message.ts +++ b/ts/state/selectors/message.ts @@ -83,7 +83,6 @@ export function getPropsForBubble( ourNumber: string | undefined, ourUuid: string | undefined, regionCode: string, - readReceiptSetting: boolean, selectedMessageId: string | undefined, selectedMessageCounter: number | undefined, callSelector: CallSelectorType, @@ -210,7 +209,6 @@ export function getPropsForBubble( ourUuid, selectedMessageId, selectedMessageCounter, - readReceiptSetting, regionCode, accountSelector ), @@ -322,7 +320,6 @@ export function getPropsForMessage( ourUuid: string | undefined, selectedMessageId: string | undefined, selectedMessageCounter: number | undefined, - readReceiptSetting: boolean, regionCode: string, accountSelector: (identifier?: string) => boolean ): Omit { @@ -393,11 +390,7 @@ export function getPropsForMessage( quote: getPropsForQuote(message, conversationSelector, ourConversationId), reactions, selectedReaction, - status: getMessagePropStatus( - message, - ourConversationId, - readReceiptSetting - ), + status: getMessagePropStatus(message, ourConversationId), text: createNonBreakingLastSeparator(message.body), textPending: message.bodyPending, timestamp: message.sent_at, @@ -901,8 +894,7 @@ export function getMessagePropStatus( MessageAttributesType, 'type' | 'errors' | 'sendStateByConversationId' >, - ourConversationId: string, - readReceiptSetting: boolean + ourConversationId: string ): LastMessageStatus | undefined { if (!isOutgoing(message)) { return undefined; @@ -936,7 +928,7 @@ export function getMessagePropStatus( if (hasErrors(message)) { return isSent(highestSuccessfulStatus) ? 'partial-sent' : 'error'; } - if (readReceiptSetting && isRead(highestSuccessfulStatus)) { + if (isRead(highestSuccessfulStatus)) { return 'read'; } if (isDelivered(highestSuccessfulStatus)) { diff --git a/ts/test-electron/state/selectors/messages_test.ts b/ts/test-electron/state/selectors/messages_test.ts index 4db2ee4dd..f9a64d28f 100644 --- a/ts/test-electron/state/selectors/messages_test.ts +++ b/ts/test-electron/state/selectors/messages_test.ts @@ -146,9 +146,7 @@ describe('state/selectors/messages', () => { it('returns undefined for incoming messages', () => { const message = createMessage({ type: 'incoming' }); - assert.isUndefined( - getMessagePropStatus(message, ourConversationId, true) - ); + assert.isUndefined(getMessagePropStatus(message, ourConversationId)); }); it('returns "paused" for messages with challenges', () => { @@ -163,7 +161,7 @@ describe('state/selectors/messages', () => { const message = createMessage({ errors: [challengeError] }); assert.strictEqual( - getMessagePropStatus(message, ourConversationId, true), + getMessagePropStatus(message, ourConversationId), 'paused' ); }); @@ -188,7 +186,7 @@ describe('state/selectors/messages', () => { }); assert.strictEqual( - getMessagePropStatus(message, ourConversationId, true), + getMessagePropStatus(message, ourConversationId), 'partial-sent' ); }); @@ -213,7 +211,7 @@ describe('state/selectors/messages', () => { }); assert.strictEqual( - getMessagePropStatus(message, ourConversationId, true), + getMessagePropStatus(message, ourConversationId), 'error' ); }); @@ -228,15 +226,13 @@ describe('state/selectors/messages', () => { }, }); - [true, false].forEach(readReceiptSetting => { - assert.strictEqual( - getMessagePropStatus(message, ourConversationId, readReceiptSetting), - 'read' - ); - }); + assert.strictEqual( + getMessagePropStatus(message, ourConversationId), + 'read' + ); }); - it('returns "read" if the message was read by at least one person and you have read receipts enabled', () => { + it('returns "read" if the message was read by at least one person', () => { const readMessage = createMessage({ sendStateByConversationId: { [ourConversationId]: { @@ -258,7 +254,7 @@ describe('state/selectors/messages', () => { }, }); assert.strictEqual( - getMessagePropStatus(readMessage, ourConversationId, true), + getMessagePropStatus(readMessage, ourConversationId), 'read' ); @@ -271,35 +267,11 @@ describe('state/selectors/messages', () => { }, }); assert.strictEqual( - getMessagePropStatus(viewedMessage, ourConversationId, true), + getMessagePropStatus(viewedMessage, ourConversationId), 'read' ); }); - it('returns "delivered" if the message was read by at least one person and you have read receipts disabled', () => { - const message = createMessage({ - sendStateByConversationId: { - [ourConversationId]: { - status: SendStatus.Sent, - updatedAt: Date.now(), - }, - [uuid()]: { - status: SendStatus.Pending, - updatedAt: Date.now(), - }, - [uuid()]: { - status: SendStatus.Read, - updatedAt: Date.now(), - }, - }, - }); - - assert.strictEqual( - getMessagePropStatus(message, ourConversationId, false), - 'delivered' - ); - }); - it('returns "delivered" if the message was delivered to at least one person, but no "higher"', () => { const message = createMessage({ sendStateByConversationId: { @@ -323,7 +295,7 @@ describe('state/selectors/messages', () => { }); assert.strictEqual( - getMessagePropStatus(message, ourConversationId, true), + getMessagePropStatus(message, ourConversationId), 'delivered' ); }); @@ -347,7 +319,7 @@ describe('state/selectors/messages', () => { }); assert.strictEqual( - getMessagePropStatus(message, ourConversationId, true), + getMessagePropStatus(message, ourConversationId), 'sent' ); }); @@ -371,7 +343,7 @@ describe('state/selectors/messages', () => { }); assert.strictEqual( - getMessagePropStatus(message, ourConversationId, true), + getMessagePropStatus(message, ourConversationId), 'sending' ); });