Group settings: on block and leave, don't delete

This commit is contained in:
Scott Nonnenberg 2021-04-28 13:27:16 -07:00 committed by GitHub
parent 4978fae69c
commit 3face767aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 29 deletions

View file

@ -68,8 +68,8 @@ const createProps = (hasGroupLink = false): Props => ({
updateGroupAttributes: async () => {
action('updateGroupAttributes')();
},
onBlockAndDelete: action('onBlockAndDelete'),
onDelete: action('onDelete'),
onBlock: action('onBlock'),
onLeave: action('onLeave'),
});
story.add('Basic', () => {

View file

@ -55,8 +55,8 @@ export type StateProps = {
title?: string;
}>
) => Promise<void>;
onBlockAndDelete: () => void;
onDelete: () => void;
onBlock: () => void;
onLeave: () => void;
};
export type Props = StateProps;
@ -78,8 +78,8 @@ export const ConversationDetails: React.ComponentType<Props> = ({
showPendingInvites,
showLightboxForMedia,
updateGroupAttributes,
onBlockAndDelete,
onDelete,
onBlock,
onLeave,
}) => {
const [modalState, setModalState] = useState<ModalState>(
ModalState.NothingOpen
@ -301,8 +301,8 @@ export const ConversationDetails: React.ComponentType<Props> = ({
i18n={i18n}
cannotLeaveBecauseYouAreLastAdmin={cannotLeaveBecauseYouAreLastAdmin}
conversationTitle={conversation.title}
onDelete={onDelete}
onBlockAndDelete={onBlockAndDelete}
onLeave={onLeave}
onBlock={onBlock}
/>
{modalNode}

View file

@ -28,8 +28,8 @@ const createProps = (overrideProps: Partial<Props> = {}): Props => ({
? overrideProps.cannotLeaveBecauseYouAreLastAdmin
: false,
conversationTitle: overrideProps.conversationTitle || '',
onBlockAndDelete: action('onBlockAndDelete'),
onDelete: action('onDelete'),
onBlock: action('onBlock'),
onLeave: action('onLeave'),
i18n,
});

View file

@ -15,16 +15,16 @@ import { ConversationDetailsIcon } from './ConversationDetailsIcon';
export type Props = {
cannotLeaveBecauseYouAreLastAdmin: boolean;
conversationTitle: string;
onBlockAndDelete: () => void;
onDelete: () => void;
onBlock: () => void;
onLeave: () => void;
i18n: LocalizerType;
};
export const ConversationDetailsActions: React.ComponentType<Props> = ({
cannotLeaveBecauseYouAreLastAdmin,
conversationTitle,
onBlockAndDelete,
onDelete,
onBlock,
onLeave,
i18n,
}) => {
const [confirmingLeave, setConfirmingLeave] = React.useState<boolean>(false);
@ -94,7 +94,7 @@ export const ConversationDetailsActions: React.ComponentType<Props> = ({
text: i18n(
'ConversationDetailsActions--leave-group-modal-confirm'
),
action: onDelete,
action: onLeave,
style: 'affirmative',
},
]}
@ -113,7 +113,7 @@ export const ConversationDetailsActions: React.ComponentType<Props> = ({
text: i18n(
'ConversationDetailsActions--block-group-modal-confirm'
),
action: onBlockAndDelete,
action: onBlock,
style: 'affirmative',
},
]}

View file

@ -36,8 +36,8 @@ export type SmartConversationDetailsProps = {
title?: string;
}>
) => Promise<void>;
onBlockAndDelete: () => void;
onDelete: () => void;
onBlock: () => void;
onLeave: () => void;
};
const mapStateToProps = (

View file

@ -3067,22 +3067,19 @@ Whisper.ConversationView = Whisper.View.extend({
// these methods are used in more than one place and should probably be
// dried up and hoisted to methods on ConversationView
const onDelete = () => {
const onLeave = () => {
this.longRunningTaskWrapper({
name: 'onDelete',
task: this.model.syncMessageRequestResponse.bind(
this.model,
messageRequestEnum.DELETE
),
name: 'onLeave',
task: () => this.model.leaveGroupV2(),
});
};
const onBlockAndDelete = () => {
const onBlock = () => {
this.longRunningTaskWrapper({
name: 'onBlockAndDelete',
name: 'onBlock',
task: this.model.syncMessageRequestResponse.bind(
this.model,
messageRequestEnum.BLOCK_AND_DELETE
messageRequestEnum.BLOCK
),
});
};
@ -3110,8 +3107,8 @@ Whisper.ConversationView = Whisper.View.extend({
updateGroupAttributes: conversation.updateGroupAttributesV2.bind(
conversation
),
onDelete,
onBlockAndDelete,
onLeave,
onBlock,
};
const view = new Whisper.ReactWrapperView({