diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index dba5ec8dc..1dc5dc183 100644
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -447,5 +447,6 @@
"blockAll": "Block All",
"messageRequests": "Message Requests",
"requestsSubtitle": "Pending Requests",
- "requestsPlaceholder": "No requests"
+ "requestsPlaceholder": "No requests",
+ "messageRequestsDescription": "Enable Message Request Inbox"
}
diff --git a/ts/components/LeftPane.tsx b/ts/components/LeftPane.tsx
index 271485155..30623f91f 100644
--- a/ts/components/LeftPane.tsx
+++ b/ts/components/LeftPane.tsx
@@ -34,6 +34,7 @@ const InnerLeftPaneMessageSection = () => {
diff --git a/ts/components/session/LeftPaneMessageSection.tsx b/ts/components/session/LeftPaneMessageSection.tsx
index b78208892..d47566c98 100644
--- a/ts/components/session/LeftPaneMessageSection.tsx
+++ b/ts/components/session/LeftPaneMessageSection.tsx
@@ -37,6 +37,7 @@ export interface Props {
contacts: Array;
conversations?: Array;
+ conversationRequests?: Array;
searchResults?: SearchResultsProps;
}
@@ -281,13 +282,19 @@ export class LeftPaneMessageSection extends React.Component {
this.handleToggleOverlay(undefined);
}}
onButtonClick={async () => {
+ window?.log?.info('Blocking all conversations');
// TODO: msgrequest iterate all convos and block
// iterate all conversations and set all to approve then
- const allConversations = getConversationController().getConversations();
+ const { conversationRequests } = this.props;
let syncRequired = false;
- _.forEach(allConversations, convo => {
- if (convo.isApproved() !== true) {
+ if (!conversationRequests) {
+ window?.log?.info('No conversation requests to block.');
+ return;
+ }
+
+ _.forEach(conversationRequests, convo => {
+ if (convo.isApproved !== true) {
BlockedNumberController.block(convo.id);
syncRequired = true;
}
diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx
index 5c6228ee0..8e4df3739 100644
--- a/ts/components/session/settings/SessionSettings.tsx
+++ b/ts/components/session/settings/SessionSettings.tsx
@@ -17,11 +17,7 @@ import {
import { shell } from 'electron';
import { mapDispatchToProps } from '../../../state/actions';
import { unblockConvoById } from '../../../interactions/conversationInteractions';
-import {
- disableMessageRequests,
- enableMessageRequests,
- toggleAudioAutoplay,
-} from '../../../state/ducks/userConfig';
+import { toggleAudioAutoplay, toggleMessageRequests } from '../../../state/ducks/userConfig';
import { sessionPassword, updateConfirmModal } from '../../../state/ducks/modalDialog';
import { PasswordAction } from '../../dialog/SessionPasswordDialog';
import { SessionIconButton } from '../icon';
@@ -412,22 +408,16 @@ class SettingsViewInner extends React.Component {
},
{
id: 'message-request-setting',
- title: 'Message Requests', // TODO: translation
- description: 'Enable Message Request Inbox',
+ title: window.i18n('messageRequests'),
+ description: window.i18n('messageRequestsDescription'),
hidden: false,
type: SessionSettingType.Toggle,
category: SessionSettingCategory.Appearance,
setFn: () => {
- window.inboxStore?.dispatch(toggleAudioAutoplay());
-
- if (window.inboxStore?.getState().userConfig.messageRequests) {
- window.inboxStore?.dispatch(disableMessageRequests());
- } else {
- window.inboxStore?.dispatch(enableMessageRequests());
- }
+ window.inboxStore?.dispatch(toggleMessageRequests());
},
content: {
- defaultValue: window.inboxStore?.getState().userConfig.audioAutoplay,
+ defaultValue: window.inboxStore?.getState().userConfig.messageRequests,
},
comparisonValue: undefined,
onClick: undefined,
diff --git a/ts/receiver/configMessage.ts b/ts/receiver/configMessage.ts
index 37f0e2637..eb7ce798b 100644
--- a/ts/receiver/configMessage.ts
+++ b/ts/receiver/configMessage.ts
@@ -125,7 +125,7 @@ const handleContactReceived = async (
// updateProfile will do a commit for us
contactConvo.set('active_at', _.toNumber(envelope.timestamp));
- if (window.lokiFeatureFlags.useMessageRequests === true) {
+ if (window.lokiFeatureFlags.useMessageRequests === true && window.inboxStore?.getState().userConfig.messageRequests) {
contactConvo.setIsApproved(Boolean(contactReceived.isApproved));
if (contactReceived.isBlocked === true) {
diff --git a/ts/state/ducks/userConfig.tsx b/ts/state/ducks/userConfig.tsx
index 8628dcd20..57af32fdc 100644
--- a/ts/state/ducks/userConfig.tsx
+++ b/ts/state/ducks/userConfig.tsx
@@ -26,20 +26,12 @@ const userConfigSlice = createSlice({
disableRecoveryPhrasePrompt: state => {
state.showRecoveryPhrasePrompt = false;
},
- disableMessageRequests: state => {
- state.messageRequests = false;
- },
- enableMessageRequests: state => {
- state.messageRequests = false;
+ toggleMessageRequests: state => {
+ state.messageRequests = !state.messageRequests;
},
},
});
const { actions, reducer } = userConfigSlice;
-export const {
- toggleAudioAutoplay,
- disableRecoveryPhrasePrompt,
- disableMessageRequests,
- enableMessageRequests,
-} = actions;
+export const { toggleAudioAutoplay, disableRecoveryPhrasePrompt, toggleMessageRequests } = actions;
export const userConfigReducer = reducer;
diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts
index bf9f20e52..7c76033b9 100644
--- a/ts/state/selectors/conversations.ts
+++ b/ts/state/selectors/conversations.ts
@@ -304,49 +304,44 @@ export const _getLeftPaneLists = (
};
}
+ // TODO: if message requests toggle on and msg requesnt enable
const messageRequestsEnabled =
window.inboxStore?.getState().userConfig.messageRequests === true &&
- window?.lokiFeatureFlags?.useMessageRequests === true;
-
- // if (!Boolean(conversation.isApproved) === true && window.lokiFeatureFlags.useMessageRequests) {
- // continue;
- // }
+ window.lokiFeatureFlags?.useMessageRequests === true;
// Add Open Group to list as soon as the name has been set
- // if (conversation.isPublic && (!conversation.name || conversation.name === 'Unknown group')) {
- // continue;
- // }
-
- // if (!conversation.isApproved && !conversation.isBlocked) {
- // conversationRequests.push(conversation);
- // }
-
- if (shouldShowInRequestList(conversation, messageRequestsEnabled)) {
- conversationRequests.push(conversation);
+ if (conversation.isPublic && (!conversation.name || conversation.name === 'Unknown group')) {
+ continue;
}
// Remove all invalid conversations and conversatons of devices associated
// with cancelled attempted links
- // if (!conversation.isPublic && !conversation.activeAt) {
- // continue;
- // }
-
- // if (conversation.activeAt !== undefined && conversation.type === ConversationTypeEnum.PRIVATE) {
- // directConversations.push(conversation);
- // }
+ if (!conversation.isPublic && !conversation.activeAt) {
+ continue;
+ }
- if (shouldShowInContacts(conversation)) {
+ if (conversation.activeAt !== undefined && conversation.type === ConversationTypeEnum.PRIVATE) {
directConversations.push(conversation);
}
- if (shouldShowInConversationList(conversation, messageRequestsEnabled)) {
- conversations.push(conversation);
- unreadCount = calculateNewUnreadTotal(unreadCount, conversation);
+ if (messageRequestsEnabled) {
+ if (!conversation.isApproved && !conversation.isBlocked) {
+ // dont increase unread counter, don't push to convo list.
+ conversationRequests.push(conversation);
+ continue;
+ }
+ }
+
+ if (
+ unreadCount < 9 &&
+ conversation.unreadCount &&
+ conversation.unreadCount > 0 &&
+ conversation.currentNotificationSetting !== 'disabled'
+ ) {
+ unreadCount += conversation.unreadCount;
}
- // if (conversation.isApproved) {
- // conversations.push(conversation);
- // }
+ conversations.push(conversation);
}
return {
@@ -357,84 +352,6 @@ export const _getLeftPaneLists = (
};
};
-const calculateNewUnreadTotal = (unreadCount: number, conversation: ReduxConversationType) => {
- if (
- unreadCount < 9 &&
- conversation.unreadCount &&
- conversation.unreadCount > 0 &&
- conversation.currentNotificationSetting !== 'disabled'
- ) {
- unreadCount += conversation.unreadCount;
- }
- return unreadCount;
-};
-
-const shouldShowInRequestList = (
- conversation: ReduxConversationType,
- messageRequestsEnabled: boolean
-) => {
- if (conversation.isPublic || conversation.isBlocked || Boolean(conversation.activeAt) === false) {
- return false;
- }
-
- if (messageRequestsEnabled) {
- if (Boolean(conversation.isApproved || !conversation.isBlocked)) {
- return false;
- }
- }
- return true;
-};
-
-const shouldShowInContacts = (conversation: ReduxConversationType) => {
- // Add Open Group to list as soon as the name has been set
- if (conversation.isPublic && (!conversation.name || conversation.name === 'Unknown group')) {
- return false;
- }
-
- // if (shouldShowInRequestList(conversation)) {
- // conversationRequests.push(conversation);
- // }
-
- // Remove all invalid conversations and conversatons of devices associated
- // with cancelled attempted links
- if (!conversation.isPublic && !conversation.activeAt) {
- return false;
- }
-
- if (conversation.activeAt !== undefined && conversation.type === ConversationTypeEnum.PRIVATE) {
- // directConversations.push(conversation);
- return true;
- } else {
- return false;
- }
-};
-
-const shouldShowInConversationList = (
- conversation: ReduxConversationType,
- messageRequestsEnabled: boolean
-) => {
- // // Add Open Group to list as soon as the name has been set
- if (conversation.isPublic && (!conversation.name || conversation.name === 'Unknown group')) {
- return false;
- }
-
- // Remove all invalid conversations and conversatons of devices associated
- // with cancelled attempted links
- if (!conversation.isPublic && !conversation.activeAt) {
- return false;
- }
-
- // if (!conversation.activeAt) {
- // return false;
- // }
-
- if (messageRequestsEnabled && !conversation.isApproved) {
- return false;
- }
-
- return true;
-};
-
export const getLeftPaneLists = createSelector(
getConversationLookup,
getConversationComparator,