Spam Reporting UI changes
This commit is contained in:
parent
e031d136a1
commit
8387f938eb
88 changed files with 2711 additions and 807 deletions
84
ts/state/smart/MessageRequestActionsConfirmation.tsx
Normal file
84
ts/state/smart/MessageRequestActionsConfirmation.tsx
Normal file
|
@ -0,0 +1,84 @@
|
|||
// Copyright 2024 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
import { getIntl } from '../selectors/user';
|
||||
import { getGlobalModalsState } from '../selectors/globalModals';
|
||||
import { getConversationSelector } from '../selectors/conversations';
|
||||
import { useConversationsActions } from '../ducks/conversations';
|
||||
import {
|
||||
MessageRequestActionsConfirmation,
|
||||
MessageRequestState,
|
||||
} from '../../components/conversation/MessageRequestActionsConfirmation';
|
||||
import { useContactNameData } from '../../components/conversation/ContactName';
|
||||
import { getAddedByForOurPendingInvitation } from '../../util/getAddedByForOurPendingInvitation';
|
||||
import { strictAssert } from '../../util/assert';
|
||||
import { useGlobalModalActions } from '../ducks/globalModals';
|
||||
|
||||
export function SmartMessageRequestActionsConfirmation(): JSX.Element | null {
|
||||
const i18n = useSelector(getIntl);
|
||||
const globalModals = useSelector(getGlobalModalsState);
|
||||
const { messageRequestActionsConfirmationProps } = globalModals;
|
||||
strictAssert(
|
||||
messageRequestActionsConfirmationProps,
|
||||
'messageRequestActionsConfirmationProps are required'
|
||||
);
|
||||
const { conversationId, state } = messageRequestActionsConfirmationProps;
|
||||
strictAssert(state !== MessageRequestState.default, 'state is required');
|
||||
const getConversation = useSelector(getConversationSelector);
|
||||
const conversation = getConversation(conversationId);
|
||||
const addedBy = useMemo(() => {
|
||||
if (conversation.type === 'group') {
|
||||
return getAddedByForOurPendingInvitation(conversation);
|
||||
}
|
||||
return null;
|
||||
}, [conversation]);
|
||||
|
||||
const conversationName = useContactNameData(conversation);
|
||||
strictAssert(conversationName, 'conversationName is required');
|
||||
const addedByName = useContactNameData(addedBy);
|
||||
|
||||
const {
|
||||
acceptConversation,
|
||||
blockConversation,
|
||||
reportSpam,
|
||||
blockAndReportSpam,
|
||||
deleteConversation,
|
||||
} = useConversationsActions();
|
||||
const { toggleMessageRequestActionsConfirmation } = useGlobalModalActions();
|
||||
|
||||
const handleChangeState = useCallback(
|
||||
(nextState: MessageRequestState) => {
|
||||
if (nextState === MessageRequestState.default) {
|
||||
toggleMessageRequestActionsConfirmation(null);
|
||||
} else {
|
||||
toggleMessageRequestActionsConfirmation({
|
||||
conversationId,
|
||||
state: nextState,
|
||||
});
|
||||
}
|
||||
},
|
||||
[conversationId, toggleMessageRequestActionsConfirmation]
|
||||
);
|
||||
|
||||
return (
|
||||
<MessageRequestActionsConfirmation
|
||||
i18n={i18n}
|
||||
conversationId={conversation.id}
|
||||
conversationType={conversation.type}
|
||||
conversationName={conversationName}
|
||||
addedByName={addedByName}
|
||||
isBlocked={conversation.isBlocked ?? false}
|
||||
isReported={conversation.isReported ?? false}
|
||||
acceptConversation={acceptConversation}
|
||||
blockConversation={blockConversation}
|
||||
reportSpam={reportSpam}
|
||||
blockAndReportSpam={blockAndReportSpam}
|
||||
deleteConversation={deleteConversation}
|
||||
state={state}
|
||||
onChangeState={handleChangeState}
|
||||
/>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue