Header Tools, Right Header: Remove Statistics from menu

This commit is contained in:
Alexander Zinchuk 2021-04-13 23:19:00 +03:00
parent 2a966e5119
commit 62b9766ec8
3 changed files with 3 additions and 52 deletions

View File

@ -40,7 +40,6 @@ interface StateProps {
canSearch?: boolean;
canMute?: boolean;
canSelect?: boolean;
canSeeStatistics?: boolean;
canLeave?: boolean;
}
@ -59,7 +58,6 @@ const HeaderActions: FC<OwnProps & StateProps & DispatchProps> = ({
canSearch,
canMute,
canSelect,
canSeeStatistics,
canLeave,
isRightColumnShown,
joinChannel,
@ -172,7 +170,6 @@ const HeaderActions: FC<OwnProps & StateProps & DispatchProps> = ({
canSearch={canSearch}
canMute={canMute}
canSelect={canSelect}
canSeeStatistics={canSeeStatistics}
canLeave={canLeave}
onSubscribeChannel={handleSubscribeClick}
onSearchClick={handleSearchClick}
@ -207,7 +204,6 @@ export default memo(withGlobal<OwnProps>(
const canSearch = isMainThread || isDiscussionThread;
const canMute = isMainThread && !isChatWithSelf && !canSubscribe;
const canSelect = !selectIsInSelectMode(global);
const canSeeStatistics = isMainThread;
const canLeave = isMainThread && !canSubscribe;
const noMenu = !(
@ -215,7 +211,6 @@ export default memo(withGlobal<OwnProps>(
|| (IS_MOBILE_SCREEN && canSearch)
|| canMute
|| canSelect
|| canSeeStatistics
|| canLeave
);
@ -228,7 +223,6 @@ export default memo(withGlobal<OwnProps>(
canSearch,
canMute,
canSelect,
canSeeStatistics,
canLeave,
};
},

View File

@ -22,7 +22,7 @@ import DeleteChatModal from '../common/DeleteChatModal';
import './HeaderMenuContainer.scss';
type DispatchProps = Pick<GlobalActions, 'updateChatMutedState' | 'toggleStatistics' | 'enterMessageSelectMode'>;
type DispatchProps = Pick<GlobalActions, 'updateChatMutedState' | 'enterMessageSelectMode'>;
export type OwnProps = {
chatId: number;
@ -34,7 +34,6 @@ export type OwnProps = {
canSearch?: boolean;
canMute?: boolean;
canSelect?: boolean;
canSeeStatistics?: boolean;
canLeave?: boolean;
onSubscribeChannel: () => void;
onSearchClick: () => void;
@ -58,7 +57,6 @@ const HeaderMenuContainer: FC<OwnProps & StateProps & DispatchProps> = ({
canSearch,
canMute,
canSelect,
canSeeStatistics,
canLeave,
chat,
isPrivate,
@ -69,7 +67,6 @@ const HeaderMenuContainer: FC<OwnProps & StateProps & DispatchProps> = ({
onClose,
onCloseAnimationEnd,
updateChatMutedState,
toggleStatistics,
enterMessageSelectMode,
}) => {
const [isMenuOpen, setIsMenuOpen] = useState(true);
@ -108,11 +105,6 @@ const HeaderMenuContainer: FC<OwnProps & StateProps & DispatchProps> = ({
closeMenu();
}, [closeMenu, onSearchClick]);
const handleStatistics = useCallback(() => {
toggleStatistics();
closeMenu();
}, [closeMenu, toggleStatistics]);
const handleSelectMessages = useCallback(() => {
enterMessageSelectMode();
closeMenu();
@ -167,14 +159,6 @@ const HeaderMenuContainer: FC<OwnProps & StateProps & DispatchProps> = ({
{lang('ReportSelectMessages')}
</MenuItem>
)}
{canSeeStatistics && (
<MenuItem
icon="poll"
onClick={handleStatistics}
>
{lang('Statistics')}
</MenuItem>
)}
{canLeave && (
<MenuItem
destructive
@ -213,7 +197,6 @@ export default memo(withGlobal<OwnProps>(
},
(setGlobal, actions): DispatchProps => pick(actions, [
'updateChatMutedState',
'toggleStatistics',
'enterMessageSelectMode',
]),
)(HeaderMenuContainer));

View File

@ -1,5 +1,5 @@
import React, {
FC, memo, useCallback, useEffect, useMemo, useRef, useState,
FC, memo, useCallback, useEffect, useRef, useState,
} from '../../lib/teact/teact';
import { withGlobal } from '../../lib/teact/teactn';
@ -25,8 +25,6 @@ import CalendarModal from '../common/CalendarModal.async';
import SearchInput from '../ui/SearchInput';
import Button from '../ui/Button';
import Transition from '../ui/Transition';
import DropdownMenu from '../ui/DropdownMenu';
import MenuItem from '../ui/MenuItem';
import './RightHeader.scss';
type OwnProps = {
@ -54,7 +52,7 @@ type StateProps = {
type DispatchProps = Pick<GlobalActions, (
'setLocalTextSearchQuery' | 'setStickerSearchQuery' | 'setGifSearchQuery' |
'searchTextMessagesLocal' | 'toggleManagement' | 'toggleStatistics' | 'searchMessagesByDate'
'searchTextMessagesLocal' | 'toggleManagement' | 'searchMessagesByDate'
)>;
const COLUMN_CLOSE_DELAY_MS = 300;
@ -106,7 +104,6 @@ const RightHeader: FC<OwnProps & StateProps & DispatchProps> = ({
setGifSearchQuery,
searchTextMessagesLocal,
toggleManagement,
toggleStatistics,
searchMessagesByDate,
}) => {
// eslint-disable-next-line no-null/no-null
@ -190,22 +187,6 @@ const RightHeader: FC<OwnProps & StateProps & DispatchProps> = ({
HeaderContent.Statistics
) : -1; // Never reached
const MenuButton: FC<{ onTrigger: () => void; isOpen?: boolean }> = useMemo(() => {
return ({ onTrigger, isOpen }) => (
<Button
round
ripple={!IS_MOBILE_SCREEN}
size="smaller"
color="translucent"
className={isOpen ? 'active' : undefined}
onClick={onTrigger}
ariaLabel={lang('Common.More')}
>
<i className="icon-more" />
</Button>
);
}, [lang]);
function renderHeaderContent() {
switch (contentKey) {
case HeaderContent.PollResults:
@ -289,12 +270,6 @@ const RightHeader: FC<OwnProps & StateProps & DispatchProps> = ({
<i className="icon-edit" />
</Button>
)}
<DropdownMenu
trigger={MenuButton}
positionX="right"
>
<MenuItem icon="poll" onClick={toggleStatistics}>{lang('Statistics')}</MenuItem>
</DropdownMenu>
</section>
</>
);
@ -380,7 +355,6 @@ export default memo(withGlobal<OwnProps>(
'setGifSearchQuery',
'searchTextMessagesLocal',
'toggleManagement',
'toggleStatistics',
'searchMessagesByDate',
]),
)(RightHeader));