Refactoring subcomponents. Adjusting conditional inbox filters to always apply msg request logic.
parent
ac8c4ac2eb
commit
07f6681aae
@ -0,0 +1,83 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import {
|
||||||
|
acceptConversation,
|
||||||
|
blockConvoById,
|
||||||
|
declineConversation,
|
||||||
|
} from '../../interactions/conversationInteractions';
|
||||||
|
import { forceSyncConfigurationNowIfNeeded } from '../../session/utils/syncUtils';
|
||||||
|
import { ReduxConversationType } from '../../state/ducks/conversations';
|
||||||
|
import { updateConfirmModal } from '../../state/ducks/modalDialog';
|
||||||
|
import { SessionButton, SessionButtonColor, SessionButtonType } from '../basic/SessionButton';
|
||||||
|
|
||||||
|
export const ConversationMessageRequestButtons = (props: {
|
||||||
|
selectedConversation: ReduxConversationType;
|
||||||
|
}) => {
|
||||||
|
const { selectedConversation } = props;
|
||||||
|
const { isApproved, type } = selectedConversation;
|
||||||
|
const showMsgRequestUI = !isApproved && type === 'private';
|
||||||
|
|
||||||
|
const handleDeclineConversationRequest = async () => {
|
||||||
|
window.inboxStore?.dispatch(
|
||||||
|
updateConfirmModal({
|
||||||
|
okText: window.i18n('decline'),
|
||||||
|
cancelText: window.i18n('cancel'),
|
||||||
|
message: window.i18n('declineRequestMessage'),
|
||||||
|
onClickOk: async () => {
|
||||||
|
await declineConversation(selectedConversation.id, false);
|
||||||
|
await blockConvoById(selectedConversation.id);
|
||||||
|
await forceSyncConfigurationNowIfNeeded();
|
||||||
|
},
|
||||||
|
onClickCancel: () => {
|
||||||
|
window.inboxStore?.dispatch(updateConfirmModal(null));
|
||||||
|
},
|
||||||
|
onClickClose: () => {
|
||||||
|
window.inboxStore?.dispatch(updateConfirmModal(null));
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAcceptConversationRequest = async () => {
|
||||||
|
const { id } = selectedConversation;
|
||||||
|
await acceptConversation(id, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!showMsgRequestUI) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ConversationRequestBanner>
|
||||||
|
<ConversationBannerRow>
|
||||||
|
<SessionButton
|
||||||
|
buttonColor={SessionButtonColor.Green}
|
||||||
|
buttonType={SessionButtonType.BrandOutline}
|
||||||
|
onClick={handleAcceptConversationRequest}
|
||||||
|
text={window.i18n('accept')}
|
||||||
|
/>
|
||||||
|
<SessionButton
|
||||||
|
buttonColor={SessionButtonColor.Danger}
|
||||||
|
buttonType={SessionButtonType.BrandOutline}
|
||||||
|
text={window.i18n('decline')}
|
||||||
|
onClick={handleDeclineConversationRequest}
|
||||||
|
/>
|
||||||
|
</ConversationBannerRow>
|
||||||
|
</ConversationRequestBanner>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ConversationBannerRow = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: var(--margins-lg);
|
||||||
|
justify-content: center;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ConversationRequestBanner = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
padding: var(--margins-lg);
|
||||||
|
gap: var(--margins-lg);
|
||||||
|
`;
|
@ -0,0 +1,34 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { ReduxConversationType } from '../../state/ducks/conversations';
|
||||||
|
|
||||||
|
export const ConversationRequestinfo = (props: { selectedConversation: ReduxConversationType }) => {
|
||||||
|
const { selectedConversation } = props;
|
||||||
|
const { isApproved, type } = selectedConversation;
|
||||||
|
const showMsgRequestUI = !isApproved && type === 'private';
|
||||||
|
|
||||||
|
if (!showMsgRequestUI) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ConversationRequestTextBottom>
|
||||||
|
<ConversationRequestTextInner>
|
||||||
|
{window.i18n('respondingToRequestWarning')}
|
||||||
|
</ConversationRequestTextInner>
|
||||||
|
</ConversationRequestTextBottom>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ConversationRequestTextBottom = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: center;
|
||||||
|
padding: var(--margins-lg);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ConversationRequestTextInner = styled.div`
|
||||||
|
color: var(--color-text-subtle);
|
||||||
|
text-align: center;
|
||||||
|
max-width: 390px;
|
||||||
|
`;
|
Loading…
Reference in New Issue