Theme toggle and settings abstraction

pull/717/head
Vincent 6 years ago
parent bbf5f8a9f2
commit 8de2ce9e23

@ -821,7 +821,8 @@
}; };
window.showSeedDialog = window.owsDesktopApp.appView.showSeedDialog; window.showSeedDialog = window.owsDesktopApp.appView.showSeedDialog;
window.showAddServerDialog = window.owsDesktopApp.appView.showAddServerDialog; window.showAddServerDialog =
window.owsDesktopApp.appView.showAddServerDialog;
window.generateID = () => window.generateID = () =>
Math.random() Math.random()
@ -874,10 +875,24 @@
}; };
window.deleteAccount = async () => { window.deleteAccount = async () => {
try {
window.log.info('Deleting everything!');
const { Logs } = window.Signal;
await Logs.deleteAll();
await window.Signal.Data.removeAll(); await window.Signal.Data.removeAll();
await window.storage.fetch(); await window.Signal.Data.close();
await window.Signal.Data.removeDB();
alert('YOUR ACCOUNT HAS BEEN DELETED'); await window.Signal.Data.removeOtherData();
} catch (error) {
window.log.error(
'Something went wrong deleting all data:',
error && error.stack ? error.stack : error
);
}
window.restart();
}; };
window.toggleTheme = () => { window.toggleTheme = () => {

@ -7,8 +7,7 @@
window.Whisper = window.Whisper || {}; window.Whisper = window.Whisper || {};
Whisper.ConversationLoadingScreen = Whisper.View.extend({ Whisper.ConversationLoadingScreen = Whisper.View.extend({
initialize() { initialize() {},
},
render() { render() {
this.toastView = new Whisper.ReactWrapperView({ this.toastView = new Whisper.ReactWrapperView({
@ -19,7 +18,5 @@
this.$el.append(this.toastView.el); this.$el.append(this.toastView.el);
}, },
}); });
})(); })();

@ -143,7 +143,6 @@
this.loadingScreen.render(); this.loadingScreen.render();
this.loadingScreen.$el.prependTo(this.$('.discussion-container')); this.loadingScreen.$el.prependTo(this.$('.discussion-container'));
this.window = options.window; this.window = options.window;
this.fileInput = new Whisper.FileInputView({ this.fileInput = new Whisper.FileInputView({
el: this.$('.attachment-list'), el: this.$('.attachment-list'),

@ -27,28 +27,35 @@
// Has been opened since app sart, but not focussed // Has been opened since app sart, but not focussed
const conversationExists = container.children(`#${id}`).length > 0; const conversationExists = container.children(`#${id}`).length > 0;
// Is focussed // Is focussed
const conversationOpened = container.children().first().id === id const conversationOpened = container.children().first().id === id;
// To limit the size of the DOM for speed // To limit the size of the DOM for speed
const maxNumConversations = 10; const maxNumConversations = 10;
const numConversations = container.children().not('.conversation.placeholder').length; const numConversations = container
.children()
.not('.conversation.placeholder').length;
const shouldTrimConversations = numConversations > maxNumConversations; const shouldTrimConversations = numConversations > maxNumConversations;
if (shouldTrimConversations){ if (shouldTrimConversations) {
// Removes conversation which has been hidden the longest // Removes conversation which has been hidden the longest
container.children()[numConversations - 1].remove(); container.children()[numConversations - 1].remove();
} }
if (conversationExists) { if (conversationExists) {
// User opened conversation, move it to top of stack, rather than re-rendering // User opened conversation, move it to top of stack, rather than re-rendering
const conversations = container.children().not('.conversation.placeholder'); const conversations = container
container.children(`#${id}`).first().insertBefore(conversations.first()); .children()
.not('.conversation.placeholder');
container
.children(`#${id}`)
.first()
.insertBefore(conversations.first());
conversation.trigger('opened'); conversation.trigger('opened');
return; return;
} }
if (! conversationOpened) { if (!conversationOpened) {
this.$el this.$el
.first() .first()
.find('video, audio') .find('video, audio')
@ -68,7 +75,6 @@
} }
container.prepend($el); container.prepend($el);
} }
conversation.trigger('opened'); conversation.trigger('opened');
}, },
@ -103,7 +109,6 @@
}, },
}); });
Whisper.InboxView = Whisper.View.extend({ Whisper.InboxView = Whisper.View.extend({
templateName: 'two-column', templateName: 'two-column',
className: 'inbox index', className: 'inbox index',

@ -185,6 +185,32 @@ ipc.on('remove-dark-overlay', () => {
} }
}); });
window.getSettingValue = settingID => {
console.log("EXECUTED");
console.log("EXECUTED");
console.log("EXECUTED");
console.log("EXECUTED");
const theme = window.storage.get('theme-setting', 'dark');
console.log(`THEME: ${theme}`);
console.log(`THEME: ${theme}`);
console.log(`THEME: ${theme}`);
console.log(`THEME: ${theme}`);
console.log(`THEME: ${theme}`);
if (settingID === 'theme'){
const theme = window.storage.get('theme-setting', 'dark');
console.log(`THEME: ${theme}`);
}
}
window.setSettingValue = settingID => {
const those = settingID;
return those;
}
installGetter('device-name', 'getDeviceName'); installGetter('device-name', 'getDeviceName');
installGetter('theme-setting', 'getThemeSetting'); installGetter('theme-setting', 'getThemeSetting');

@ -243,7 +243,7 @@ $session_message-container-border-radius: 5px;
border: 2px solid $session-color-green; border: 2px solid $session-color-green;
background-color: $session-color-green; background-color: $session-color-green;
&.disabled{ &.disabled {
background-color: rgba($session-color-green, 0.6); background-color: rgba($session-color-green, 0.6);
} }
@ -253,37 +253,37 @@ $session_message-container-border-radius: 5px;
} }
&.white { &.white {
background-color: $session-color-white; background-color: $session-color-white;
&.disabled{ &.disabled {
background-color: rgba($session-color-white, 0.6); background-color: rgba($session-color-white, 0.6);
} }
} }
&.primary { &.primary {
background-color: $session-color-primary; background-color: $session-color-primary;
&.disabled{ &.disabled {
background-color: rgba($session-color-primary, 0.6); background-color: rgba($session-color-primary, 0.6);
} }
} }
&.secondary { &.secondary {
background-color: $session-color-secondary; background-color: $session-color-secondary;
&.disabled{ &.disabled {
background-color: rgba($session-color-secondary, 0.6); background-color: rgba($session-color-secondary, 0.6);
} }
} }
&.success { &.success {
background-color: $session-color-success; background-color: $session-color-success;
&.disabled{ &.disabled {
background-color: rgba($session-color-success, 0.6); background-color: rgba($session-color-success, 0.6);
} }
} }
&.danger { &.danger {
background-color: $session-color-danger; background-color: $session-color-danger;
&.disabled{ &.disabled {
background-color: rgba($session-color-danger, 0.6); background-color: rgba($session-color-danger, 0.6);
} }
} }
&.warning { &.warning {
background-color: $session-color-warning; background-color: $session-color-warning;
&.disabled{ &.disabled {
background-color: rgba($session-color-warning, 0.6); background-color: rgba($session-color-warning, 0.6);
} }
} }
@ -886,7 +886,6 @@ label {
margin-left: 75px; margin-left: 75px;
} }
.conversation-loader { .conversation-loader {
height: 100%; height: 100%;
margin-top: 45vh; margin-top: 45vh;
@ -894,7 +893,7 @@ label {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
&>div{ & > div {
display: block; display: block;
} }
} }
@ -956,7 +955,6 @@ label {
} }
} }
.session-settings { .session-settings {
width: 100%; width: 100%;
height: 100vh; height: 100vh;
@ -1036,21 +1034,16 @@ label {
transition: $session-transition-duration !important; transition: $session-transition-duration !important;
} }
.network-status-container {
.network-status-container{
} }
.discussion-container { .discussion-container {
.module-message { .module-message {
font-family: SFPro; font-family: SFPro;
border-radius: 5px; border-radius: 5px;
} }
} }
.bottom-bar textarea.send-message { .bottom-bar textarea.send-message {
height: 60px; height: 60px;
background-color: $session-shade-4; background-color: $session-shade-4;

@ -13,7 +13,6 @@ $session-compose-margin: 20px;
@include session-dark-background-hover; @include session-dark-background-hover;
} }
} }
} }
.gutter { .gutter {
width: 380px !important; width: 380px !important;
@ -71,8 +70,6 @@ $session-compose-margin: 20px;
@at-root .dark-theme #{&} { @at-root .dark-theme #{&} {
color: $session-shade-17; color: $session-shade-17;
} }
} }
&__header__name--with-unread .module-conversation__user__profile-number, &__header__name--with-unread .module-conversation__user__profile-number,
@ -112,12 +109,10 @@ $session-compose-margin: 20px;
@at-root .dark-theme #{&} { @at-root .dark-theme #{&} {
color: $session-color-white; color: $session-color-white;
} }
} }
} }
.inbox { .inbox {
@at-root .light-theme #{&} { @at-root .light-theme #{&} {
color: $session-color-black; color: $session-color-black;
} }
@ -126,7 +121,6 @@ $session-compose-margin: 20px;
} }
} }
.module-left-pane { .module-left-pane {
border-right: none !important; border-right: none !important;
width: 300px; width: 300px;
@ -404,7 +398,6 @@ $session-compose-margin: 20px;
color: $session-color-light-grey; color: $session-color-light-grey;
} }
&-selected, &-selected,
&:hover { &:hover {
font-weight: bold; font-weight: bold;
@ -417,7 +410,6 @@ $session-compose-margin: 20px;
color: $session-color-white; color: $session-color-white;
background: $session-shade-8; background: $session-shade-8;
} }
} }
} }
} }

@ -28,7 +28,6 @@
&__metadata__badge, &__metadata__badge,
&__metadata__date--incoming, &__metadata__date--incoming,
&__metadata__date--outgoing { &__metadata__date--outgoing {
@at-root .light-theme #{&} { @at-root .light-theme #{&} {
@include session-color-subtle($session-color-black); @include session-color-subtle($session-color-black);
} }
@ -53,7 +52,6 @@
@at-root .dark-theme #{&} { @at-root .dark-theme #{&} {
background-color: $session-shade-11; background-color: $session-shade-11;
} }
} }
&__container { &__container {

@ -208,7 +208,6 @@ $session-compose-margin: 20px;
flex-shrink: 0; flex-shrink: 0;
} }
} }
} }
.user-search-dropdown { .user-search-dropdown {
@ -438,4 +437,3 @@ $session-compose-margin: 20px;
border: 1px solid $session-color-dark-grey; border: 1px solid $session-color-dark-grey;
} }
} }

@ -35,7 +35,6 @@ body.dark-theme {
} }
.bottom-bar { .bottom-bar {
form.send { form.send {
&.video-attachment { &.video-attachment {
.outer { .outer {

@ -2,14 +2,12 @@ import React from 'react';
import { SessionSpinner } from './session/SessionSpinner'; import { SessionSpinner } from './session/SessionSpinner';
export class ConversationLoadingScreen extends React.PureComponent { export class ConversationLoadingScreen extends React.PureComponent {
constructor(props: any) { constructor(props: any) {
super(props); super(props);
} }
public render() { public render() {
return ( return (
<div className="conversation-loader"> <div className="conversation-loader">
<SessionSpinner /> <SessionSpinner />

@ -2,148 +2,25 @@ import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { import {
SessionSettingListItem, SessionSettingCategory,
SessionSettingType, SettingsView,
} from './session/settings/SessionSettingListItem'; } from './session/settings/SessionSettings';
import { SessionSettingCategory } from './session/LeftPaneSettingSection';
import { SessionButtonColor } from './session/SessionButton';
import { SessionIconButton, SessionIconType, SessionIconSize } from './session/icon';
// Grab initial values from database on startup
const localSettings = [
{
id: 'typingIndicators',
title: 'Typing Indicators',
description:
'See and share when messages are being typed. This setting is optional and applies to all conversations.',
type: SessionSettingType.Toggle,
category: SessionSettingCategory.Privacy,
value: false,
},
{
id: 'screenLock',
title: 'Screen Lock',
description:
'Unlock Loki Session using your password. Visit notification settings to customise.',
type: SessionSettingType.Toggle,
category: SessionSettingCategory.Privacy,
value: true,
},
{
id: 'screenSecurity',
title: 'Screen Security',
description:
'Prevent Loki Session previews from appearing in desktop notifications.',
type: SessionSettingType.Toggle,
category: SessionSettingCategory.Privacy,
value: false,
},
{
id: 'linkPreviews',
title: 'Send Link Previews',
description:
'Supported for Imgur, Instagram, Pinterest, Reddit and YouTube.',
type: SessionSettingType.Toggle,
category: SessionSettingCategory.Privacy,
value: true,
},
{
id: 'clearConversationHistory',
title: 'Clear Conversation History',
category: SessionSettingCategory.Privacy,
type: SessionSettingType.Button,
value: false,
buttonText: 'Clear',
buttonColor: SessionButtonColor.Danger,
},
{
id: 'changePassword',
title: 'Change Password',
category: SessionSettingCategory.Account,
type: SessionSettingType.Button,
value: false,
buttonText: 'Change',
buttonColor: SessionButtonColor.Primary,
},
{
id: 'removePassword',
title: 'Remove Password',
category: SessionSettingCategory.Account,
type: SessionSettingType.Button,
value: false,
buttonText: 'Remove',
buttonColor: SessionButtonColor.Danger,
},
];
export class MainViewController { export class MainViewController {
constructor() {}
public static renderMessageView() { static renderMessageView() {
ReactDOM.render( ReactDOM.render(<MessageView />, document.getElementById('main-view'));
<MessageView/>,
document.getElementById('main-view')
);
} }
public static renderSettingsView(category: SessionSettingCategory) { static renderSettingsView(category: SessionSettingCategory) {
ReactDOM.render( ReactDOM.render(
<SettingsView category={category}/>, <SettingsView category={category} />,
document.getElementById('main-view') document.getElementById('main-view')
); );
} }
} }
interface SettingsViewProps {
category: SessionSettingCategory
}
export class SettingsView extends React.Component<SettingsViewProps>{
public settingsViewRef: React.RefObject<HTMLDivElement>;
public constructor(props: any) {
super(props);
this.settingsViewRef = React.createRef();
}
render() {
const { category } = this.props;
return (
<div className="session-settings">
<SettingsHeader category={category}/>
<div
ref = {this.settingsViewRef}
className="session-settings-list"
>
{localSettings.map(setting => {
return (
<div key={setting.id}>
{setting.category === category && (
<SessionSettingListItem
title={setting.title}
description={setting.description}
type={setting.type}
value={setting.value}
onClick={() => {
SettingsManager.updateSetting(setting);
}}
buttonText={setting.buttonText || undefined}
buttonColor={setting.buttonColor || undefined}
/>
)}
</div>
);
})}
</div>
</div>
)
}
}
export class MessageView extends React.Component { export class MessageView extends React.Component {
render() { render() {
return ( return (
@ -155,6 +32,7 @@ export class MessageView extends React.Component {
<img <img
src="images/session/brand.svg" src="images/session/brand.svg"
className="session-filter-color-green session-logo-128" className="session-filter-color-green session-logo-128"
alt="Brand"
/> />
<p className="session-logo-text">SESSION</p> <p className="session-logo-text">SESSION</p>
</div> </div>
@ -164,50 +42,3 @@ export class MessageView extends React.Component {
); );
} }
} }
export class SettingsHeader extends React.Component<SettingsViewProps>{
public constructor(props: any) {
super(props);
}
public focusSearch(){
$('.left-pane-setting-section .session-search-input input').focus();
}
render() {
const category = String(this.props.category)
const categoryTitlePrefix = category[0].toUpperCase() + category.substr(1);
// Remove 's' on the end to keep words in singular form
const categoryTitle = categoryTitlePrefix[categoryTitlePrefix.length - 1] === 's'
? categoryTitlePrefix.slice(0, -1) + ' Settings'
: categoryTitlePrefix + ' Settings';
return (
<div className="session-settings-header">
{ categoryTitle }
<SessionIconButton
iconType={SessionIconType.Search}
iconSize={SessionIconSize.Large}
onClick={this.focusSearch}
/>
</div>
);
}
}
export class SettingsManager {
public static updateSetting({ id, type, value }) {
if (type === SessionSettingType.Toggle) {
alert(`You clicked a toggle with ID: ${id}`);
// Manage toggle events
return;
}
alert('you clicked something else');
return;
}
}

@ -17,7 +17,7 @@ import { cleanSearchTerm } from '../../util/cleanSearchTerm';
import { SearchOptions } from '../../types/Search'; import { SearchOptions } from '../../types/Search';
import { validateNumber } from '../../types/PhoneNumber'; import { validateNumber } from '../../types/PhoneNumber';
import { LeftPane, RowRendererParamsType } from '../LeftPane'; import { LeftPane, RowRendererParamsType } from '../LeftPane';
import { SessionButton, SessionButtonType, SessionButtonColor } from './SessionButton'; import { SessionButton, SessionButtonType } from './SessionButton';
export interface Props { export interface Props {
searchTerm: string; searchTerm: string;
@ -146,18 +146,6 @@ export class LeftPaneMessageSection extends React.Component<Props, any> {
return [list]; return [list];
} }
public renderMessagePanelButtons(): JSX.Element {
return (
<div className="module-left-pane__header-buttons">
<SessionButton
text={window.i18n('showAddServer')}
buttonType={SessionButtonType.Square}
onClick={window.showAddServerDialog}
/>
</div>
);
}
public renderHeader(): JSX.Element { public renderHeader(): JSX.Element {
const labels = [window.i18n('messagesHeader')]; const labels = [window.i18n('messagesHeader')];
@ -193,7 +181,6 @@ export class LeftPaneMessageSection extends React.Component<Props, any> {
public renderConversations() { public renderConversations() {
return ( return (
<div> <div>
{this.renderMessagePanelButtons()}
<SessionSearchInput <SessionSearchInput
searchString={this.props.searchTerm} searchString={this.props.searchTerm}
onChange={this.updateSearchBound} onChange={this.updateSearchBound}

@ -13,14 +13,7 @@ import {
import { SessionIcon, SessionIconSize, SessionIconType } from './icon'; import { SessionIcon, SessionIconSize, SessionIconType } from './icon';
import { SessionSearchInput } from './SessionSearchInput'; import { SessionSearchInput } from './SessionSearchInput';
import { SessionSettingCategory } from './settings/SessionSettings';
export enum SessionSettingCategory {
General = 'general',
Account = 'account',
Privacy = 'privacy',
Notifications = 'notifications',
Devices = 'devices',
}
export interface Props {} export interface Props {}

@ -55,7 +55,12 @@ export class SessionButton extends React.PureComponent<Props> {
return ( return (
<div <div
className={classNames('session-button', ...buttonTypes, buttonColor, disabled && 'disabled')} className={classNames(
'session-button',
...buttonTypes,
buttonColor,
disabled && 'disabled'
)}
role="button" role="button"
onClick={disabled ? () => null : this.clickHandler} onClick={disabled ? () => null : this.clickHandler}
> >

@ -1,22 +1,14 @@
import React from 'react'; import React from 'react';
import { SessionToggle } from '../SessionToggle'; import { SessionToggle } from '../SessionToggle';
import { import { SessionButton, SessionButtonColor } from '../SessionButton';
SessionButton, import { SessionSettingType } from './SessionSettings';
SessionButtonColor,
SessionButtonType,
} from '../SessionButton';
export enum SessionSettingType {
Toggle = 'toggle',
Options = 'options',
Button = 'button',
}
interface Props { interface Props {
title: string; title: string;
description?: string; description?: string;
type: SessionSettingType; type: SessionSettingType;
value: boolean | string; value: any;
options?: Array<any>;
onClick?: any; onClick?: any;
buttonText?: string; buttonText?: string;
buttonColor?: SessionButtonColor; buttonColor?: SessionButtonColor;
@ -26,6 +18,8 @@ export class SessionSettingListItem extends React.Component<Props> {
public constructor(props: Props) { public constructor(props: Props) {
super(props); super(props);
this.state = {}; this.state = {};
this.handleClick = this.handleClick.bind(this);
} }
public render(): JSX.Element { public render(): JSX.Element {
@ -34,7 +28,6 @@ export class SessionSettingListItem extends React.Component<Props> {
description, description,
type, type,
value, value,
onClick,
buttonText, buttonText,
buttonColor, buttonColor,
} = this.props; } = this.props;
@ -53,7 +46,7 @@ export class SessionSettingListItem extends React.Component<Props> {
{type === SessionSettingType.Toggle && ( {type === SessionSettingType.Toggle && (
<div className="session-sessings-item__selection"> <div className="session-sessings-item__selection">
<SessionToggle active={Boolean(value)} onClick={onClick} /> <SessionToggle active={Boolean(value)} onClick={this.handleClick} />
</div> </div>
)} )}
@ -61,10 +54,14 @@ export class SessionSettingListItem extends React.Component<Props> {
<SessionButton <SessionButton
text={buttonText} text={buttonText}
buttonColor={buttonColor} buttonColor={buttonColor}
onClick={onClick} onClick={this.handleClick}
/> />
)} )}
</div> </div>
); );
} }
private handleClick() {
this.props.onClick && this.props.onClick();
}
} }

@ -0,0 +1,156 @@
import React from 'react';
import { SettingsHeader } from './SessionSettingsHeader';
import { SessionSettingListItem } from './SessionSettingListItem';
import { SessionButtonColor } from '../SessionButton';
export enum SessionSettingCategory {
General = 'general',
Account = 'account',
Privacy = 'privacy',
Notifications = 'notifications',
Devices = 'devices',
}
export enum SessionSettingType {
Toggle = 'toggle',
Options = 'options',
Button = 'button',
}
// Grab initial values from database on startup
const localSettings = [
{
id: 'theme',
title: 'Light Mode',
description: 'Choose the theme best suited to you',
type: SessionSettingType.Toggle,
category: SessionSettingCategory.General,
afterClick: () => window.toggleTheme(),
},
{
id: 'typingIndicators',
title: 'Typing Indicators',
description:
'See and share when messages are being typed. This setting is optional and applies to all conversations.',
type: SessionSettingType.Toggle,
category: SessionSettingCategory.Privacy,
},
{
id: 'screenLock',
title: 'Screen Lock',
description:
'Unlock Loki Session using your password. Visit notification settings to customise.',
type: SessionSettingType.Toggle,
category: SessionSettingCategory.Privacy,
},
{
id: 'screenSecurity',
title: 'Screen Security',
description:
'Prevent Loki Session previews from appearing in desktop notifications.',
type: SessionSettingType.Toggle,
category: SessionSettingCategory.Privacy,
},
{
id: 'linkPreviews',
title: 'Send Link Previews',
description:
'Supported for Imgur, Instagram, Pinterest, Reddit and YouTube.',
type: SessionSettingType.Toggle,
category: SessionSettingCategory.Privacy,
},
{
id: 'clearConversationHistory',
title: 'Clear Conversation History',
category: SessionSettingCategory.Privacy,
type: SessionSettingType.Button,
buttonText: 'Clear',
buttonColor: SessionButtonColor.Danger,
},
{
id: 'changePassword',
title: 'Change Password',
category: SessionSettingCategory.Account,
type: SessionSettingType.Button,
buttonText: 'Change',
buttonColor: SessionButtonColor.Primary,
},
{
id: 'removePassword',
title: 'Remove Password',
category: SessionSettingCategory.Account,
type: SessionSettingType.Button,
buttonText: 'Remove',
buttonColor: SessionButtonColor.Danger,
},
];
export interface SettingsViewProps {
category: SessionSettingCategory;
}
export class SettingsView extends React.Component<SettingsViewProps> {
public settingsViewRef: React.RefObject<HTMLDivElement>;
public constructor(props: any) {
super(props);
this.settingsViewRef = React.createRef();
}
public renderSettingInCategory() {
return (
<>
{localSettings.map(setting => {
const { category } = this.props;
const renderSettings = setting.category === category;
return (
<div key={setting.id}>
{renderSettings && (
<SessionSettingListItem
title={setting.title}
description={setting.description}
type={setting.type}
value={window.getSettingValue(setting.id)}
onClick={() => {
SettingsManager.updateSetting(setting);
}}
buttonText={setting.buttonText || undefined}
buttonColor={setting.buttonColor || undefined}
/>
)}
</div>
);
})}
</>
);
}
public render() {
const { category } = this.props;
return (
<div className="session-settings">
<SettingsHeader category={category} />
<div ref={this.settingsViewRef} className="session-settings-list">
{this.renderSettingInCategory()}
</div>
</div>
);
}
}
export class SettingsManager {
public static updateSetting(item: any) {
if (item.type === SessionSettingType.Toggle) {
//alert(`You clicked a toggle with ID: ${item.id}`);
// Manage toggle events
}
// If there's an onClick function, execute it
item.afterClick && item.afterClick();
return;
}
}

@ -0,0 +1,35 @@
import React from 'react';
import { SessionIconButton, SessionIconSize, SessionIconType } from '../icon';
import { SettingsViewProps } from './SessionSettings';
export class SettingsHeader extends React.Component<SettingsViewProps> {
public constructor(props: any) {
super(props);
}
public focusSearch() {
$('.left-pane-setting-section .session-search-input input').focus();
}
render() {
const category = String(this.props.category);
const categoryTitlePrefix = category[0].toUpperCase() + category.substr(1);
// Remove 's' on the end to keep words in singular form
const categoryTitle =
categoryTitlePrefix[categoryTitlePrefix.length - 1] === 's'
? categoryTitlePrefix.slice(0, -1) + ' Settings'
: categoryTitlePrefix + ' Settings';
return (
<div className="session-settings-header">
{categoryTitle}
<SessionIconButton
iconType={SessionIconType.Search}
iconSize={SessionIconSize.Large}
onClick={this.focusSearch}
/>
</div>
);
}
}

4
ts/global.d.ts vendored

@ -1,7 +1,6 @@
interface Window { interface Window {
Events: any; Events: any;
deleteAllData: any; deleteAllData: any;
deleteAccount: any;
getAccountManager: any; getAccountManager: any;
mnemonic: any; mnemonic: any;
clipboard: any; clipboard: any;
@ -25,6 +24,9 @@ interface Window {
showSeedDialog: any; showSeedDialog: any;
showAddServerDialog: any; showAddServerDialog: any;
toggleTheme: any; toggleTheme: any;
deleteAccount: any;
getSettingValue: any;
setSettingValue: any;
} }
interface Promise<T> { interface Promise<T> {

Loading…
Cancel
Save