|
|
|
@ -5,8 +5,12 @@ import { PropsData as SearchResultsProps } from '../SearchResults';
|
|
|
|
|
import { debounce } from 'lodash';
|
|
|
|
|
import { cleanSearchTerm } from '../../util/cleanSearchTerm';
|
|
|
|
|
import { SearchOptions } from '../../types/Search';
|
|
|
|
|
import { LeftPane, RowRendererParamsType } from '../LeftPane';
|
|
|
|
|
import { SessionButton, SessionButtonType, SessionButtonColor } from './SessionButton';
|
|
|
|
|
import { LeftPane } from '../LeftPane';
|
|
|
|
|
import {
|
|
|
|
|
SessionButton,
|
|
|
|
|
SessionButtonType,
|
|
|
|
|
SessionButtonColor,
|
|
|
|
|
} from './SessionButton';
|
|
|
|
|
import { AutoSizer, List } from 'react-virtualized';
|
|
|
|
|
|
|
|
|
|
export interface Props {
|
|
|
|
@ -35,6 +39,7 @@ export class LeftPaneContactSection extends React.Component<Props, any> {
|
|
|
|
|
|
|
|
|
|
this.debouncedSearch = debounce(this.search.bind(this), 20);
|
|
|
|
|
this.handleTabSelected = this.handleTabSelected.bind(this);
|
|
|
|
|
this.handleToggleOverlay = this.handleToggleOverlay.bind(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public componentWillUnmount() {
|
|
|
|
@ -42,29 +47,49 @@ export class LeftPaneContactSection extends React.Component<Props, any> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public handleTabSelected(tabType: number) {
|
|
|
|
|
this.setState({selectedTab: tabType});
|
|
|
|
|
this.setState({ selectedTab: tabType, showAddContactView: false });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public renderHeader(): JSX.Element|undefined {
|
|
|
|
|
public renderHeader(): JSX.Element | undefined {
|
|
|
|
|
const labels = [window.i18n('contactsHeader'), window.i18n('lists')];
|
|
|
|
|
return LeftPane.renderHeader(labels, this.handleTabSelected, undefined, null);
|
|
|
|
|
return LeftPane.renderHeader(
|
|
|
|
|
labels,
|
|
|
|
|
this.handleTabSelected,
|
|
|
|
|
undefined,
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public render(): JSX.Element {
|
|
|
|
|
return (
|
|
|
|
|
<div className="left-pane-contact-section">
|
|
|
|
|
{this.renderHeader()}
|
|
|
|
|
{this.state.showAddContactView || this.renderContacts()}
|
|
|
|
|
{this.state.showAddContactView
|
|
|
|
|
? LeftPane.renderClosableOverlay(
|
|
|
|
|
true,
|
|
|
|
|
undefined,
|
|
|
|
|
this.handleToggleOverlay,
|
|
|
|
|
undefined,
|
|
|
|
|
''
|
|
|
|
|
)
|
|
|
|
|
: this.renderContacts()}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private handleToggleOverlay() {
|
|
|
|
|
this.setState((prevState: { showAddContactView: any }) => ({
|
|
|
|
|
showAddContactView: !prevState.showAddContactView,
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private renderContacts() {
|
|
|
|
|
return (
|
|
|
|
|
<div className="left-pane-contact-content">
|
|
|
|
|
{this.renderList()}
|
|
|
|
|
{this.renderBottomButtons()}
|
|
|
|
|
</div>);
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private renderBottomButtons(): JSX.Element {
|
|
|
|
@ -74,11 +99,28 @@ export class LeftPaneContactSection extends React.Component<Props, any> {
|
|
|
|
|
const createGroup = window.i18n('createGroup');
|
|
|
|
|
return (
|
|
|
|
|
<div className="left-pane-contact-bottom-buttons">
|
|
|
|
|
<SessionButton text={edit} buttonType={SessionButtonType.SquareOutline} buttonColor={SessionButtonColor.White}/>
|
|
|
|
|
{selectedTab === 0 ? <SessionButton text={addContact} buttonType={SessionButtonType.SquareOutline} buttonColor={SessionButtonColor.Green}/> :
|
|
|
|
|
<SessionButton text={createGroup} buttonType={SessionButtonType.Square} buttonColor={SessionButtonColor.Green}/>}
|
|
|
|
|
<SessionButton
|
|
|
|
|
text={edit}
|
|
|
|
|
buttonType={SessionButtonType.SquareOutline}
|
|
|
|
|
buttonColor={SessionButtonColor.White}
|
|
|
|
|
/>
|
|
|
|
|
{selectedTab === 0 ? (
|
|
|
|
|
<SessionButton
|
|
|
|
|
text={addContact}
|
|
|
|
|
buttonType={SessionButtonType.SquareOutline}
|
|
|
|
|
buttonColor={SessionButtonColor.Green}
|
|
|
|
|
onClick={this.handleToggleOverlay}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<SessionButton
|
|
|
|
|
text={createGroup}
|
|
|
|
|
buttonType={SessionButtonType.SquareOutline}
|
|
|
|
|
buttonColor={SessionButtonColor.Green}
|
|
|
|
|
onClick={this.handleToggleOverlay}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getCurrentConversations():
|
|
|
|
@ -97,47 +139,50 @@ export class LeftPaneContactSection extends React.Component<Props, any> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private renderList() {
|
|
|
|
|
// const conversations = this.getCurrentConversations();
|
|
|
|
|
const conversations = this.getCurrentConversations();
|
|
|
|
|
|
|
|
|
|
// if (!conversations) {
|
|
|
|
|
// throw new Error(
|
|
|
|
|
// 'render: must provided conversations if no search results are provided'
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
if (!conversations) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
'render: must provided conversations if no search results are provided'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// const length = conversations.length;
|
|
|
|
|
// const listKey = 0;
|
|
|
|
|
console.log('conversations length;', conversations.length);
|
|
|
|
|
|
|
|
|
|
// Note: conversations is not a known prop for List, but it is required to ensure that
|
|
|
|
|
// it re-renders when our conversation data changes. Otherwise it would just render
|
|
|
|
|
// on startup and scroll.
|
|
|
|
|
const list = (
|
|
|
|
|
<div className="module-left-pane__list" key={0}>
|
|
|
|
|
<AutoSizer>
|
|
|
|
|
{({ height, width }) => (
|
|
|
|
|
<List
|
|
|
|
|
className="module-left-pane__virtual-list"
|
|
|
|
|
height={height}
|
|
|
|
|
rowCount={length}
|
|
|
|
|
rowHeight={64}
|
|
|
|
|
rowRenderer={this.renderRow}
|
|
|
|
|
width={width}
|
|
|
|
|
autoHeight={true}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</AutoSizer>
|
|
|
|
|
<AutoSizer>
|
|
|
|
|
{({ height, width }) => (
|
|
|
|
|
<List
|
|
|
|
|
className="module-left-pane__virtual-list"
|
|
|
|
|
height={height}
|
|
|
|
|
rowCount={conversations.length}
|
|
|
|
|
rowHeight={64}
|
|
|
|
|
rowRenderer={this.renderRow}
|
|
|
|
|
width={width}
|
|
|
|
|
autoHeight={true}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</AutoSizer>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return [list];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public renderRow() {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public renderRow = ({
|
|
|
|
|
// index,
|
|
|
|
|
// key,
|
|
|
|
|
// style,
|
|
|
|
|
}: RowRendererParamsType): JSX.Element|undefined => {
|
|
|
|
|
// public renderRow = ({
|
|
|
|
|
// ,
|
|
|
|
|
// }: // index,
|
|
|
|
|
// key,
|
|
|
|
|
// style,
|
|
|
|
|
// RowRendererParamsType): JSX.Element | undefined => {
|
|
|
|
|
// const { openConversationInternal } = this.props;
|
|
|
|
|
|
|
|
|
|
// const conversations = this.getCurrentConversations();
|
|
|
|
@ -157,10 +202,8 @@ export class LeftPaneContactSection extends React.Component<Props, any> {
|
|
|
|
|
// i18n={window.i18n}
|
|
|
|
|
// />
|
|
|
|
|
// );
|
|
|
|
|
return undefined;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return undefined;
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
public updateSearch(searchTerm: string) {
|
|
|
|
|
const { updateSearchTerm, clearSearch } = this.props;
|
|
|
|
|