Show read/viewed even after read receipts disabled

This commit is contained in:
Evan Hahn 2021-07-21 14:21:16 -05:00 committed by GitHub
parent 8bcf3addc7
commit 2c59c71872
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 70 deletions

View file

@ -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

View file

@ -367,7 +367,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
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<MessageAttributesType> {
(isIncoming(attributes) ||
getMessagePropStatus(
attributes,
window.ConversationController.getOurConversationIdOrThrow(),
window.storage.get('read-receipt-setting', false)
window.ConversationController.getOurConversationIdOrThrow()
) !== 'partial-sent')
) {
return undefined;

View file

@ -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,

View file

@ -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<string> =>

View file

@ -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<PropsForMessage, 'renderingContext'> {
@ -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)) {

View file

@ -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'
);
});