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

View File

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