Merge pull request #1343 from Bilb/close-overlay-message-sent

pull/1345/head
Audric Ackermann 5 years ago committed by GitHub
commit 789461bd7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -40,7 +40,6 @@ export interface Props {
interface State { interface State {
showAddContactView: boolean; showAddContactView: boolean;
selectedTab: number;
addContactRecipientID: string; addContactRecipientID: string;
pubKeyPasted: string; pubKeyPasted: string;
} }
@ -52,27 +51,33 @@ export class LeftPaneContactSection extends React.Component<Props, State> {
super(props); super(props);
this.state = { this.state = {
showAddContactView: false, showAddContactView: false,
selectedTab: 0,
addContactRecipientID: '', addContactRecipientID: '',
pubKeyPasted: '', pubKeyPasted: '',
}; };
this.debouncedSearch = debounce(this.search.bind(this), 20); this.debouncedSearch = debounce(this.search.bind(this), 20);
this.handleTabSelected = this.handleTabSelected.bind(this);
this.handleToggleOverlay = this.handleToggleOverlay.bind(this); this.handleToggleOverlay = this.handleToggleOverlay.bind(this);
this.handleOnAddContact = this.handleOnAddContact.bind(this); this.handleOnAddContact = this.handleOnAddContact.bind(this);
this.handleRecipientSessionIDChanged = this.handleRecipientSessionIDChanged.bind( this.handleRecipientSessionIDChanged = this.handleRecipientSessionIDChanged.bind(
this this
); );
this.closeOverlay = this.closeOverlay.bind(this);
}
public componentDidMount() {
MainViewController.renderMessageView();
window.Whisper.events.on('calculatingPoW', this.closeOverlay);
}
public componentDidUpdate() {
MainViewController.renderMessageView();
} }
public componentWillUnmount() { public componentWillUnmount() {
this.updateSearch(''); this.updateSearch('');
this.setState({ addContactRecipientID: '' }); this.setState({ addContactRecipientID: '' });
} window.Whisper.events.off('calculatingPoW', this.closeOverlay);
public handleTabSelected(tabType: number) {
this.setState({ selectedTab: tabType, showAddContactView: false });
} }
public renderHeader(): JSX.Element | undefined { public renderHeader(): JSX.Element | undefined {
@ -80,7 +85,7 @@ export class LeftPaneContactSection extends React.Component<Props, State> {
return LeftPane.RENDER_HEADER( return LeftPane.RENDER_HEADER(
labels, labels,
this.handleTabSelected, null,
undefined, undefined,
undefined, undefined,
undefined, undefined,
@ -88,14 +93,6 @@ export class LeftPaneContactSection extends React.Component<Props, State> {
); );
} }
public componentDidMount() {
MainViewController.renderMessageView();
}
public componentDidUpdate() {
MainViewController.renderMessageView();
}
public render(): JSX.Element { public render(): JSX.Element {
return ( return (
<div className="left-pane-contact-section"> <div className="left-pane-contact-section">
@ -182,6 +179,12 @@ export class LeftPaneContactSection extends React.Component<Props, State> {
); );
} }
private closeOverlay({ pubKey }: { pubKey: string }) {
if (this.state.addContactRecipientID === pubKey) {
this.setState({ showAddContactView: false, addContactRecipientID: '' });
}
}
private handleToggleOverlay() { private handleToggleOverlay() {
this.setState((prevState: { showAddContactView: boolean }) => ({ this.setState((prevState: { showAddContactView: boolean }) => ({
showAddContactView: !prevState.showAddContactView, showAddContactView: !prevState.showAddContactView,
@ -217,7 +220,6 @@ export class LeftPaneContactSection extends React.Component<Props, State> {
} }
private renderBottomButtons(): JSX.Element { private renderBottomButtons(): JSX.Element {
const { selectedTab } = this.state;
const addContact = window.i18n('addContact'); const addContact = window.i18n('addContact');
return ( return (

@ -93,10 +93,21 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
this.renderClosableOverlay = this.renderClosableOverlay.bind(this); this.renderClosableOverlay = this.renderClosableOverlay.bind(this);
this.debouncedSearch = debounce(this.search.bind(this), 20); this.debouncedSearch = debounce(this.search.bind(this), 20);
this.closeOverlay = this.closeOverlay.bind(this);
}
public componentDidMount() {
MainViewController.renderMessageView();
window.Whisper.events.on('calculatingPoW', this.closeOverlay);
}
public componentDidUpdate() {
MainViewController.renderMessageView();
} }
public componentWillUnmount() { public componentWillUnmount() {
this.updateSearch(''); this.updateSearch('');
window.Whisper.events.off('calculatingPoW', this.closeOverlay);
} }
public renderRow = ({ public renderRow = ({
@ -176,12 +187,10 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
return [list]; return [list];
} }
public componentDidMount() { public closeOverlay({ pubKey }: { pubKey: string }) {
MainViewController.renderMessageView(); if (this.state.valuePasted === pubKey) {
} this.setState({ overlay: false, valuePasted: '' });
}
public componentDidUpdate() {
MainViewController.renderMessageView();
} }
public renderHeader(): JSX.Element { public renderHeader(): JSX.Element {

Loading…
Cancel
Save