From ac8c4ac2eb210544164e109612606187532d409f Mon Sep 17 00:00:00 2001 From: warrickct Date: Mon, 14 Feb 2022 09:57:43 +1100 Subject: [PATCH] Removing msg req feature flag. --- _locales/en/messages.json | 7 +++-- preload.js | 1 - .../conversation/SessionConversation.tsx | 4 +-- .../leftpane/LeftPaneMessageSection.tsx | 12 ++++---- .../overlay/OverlayMessageRequest.tsx | 9 +----- .../settings/section/CategoryPrivacy.tsx | 29 +++++++++++-------- ts/models/conversation.ts | 4 +-- ts/receiver/configMessage.ts | 5 +--- ts/state/selectors/conversations.ts | 17 +++-------- ts/types/LocalizerKeys.ts | 3 ++ 10 files changed, 38 insertions(+), 53 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 02cb08761..0b3c920e5 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -439,7 +439,7 @@ "messageRequests": "Message Requests", "requestsSubtitle": "Pending Requests", "requestsPlaceholder": "No requests", - "messageRequestsDescription": "Enable Message Request Inbox", + "messageRequestsDescription": "Always show the Message Request inbox", "incomingCallFrom": "Incoming call from '$name$'", "ringing": "Ringing...", "establishingConnection": "Establishing connection...", @@ -471,5 +471,8 @@ "messageRequestAcceptedOurs": "You have accepted $name$'s message request", "messageRequestAcceptedOursNoName": "You have accepted the message request", "declineRequestMessage": "Are you sure you want to decline this message request?", - "respondingToRequestWarning": "Sending a message to this user will automatically accept their message request and reveal your Session ID." + "respondingToRequestWarning": "Sending a message to this user will automatically accept their message request and reveal your Session ID.", + "alwaysShowMessageRequests": "Always show Message Requests", + "openMessageRequestInbox": "View Message Requests", + "openMessageRequestInboxDescription": "View your Message Request inbox" } diff --git a/preload.js b/preload.js index fe8b9cd66..55443d236 100644 --- a/preload.js +++ b/preload.js @@ -37,7 +37,6 @@ window.isBehindProxy = () => Boolean(config.proxyUrl); window.lokiFeatureFlags = { useOnionRequests: true, - useMessageRequests: true, useCallMessage: true, }; diff --git a/ts/components/conversation/SessionConversation.tsx b/ts/components/conversation/SessionConversation.tsx index 12456edc5..02f16d99b 100644 --- a/ts/components/conversation/SessionConversation.tsx +++ b/ts/components/conversation/SessionConversation.tsx @@ -230,9 +230,7 @@ export class SessionConversation extends React.Component { const isApproved = selectedConversation.isApproved; const selectionMode = selectedMessages.length > 0; - const useMsgRequests = - window.lokiFeatureFlags.useMessageRequests && - window.inboxStore?.getState().userConfig.messageRequests; + const useMsgRequests = window.inboxStore?.getState().userConfig.messageRequests; const showMsgRequestUI = useMsgRequests && !isApproved && messagesProps.length > 0; const handleDeclineConversationRequest = async () => { diff --git a/ts/components/leftpane/LeftPaneMessageSection.tsx b/ts/components/leftpane/LeftPaneMessageSection.tsx index 15f879c77..e415dd9ae 100644 --- a/ts/components/leftpane/LeftPaneMessageSection.tsx +++ b/ts/components/leftpane/LeftPaneMessageSection.tsx @@ -123,13 +123,11 @@ export class LeftPaneMessageSection extends React.Component { onChange={this.updateSearch} placeholder={window.i18n('searchFor...')} /> - {window.lokiFeatureFlags.useMessageRequests ? ( - { - window.inboxStore?.dispatch(setOverlayMode('message-requests')); - }} - /> - ) : null} + { + window.inboxStore?.dispatch(setOverlayMode('message-requests')); + }} + /> {this.renderList()} {this.renderBottomButtons()} diff --git a/ts/components/leftpane/overlay/OverlayMessageRequest.tsx b/ts/components/leftpane/overlay/OverlayMessageRequest.tsx index 2724fe9c9..fbcd4c7de 100644 --- a/ts/components/leftpane/overlay/OverlayMessageRequest.tsx +++ b/ts/components/leftpane/overlay/OverlayMessageRequest.tsx @@ -18,14 +18,7 @@ import useKey from 'react-use/lib/useKey'; * Blocks all message request conversations and synchronizes across linked devices * @returns void */ -async function handleBlockAllRequestsClick(messageRequestSetting: boolean) { - const messageRequestsEnabled = - messageRequestSetting && window?.lokiFeatureFlags?.useMessageRequests; - - if (!messageRequestsEnabled) { - return; - } - +async function handleBlockAllRequestsClick() { // block all convo requests. Force sync if there were changes. window?.log?.info('Blocking all conversations'); const conversations = getConversationController().getConversations(); diff --git a/ts/components/settings/section/CategoryPrivacy.tsx b/ts/components/settings/section/CategoryPrivacy.tsx index 64f2c5c05..1ae494594 100644 --- a/ts/components/settings/section/CategoryPrivacy.tsx +++ b/ts/components/settings/section/CategoryPrivacy.tsx @@ -57,8 +57,6 @@ export const SettingsCategoryPrivacy = (props: { const forceUpdate = useUpdate(); const dispatch = useDispatch(); - const hasMessageRequestFlag = window.lokiFeatureFlags.useMessageRequests; - if (props.hasPassword !== null) { return ( <> @@ -112,16 +110,23 @@ export const SettingsCategoryPrivacy = (props: { description={window.i18n('autoUpdateSettingDescription')} active={Boolean(window.getSettingValue(SettingsKey.settingsAutoUpdate))} /> - {hasMessageRequestFlag && ( - { - dispatch(toggleMessageRequests()); - }} - title={window.i18n('messageRequests')} - description={window.i18n('messageRequestsDescription')} - active={useSelector(getIsMessageRequestsEnabled)} - /> - )} + { + dispatch(toggleMessageRequests()); + }} + title={window.i18n('alwaysShowMessageRequests')} + description={window.i18n('messageRequestsDescription')} + active={useSelector(getIsMessageRequestsEnabled)} + /> + { + // TODO: open msg request inbox + }} + buttonColor={SessionButtonColor.Primary} + buttonText={window.i18n('openMessageRequestInbox')} + /> {!props.hasPassword && ( { ) { return false; } - const msgRequestsEnabled = - window.lokiFeatureFlags.useMessageRequests && - window.inboxStore?.getState().userConfig.messageRequests; + const msgRequestsEnabled = window.inboxStore?.getState().userConfig.messageRequests; // if msg requests are unused, we have to send typing (this is already a private active unblocked convo) if (!msgRequestsEnabled) { diff --git a/ts/receiver/configMessage.ts b/ts/receiver/configMessage.ts index 925a49db0..1b3f7822c 100644 --- a/ts/receiver/configMessage.ts +++ b/ts/receiver/configMessage.ts @@ -140,10 +140,7 @@ const handleContactReceived = async ( contactConvo.set('active_at', _.toNumber(envelope.timestamp)); } - if ( - window.lokiFeatureFlags.useMessageRequests && - window.inboxStore?.getState().userConfig.messageRequests - ) { + if (window.inboxStore?.getState().userConfig.messageRequests) { if (contactReceived.isApproved) { await contactConvo.setIsApproved(Boolean(contactReceived.isApproved)); diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 5a40e99bf..384bfb311 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -340,14 +340,11 @@ export const _getLeftPaneLists = ( let unreadCount = 0; for (const conversation of sortedConversations) { - const excludeUnapproved = - isMessageRequestEnabled && window.lokiFeatureFlags?.useMessageRequests; - if (conversation.activeAt !== undefined && conversation.type === ConversationTypeEnum.PRIVATE) { directConversations.push(conversation); } - if (excludeUnapproved && !conversation.isApproved && !conversation.isBlocked) { + if (isMessageRequestEnabled && !conversation.isApproved && !conversation.isBlocked) { // dont increase unread counter, don't push to convo list. continue; } @@ -434,11 +431,9 @@ const _getConversationRequests = ( sortedConversations: Array, isMessageRequestEnabled?: boolean ): Array => { - const pushToMessageRequests = - isMessageRequestEnabled && window?.lokiFeatureFlags?.useMessageRequests; return _.filter(sortedConversations, conversation => { return ( - pushToMessageRequests && + isMessageRequestEnabled && !conversation.isApproved && !conversation.isBlocked && conversation.isPrivate && @@ -457,17 +452,13 @@ const _getPrivateContactsPubkeys = ( sortedConversations: Array, isMessageRequestEnabled?: boolean ): Array => { - const pushToMessageRequests = - (isMessageRequestEnabled && window?.lokiFeatureFlags?.useMessageRequests) || - !isMessageRequestEnabled; - return _.filter(sortedConversations, conversation => { return ( conversation.isPrivate && !conversation.isBlocked && !conversation.isMe && - (conversation.didApproveMe || !pushToMessageRequests) && - (conversation.isApproved || !pushToMessageRequests) && + (conversation.didApproveMe || !isMessageRequestEnabled) && + (conversation.isApproved || !isMessageRequestEnabled) && Boolean(conversation.activeAt) ); }).map(convo => convo.id); diff --git a/ts/types/LocalizerKeys.ts b/ts/types/LocalizerKeys.ts index aa034d2fa..bab3caa5c 100644 --- a/ts/types/LocalizerKeys.ts +++ b/ts/types/LocalizerKeys.ts @@ -471,4 +471,7 @@ export type LocalizerKeys = | 'messageRequestAcceptedOurs' | 'messageRequestAcceptedOursNoName' | 'declineRequestMessage' + | 'openMessageRequestInbox' + | 'openMessageRequestInboxDescription' + | 'alwaysShowMessageRequests' | 'reportIssue';