From 3ec6c6523c63b60f050e4c1825b6a6abb4958d38 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 28 Apr 2021 14:03:22 +1000 Subject: [PATCH] remove addcontacts bottom buttons on contact page/useless --- .../session/LeftPaneContactSection.tsx | 96 +------------------ ts/components/session/PillDivider.tsx | 9 +- .../session/SessionClosableOverlay.tsx | 15 --- 3 files changed, 8 insertions(+), 112 deletions(-) diff --git a/ts/components/session/LeftPaneContactSection.tsx b/ts/components/session/LeftPaneContactSection.tsx index f4818a9b5..8e063ad71 100644 --- a/ts/components/session/LeftPaneContactSection.tsx +++ b/ts/components/session/LeftPaneContactSection.tsx @@ -12,6 +12,7 @@ import { LeftPaneSectionHeader } from './LeftPaneSectionHeader'; import { ConversationController } from '../../session/conversations'; import { PubKey } from '../../session/types'; import { ConversationType } from '../../models/conversation'; +import autoBind from 'auto-bind'; export interface Props { directContacts: Array; @@ -19,34 +20,10 @@ export interface Props { openConversationExternal: (id: string, messageId?: string) => void; } -interface State { - showAddContactView: boolean; - addContactRecipientID: string; - pubKeyPasted: string; -} - -export class LeftPaneContactSection extends React.Component { +export class LeftPaneContactSection extends React.Component { public constructor(props: Props) { super(props); - this.state = { - showAddContactView: false, - addContactRecipientID: '', - pubKeyPasted: '', - }; - - this.handleToggleOverlay = this.handleToggleOverlay.bind(this); - this.handleOnAddContact = this.handleOnAddContact.bind(this); - this.handleRecipientSessionIDChanged = this.handleRecipientSessionIDChanged.bind(this); - this.closeOverlay = this.closeOverlay.bind(this); - } - - public componentDidMount() { - window.Whisper.events.on('calculatingPoW', this.closeOverlay); - } - - public componentWillUnmount() { - this.setState({ addContactRecipientID: '' }); - window.Whisper.events.off('calculatingPoW', this.closeOverlay); + autoBind(this); } public renderHeader(): JSX.Element | undefined { @@ -57,7 +34,7 @@ export class LeftPaneContactSection extends React.Component { return (
{this.renderHeader()} - {this.state.showAddContactView ? this.renderClosableOverlay() : this.renderContacts()} + {this.renderContacts()}
); } @@ -77,71 +54,8 @@ export class LeftPaneContactSection extends React.Component { ); }; - private renderClosableOverlay() { - return ( - - ); - } - - private closeOverlay({ pubKey }: { pubKey: string }) { - if (this.state.addContactRecipientID === pubKey) { - this.setState({ showAddContactView: false, addContactRecipientID: '' }); - } - } - - private handleToggleOverlay() { - this.setState((prevState: { showAddContactView: boolean }) => ({ - showAddContactView: !prevState.showAddContactView, - })); - } - - private handleOnAddContact() { - const sessionID = this.state.addContactRecipientID.trim(); - const error = PubKey.validateWithError(sessionID, window.i18n); - - if (error) { - ToastUtils.pushToastError('addContact', error); - } else { - void ConversationController.getInstance() - .getOrCreateAndWait(sessionID, ConversationType.PRIVATE) - .then(() => { - this.props.openConversationExternal(sessionID); - }); - } - } - - private handleRecipientSessionIDChanged(value: string) { - this.setState({ addContactRecipientID: value }); - } - private renderContacts() { - return ( -
- {this.renderList()} - {this.renderBottomButtons()} -
- ); - } - - private renderBottomButtons(): JSX.Element { - const addContact = window.i18n('addContact'); - - return ( -
- -
- ); + return
{this.renderList()}
; } private renderList() { diff --git a/ts/components/session/PillDivider.tsx b/ts/components/session/PillDivider.tsx index f58394832..9d39d2bb6 100644 --- a/ts/components/session/PillDivider.tsx +++ b/ts/components/session/PillDivider.tsx @@ -1,13 +1,10 @@ import React from 'react'; -interface ReceivedProps { +type Props = { text: string; -} - -// Needed because of https://github.com/microsoft/tslint-microsoft-contrib/issues/339 -type Props = ReceivedProps; +}; -export const PillDivider: React.SFC = props => { +export const PillDivider = (props: Props) => { return (
diff --git a/ts/components/session/SessionClosableOverlay.tsx b/ts/components/session/SessionClosableOverlay.tsx index 08579b7a0..2dddfd715 100644 --- a/ts/components/session/SessionClosableOverlay.tsx +++ b/ts/components/session/SessionClosableOverlay.tsx @@ -13,7 +13,6 @@ import { DefaultTheme } from 'styled-components'; import { UserUtils } from '../../session/utils'; export enum SessionClosableOverlayType { - Contact = 'contact', Message = 'message', OpenGroup = 'open-group', ClosedGroup = 'closed-group', @@ -109,7 +108,6 @@ export class SessionClosableOverlay extends React.Component { onButtonClick, } = this.props; - const isAddContactView = overlayMode === SessionClosableOverlayType.Contact; const isMessageView = overlayMode === SessionClosableOverlayType.Message; const isOpenGroupView = overlayMode === SessionClosableOverlayType.OpenGroup; const isClosedGroupView = overlayMode === SessionClosableOverlayType.ClosedGroup; @@ -127,13 +125,6 @@ export class SessionClosableOverlay extends React.Component { subtitle = window.i18n('enterSessionID'); placeholder = window.i18n('enterSessionIDOfRecipient'); break; - case 'contact': - title = window.i18n('addContact'); - buttonText = window.i18n('next'); - descriptionLong = window.i18n('usersCanShareTheir...'); - subtitle = window.i18n('enterSessionID'); - placeholder = window.i18n('enterSessionIDOfRecipient'); - break; case 'open-group': title = window.i18n('joinOpenGroup'); buttonText = window.i18n('next'); @@ -237,12 +228,6 @@ export class SessionClosableOverlay extends React.Component { /> )} - {isAddContactView && } - - {isAddContactView && ( - - )} -