Middle Header: Hide tools when selecting messages to prevent history loss

This commit is contained in:
Alexander Zinchuk 2021-08-27 21:08:44 +03:00
parent 44adc496b6
commit 6728fd4e2a
2 changed files with 8 additions and 18 deletions

View File

@ -43,7 +43,6 @@ interface StateProps {
canSubscribe?: boolean;
canSearch?: boolean;
canMute?: boolean;
canSelect?: boolean;
canLeave?: boolean;
}
@ -62,7 +61,6 @@ const HeaderActions: FC<OwnProps & StateProps & DispatchProps> = ({
canSubscribe,
canSearch,
canMute,
canSelect,
canLeave,
isRightColumnShown,
joinChannel,
@ -191,7 +189,6 @@ const HeaderActions: FC<OwnProps & StateProps & DispatchProps> = ({
canSubscribe={canSubscribe}
canSearch={canSearch}
canMute={canMute}
canSelect={canSelect}
canLeave={canLeave}
onSubscribeChannel={handleSubscribeClick}
onSearchClick={handleSearchClick}
@ -208,7 +205,7 @@ export default memo(withGlobal<OwnProps>(
const chat = selectChat(global, chatId);
const isChannel = Boolean(chat && isChatChannel(chat));
if (chat?.isRestricted) {
if (chat?.isRestricted || selectIsInSelectMode(global)) {
return {
noMenu: true,
};
@ -227,14 +224,12 @@ export default memo(withGlobal<OwnProps>(
);
const canSearch = isMainThread || isDiscussionThread;
const canMute = isMainThread && !isChatWithSelf && !canSubscribe;
const canSelect = !selectIsInSelectMode(global);
const canLeave = isMainThread && !canSubscribe;
const noMenu = !(
(IS_SINGLE_COLUMN_LAYOUT && canSubscribe)
|| (IS_SINGLE_COLUMN_LAYOUT && canSearch)
|| canMute
|| canSelect
|| canLeave
);
@ -247,7 +242,6 @@ export default memo(withGlobal<OwnProps>(
canSubscribe,
canSearch,
canMute,
canSelect,
canLeave,
};
},

View File

@ -37,7 +37,6 @@ export type OwnProps = {
canSubscribe?: boolean;
canSearch?: boolean;
canMute?: boolean;
canSelect?: boolean;
canLeave?: boolean;
onSubscribeChannel: () => void;
onSearchClick: () => void;
@ -62,7 +61,6 @@ const HeaderMenuContainer: FC<OwnProps & StateProps & DispatchProps> = ({
canSubscribe,
canSearch,
canMute,
canSelect,
canLeave,
chat,
isPrivate,
@ -183,14 +181,12 @@ const HeaderMenuContainer: FC<OwnProps & StateProps & DispatchProps> = ({
{lang(isMuted ? 'ChatsUnmute' : 'ChatsMute')}
</MenuItem>
)}
{canSelect && (
<MenuItem
icon="select"
onClick={handleSelectMessages}
>
{lang('ReportSelectMessages')}
</MenuItem>
)}
<MenuItem
icon="select"
onClick={handleSelectMessages}
>
{lang('ReportSelectMessages')}
</MenuItem>
{canLeave && (
<MenuItem
destructive
@ -198,7 +194,7 @@ const HeaderMenuContainer: FC<OwnProps & StateProps & DispatchProps> = ({
onClick={handleDelete}
>
{lang(isPrivate
? 'Delete'
? 'DeleteChatUser'
: (canDeleteChat ? 'GroupInfo.DeleteAndExit' : (isChannel ? 'LeaveChannel' : 'Group.LeaveGroup')))}
</MenuItem>
)}