Add confirmation dialog for clear all message requests.

pull/2222/head
warrickct 3 years ago
parent 79c1c52034
commit 5888fecda4

@ -476,5 +476,7 @@
"noMediaUntilApproved": "You cannot send attachments until the conversation is approved",
"mustBeApproved": "This conversation must be accepted to use this feature",
"youHaveANewFriendRequest": "You have a new friend request",
"clearAllConfirmationTitle": "Clear All Message Requests",
"clearAllConfirmationBody": "Are you sure you want to clear all message requests?",
"openMessageRequestInboxDescription": "View your Message Request inbox"
}

@ -13,12 +13,35 @@ import { forceSyncConfigurationNowIfNeeded } from '../../../session/utils/syncUt
import { BlockedNumberController } from '../../../util';
import useKey from 'react-use/lib/useKey';
import { ReduxConversationType } from '../../../state/ducks/conversations';
import { updateConfirmModal } from '../../../state/ducks/modalDialog';
export const OverlayMessageRequest = () => {
useKey('Escape', closeOverlay);
const dispatch = useDispatch();
function closeOverlay() {
dispatch(setOverlayMode(undefined));
}
const hasRequests = useSelector(getConversationRequests).length > 0;
const messageRequests = useSelector(getConversationRequests);
const buttonText = window.i18n('clearAll');
/**
* Blocks all message request conversations and synchronizes across linked devices
* @returns void
*/
async function handleBlockAllRequestsClick(convoRequests: Array<ReduxConversationType>) {
const { i18n } = window;
const title = i18n('clearAllConfirmationTitle');
const message = i18n('clearAllConfirmationBody');
const onClose = dispatch(updateConfirmModal(null));
dispatch(
updateConfirmModal({
title,
message,
onClose,
onClickOk: async () => {
window?.log?.info('Blocking all conversations');
if (!convoRequests) {
window?.log?.info('No conversation requests to block.');
@ -44,19 +67,11 @@ async function handleBlockAllRequestsClick(convoRequests: Array<ReduxConversatio
if (syncRequired) {
await forceSyncConfigurationNowIfNeeded();
}
},
})
);
}
export const OverlayMessageRequest = () => {
useKey('Escape', closeOverlay);
const dispatch = useDispatch();
function closeOverlay() {
dispatch(setOverlayMode(undefined));
}
const hasRequests = useSelector(getConversationRequests).length > 0;
const messageRequests = useSelector(getConversationRequests);
const buttonText = window.i18n('clearAll');
return (
<div className="module-left-pane-overlay">
{hasRequests ? (

@ -479,4 +479,6 @@ export type LocalizerKeys =
| 'noMediaUntilApproved'
| 'mustBeApproved'
| 'youHaveANewFriendRequest'
| 'clearAllConfirmationTitle'
| 'clearAllConfirmationBody'
| 'reportIssue';

Loading…
Cancel
Save