Requesting flow working with sending message as acceptance.
parent
cdeac8f424
commit
d627b8e11d
@ -0,0 +1,44 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { PropsForMessageRequestResponse } from '../../../../models/messageType';
|
||||||
|
import { getConversationController } from '../../../../session/conversations';
|
||||||
|
import { UserUtils } from '../../../../session/utils';
|
||||||
|
import { Flex } from '../../../basic/Flex';
|
||||||
|
import { SpacerSM, Text } from '../../../basic/Text';
|
||||||
|
import { ReadableMessage } from './ReadableMessage';
|
||||||
|
|
||||||
|
export const MessageRequestResponse = (props: PropsForMessageRequestResponse) => {
|
||||||
|
const { messageId, isUnread, receivedAt, conversationId, source } = props;
|
||||||
|
|
||||||
|
let profileName = '';
|
||||||
|
if (conversationId) {
|
||||||
|
profileName =
|
||||||
|
getConversationController()
|
||||||
|
.get(conversationId)
|
||||||
|
.getProfileName() + '';
|
||||||
|
}
|
||||||
|
const msgText =
|
||||||
|
profileName && props.source === UserUtils.getOurPubKeyStrFromCache()
|
||||||
|
? window.i18n('messageRequestAcceptedOurs', [profileName])
|
||||||
|
: window.i18n('messageRequestAccepted');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ReadableMessage
|
||||||
|
messageId={messageId}
|
||||||
|
receivedAt={receivedAt}
|
||||||
|
isUnread={isUnread}
|
||||||
|
key={`readable-message-${messageId}`}
|
||||||
|
>
|
||||||
|
<Flex
|
||||||
|
container={true}
|
||||||
|
flexDirection="row"
|
||||||
|
alignItems="center"
|
||||||
|
justifyContent="center"
|
||||||
|
margin={'var(--margins-sm)'}
|
||||||
|
id={`msg-${messageId}`}
|
||||||
|
>
|
||||||
|
<SpacerSM />
|
||||||
|
<Text text={msgText} subtle={true} ellipsisOverflow={true} />
|
||||||
|
</Flex>
|
||||||
|
</ReadableMessage>
|
||||||
|
);
|
||||||
|
};
|
@ -1,64 +0,0 @@
|
|||||||
import React, { useContext } from 'react';
|
|
||||||
import {
|
|
||||||
approveConversation,
|
|
||||||
blockConvoById,
|
|
||||||
} from '../../../interactions/conversationInteractions';
|
|
||||||
import { forceSyncConfigurationNowIfNeeded } from '../../../session/utils/syncUtils';
|
|
||||||
import { SessionIconButton } from '../../icon';
|
|
||||||
import { ContextConversationId } from './ConversationListItem';
|
|
||||||
|
|
||||||
const RejectMessageRequestButton = () => {
|
|
||||||
const conversationId = useContext(ContextConversationId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes conversation from requests list,
|
|
||||||
* adds ID to block list, syncs the block with linked devices.
|
|
||||||
*/
|
|
||||||
const handleConversationBlock = async () => {
|
|
||||||
await blockConvoById(conversationId);
|
|
||||||
await forceSyncConfigurationNowIfNeeded();
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<SessionIconButton
|
|
||||||
iconType="exit"
|
|
||||||
iconSize="large"
|
|
||||||
onClick={handleConversationBlock}
|
|
||||||
backgroundColor="var(--color-destructive)"
|
|
||||||
iconColor="var(--color-foreground-primary)"
|
|
||||||
iconPadding="var(--margins-xs)"
|
|
||||||
borderRadius="2px"
|
|
||||||
margin="0 5px 0 0"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const ApproveMessageRequestButton = () => {
|
|
||||||
const conversationId = useContext(ContextConversationId);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<SessionIconButton
|
|
||||||
iconType="check"
|
|
||||||
iconSize="large"
|
|
||||||
onClick={async () => {
|
|
||||||
await approveConversation(conversationId);
|
|
||||||
}}
|
|
||||||
backgroundColor="var(--color-accent)"
|
|
||||||
iconColor="var(--color-foreground-primary)"
|
|
||||||
iconPadding="var(--margins-xs)"
|
|
||||||
borderRadius="2px"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const MessageRequestButtons = ({ isMessageRequest }: { isMessageRequest: boolean }) => {
|
|
||||||
if (!isMessageRequest) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<RejectMessageRequestButton />
|
|
||||||
<ApproveMessageRequestButton />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
Loading…
Reference in New Issue