mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Add confirmation dialog for clear all message requests.
This commit is contained in:
parent
79c1c52034
commit
5888fecda4
3 changed files with 51 additions and 32 deletions
|
@ -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,38 +13,7 @@ import { forceSyncConfigurationNowIfNeeded } from '../../../session/utils/syncUt
|
|||
import { BlockedNumberController } from '../../../util';
|
||||
import useKey from 'react-use/lib/useKey';
|
||||
import { ReduxConversationType } from '../../../state/ducks/conversations';
|
||||
|
||||
/**
|
||||
* Blocks all message request conversations and synchronizes across linked devices
|
||||
* @returns void
|
||||
*/
|
||||
async function handleBlockAllRequestsClick(convoRequests: Array<ReduxConversationType>) {
|
||||
window?.log?.info('Blocking all conversations');
|
||||
if (!convoRequests) {
|
||||
window?.log?.info('No conversation requests to block.');
|
||||
return;
|
||||
}
|
||||
|
||||
let syncRequired = false;
|
||||
const convoController = getConversationController();
|
||||
await Promise.all(
|
||||
convoRequests.map(async convo => {
|
||||
const { id } = convo;
|
||||
const convoModel = convoController.get(id);
|
||||
if (!convoModel.isBlocked()) {
|
||||
await BlockedNumberController.block(id);
|
||||
await convoModel.commit();
|
||||
}
|
||||
await convoModel.setIsApproved(false);
|
||||
|
||||
syncRequired = true;
|
||||
})
|
||||
);
|
||||
|
||||
if (syncRequired) {
|
||||
await forceSyncConfigurationNowIfNeeded();
|
||||
}
|
||||
}
|
||||
import { updateConfirmModal } from '../../../state/ducks/modalDialog';
|
||||
|
||||
export const OverlayMessageRequest = () => {
|
||||
useKey('Escape', closeOverlay);
|
||||
|
@ -57,6 +26,52 @@ export const OverlayMessageRequest = () => {
|
|||
|
||||
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.');
|
||||
return;
|
||||
}
|
||||
|
||||
let syncRequired = false;
|
||||
const convoController = getConversationController();
|
||||
await Promise.all(
|
||||
convoRequests.map(async convo => {
|
||||
const { id } = convo;
|
||||
const convoModel = convoController.get(id);
|
||||
if (!convoModel.isBlocked()) {
|
||||
await BlockedNumberController.block(id);
|
||||
await convoModel.commit();
|
||||
}
|
||||
await convoModel.setIsApproved(false);
|
||||
|
||||
syncRequired = true;
|
||||
})
|
||||
);
|
||||
|
||||
if (syncRequired) {
|
||||
await forceSyncConfigurationNowIfNeeded();
|
||||
}
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="module-left-pane-overlay">
|
||||
{hasRequests ? (
|
||||
|
|
|
@ -479,4 +479,6 @@ export type LocalizerKeys =
|
|||
| 'noMediaUntilApproved'
|
||||
| 'mustBeApproved'
|
||||
| 'youHaveANewFriendRequest'
|
||||
| 'clearAllConfirmationTitle'
|
||||
| 'clearAllConfirmationBody'
|
||||
| 'reportIssue';
|
||||
|
|
Loading…
Reference in a new issue