import React from 'react'; import classNames from 'classnames'; import { LeftPane } from '../LeftPane'; import { SessionButton, SessionButtonColor, SessionButtonType, } from './SessionButton'; import { SessionIcon, SessionIconSize, SessionIconType } from './icon'; import { SessionSearchInput } from './SessionSearchInput'; import { SessionSettingCategory } from './settings/SessionSettings'; import { DefaultTheme } from 'styled-components'; import { LeftPaneSectionHeader } from './LeftPaneSectionHeader'; interface Props { settingsCategory: SessionSettingCategory; showSessionSettingsCategory: (category: SessionSettingCategory) => void; theme: DefaultTheme; } export interface State { searchQuery: string; } export class LeftPaneSettingSection extends React.Component { public constructor(props: any) { super(props); this.state = { searchQuery: '', }; this.setCategory = this.setCategory.bind(this); this.onDeleteAccount = this.onDeleteAccount.bind(this); } public render(): JSX.Element { return (
{this.renderHeader()} {this.renderSettings()}
); } public renderHeader(): JSX.Element | undefined { return ( ); } public renderRow(item: any): JSX.Element { const { settingsCategory } = this.props; return (
{ this.setCategory(item.id); }} >
{item.title}
{item.id === settingsCategory && ( )}
); } public renderCategories(): JSX.Element { const categories = this.getCategories().filter(item => !item.hidden); return (
{categories.map(item => this.renderRow(item))}
); } public renderSearch() { return (
null} placeholder="" theme={this.props.theme} />
); } public renderSettings(): JSX.Element { const showSearch = false; return (
{showSearch && this.renderSearch()} {this.renderCategories()} {this.renderBottomButtons()}
); } public renderBottomButtons(): JSX.Element | undefined { const dangerButtonText = window.i18n('clearAllData'); const showRecoveryPhrase = window.i18n('showRecoveryPhrase'); return (
window.Whisper.events.trigger('showSeedDialog')} />
); } public onDeleteAccount() { const title = window.i18n('clearAllData'); const message = window.i18n('unpairDeviceWarning'); let messageSub = ''; const identityKey = window.textsecure.storage.get('identityKey'); if (identityKey && identityKey.ed25519KeyPair === undefined) { messageSub = "We've updated the way Session IDs are generated, so you will not be able to restore your current Session ID."; } window.confirmationDialog({ title, message, messageSub, resolve: window.deleteAccount, okTheme: 'danger', }); } public getCategories() { return [ { id: SessionSettingCategory.Appearance, title: window.i18n('appearanceSettingsTitle'), hidden: false, }, { id: SessionSettingCategory.Privacy, title: window.i18n('privacySettingsTitle'), hidden: false, }, { id: SessionSettingCategory.Blocked, title: window.i18n('blockedSettingsTitle'), hidden: false, }, { id: SessionSettingCategory.Permissions, title: window.i18n('permissionSettingsTitle'), hidden: true, }, { id: SessionSettingCategory.Notifications, title: window.i18n('notificationsSettingsTitle'), hidden: false, }, ]; } public setCategory(category: SessionSettingCategory) { this.props.showSessionSettingsCategory(category); } }