Globalised consts

pull/710/head
Vincent 5 years ago
parent 2419272608
commit ff7dbd6562

@ -631,6 +631,11 @@ label {
&--selected { &--selected {
background-color: $session-shade-7 !important; background-color: $session-shade-7 !important;
} }
&:active,
&:visited,
&:focus {
outline: none;
}
} }
.session-dropdown { .session-dropdown {

@ -1,5 +1,4 @@
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom';
import classNames from 'classnames'; import classNames from 'classnames';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { ContextMenu, ContextMenuTrigger, MenuItem } from 'react-contextmenu'; import { ContextMenu, ContextMenuTrigger, MenuItem } from 'react-contextmenu';

@ -8,12 +8,6 @@ import {
SessionButtonType, SessionButtonType,
} from './session/SessionButton'; } from './session/SessionButton';
declare global {
interface Window {
displayNameRegex: any;
}
}
interface Props { interface Props {
i18n: any; i18n: any;
profileName: string; profileName: string;

@ -2,7 +2,6 @@ import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { SessionIcon, SessionIconSize, SessionIconType } from './icon/'; import { SessionIcon, SessionIconSize, SessionIconType } from './icon/';
import { generateID } from './tools/ComponentTools';
export enum SessionDropDownItemType { export enum SessionDropDownItemType {
Default = 'default', Default = 'default',
@ -20,7 +19,6 @@ interface Props {
export class SessionDropdownItem extends React.PureComponent<Props> { export class SessionDropdownItem extends React.PureComponent<Props> {
public static defaultProps = { public static defaultProps = {
id: generateID(),
type: SessionDropDownItemType.Default, type: SessionDropDownItemType.Default,
icon: null, icon: null,
active: false, active: false,
@ -33,7 +31,8 @@ export class SessionDropdownItem extends React.PureComponent<Props> {
} }
public render() { public render() {
const { id, content, type, icon, active } = this.props; const { content, type, icon, active } = this.props;
const id = this.props.id || window.generateID();
return ( return (
<li <li

@ -3,6 +3,7 @@ import classNames from 'classnames';
interface Props { interface Props {
active: boolean; active: boolean;
onClick: any;
} }
interface State { interface State {
@ -10,7 +11,7 @@ interface State {
} }
export class SessionToggle extends React.PureComponent<Props, State> { export class SessionToggle extends React.PureComponent<Props, State> {
public static readonly extendedDefaults = { public static defaultProps = {
onClick: () => null, onClick: () => null,
}; };
@ -40,9 +41,14 @@ export class SessionToggle extends React.PureComponent<Props, State> {
); );
} }
private clickHandler() { private clickHandler(e: any) {
this.setState({ this.setState({
active: !this.state.active, active: !this.state.active,
}); });
if (this.props.onClick) {
e.stopPropagation();
this.props.onClick();
}
} }
} }

@ -1,8 +0,0 @@
// This is a collection of tools which can be ued to simplify the esign and rendering process of your components.
export function generateID() {
// Generates a unique ID for your component
const buffer = new Uint32Array(10);
return window.crypto.getRandomValues(buffer)[0].toString();
}

1
ts/global.d.ts vendored

@ -12,6 +12,7 @@ interface Window {
textsecure: any; textsecure: any;
Session: any; Session: any;
i18n: any; i18n: any;
generateID: any;
} }
interface Promise<T> { interface Promise<T> {

Loading…
Cancel
Save