Adding improvements to message request handling.
This commit is contained in:
parent
2e2941ba9b
commit
9c9a43ee97
|
@ -447,5 +447,6 @@
|
|||
"blockAll": "Block All",
|
||||
"messageRequests": "Message Requests",
|
||||
"requestsSubtitle": "Pending Requests",
|
||||
"requestsPlaceholder": "No requests"
|
||||
"requestsPlaceholder": "No requests",
|
||||
"messageRequestsDescription": "Enable Message Request Inbox"
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ const InnerLeftPaneMessageSection = () => {
|
|||
<LeftPaneMessageSection
|
||||
conversations={lists?.conversations || []}
|
||||
contacts={lists?.contacts || []}
|
||||
conversationRequests={lists?.conversationRequests}
|
||||
searchResults={searchResults}
|
||||
searchTerm={searchTerm}
|
||||
/>
|
||||
|
|
|
@ -37,6 +37,7 @@ export interface Props {
|
|||
|
||||
contacts: Array<ReduxConversationType>;
|
||||
conversations?: Array<ConversationListItemProps>;
|
||||
conversationRequests?: Array<ConversationListItemProps>;
|
||||
searchResults?: SearchResultsProps;
|
||||
}
|
||||
|
||||
|
@ -281,13 +282,19 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -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<SettingsViewProps, State> {
|
|||
},
|
||||
{
|
||||
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,
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.isPublic && !conversation.activeAt) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if (conversation.activeAt !== undefined && conversation.type === ConversationTypeEnum.PRIVATE) {
|
||||
// directConversations.push(conversation);
|
||||
// }
|
||||
|
||||
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 (conversation.isApproved) {
|
||||
// conversations.push(conversation);
|
||||
// }
|
||||
if (
|
||||
unreadCount < 9 &&
|
||||
conversation.unreadCount &&
|
||||
conversation.unreadCount > 0 &&
|
||||
conversation.currentNotificationSetting !== 'disabled'
|
||||
) {
|
||||
unreadCount += conversation.unreadCount;
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue