Fix a number of lint failures

This commit is contained in:
Scott Nonnenberg 2018-04-12 00:33:52 -07:00
parent 1cc0633786
commit 0f8dd7e2db
No known key found for this signature in database
GPG key ID: 5F82280C35134661
4 changed files with 39 additions and 32 deletions

View file

@ -531,7 +531,7 @@
}, },
scrollToMessage: function(providedOptions) { scrollToMessage: function(providedOptions) {
const options = providedOptions || options; const options = providedOptions || {};
const { id } = options; const { id } = options;
if (id) { if (id) {

View file

@ -28,7 +28,7 @@ module.exports = {
util: 'ts/styleguide/StyleGuideUtil', util: 'ts/styleguide/StyleGuideUtil',
}, },
contextDependencies: [ contextDependencies: [
path.join(__dirname, 'ts/test'), path.join(__dirname, 'ts/styleguide'),
], ],
// We don't want one long, single page // We don't want one long, single page
pagePerSection: true, pagePerSection: true,

View file

@ -6,23 +6,23 @@ import Mime from '../../../js/modules/types/mime';
interface Props { interface Props {
i18n: (key: string, values?: Array<string>) => string;
authorTitle: string;
authorProfileName?: string;
authorColor: string;
text: string;
attachments: Array<QuotedAttachment>; attachments: Array<QuotedAttachment>;
authorColor: string;
authorProfileName?: string;
authorTitle: string;
i18n: (key: string, values?: Array<string>) => string;
isIncoming: boolean;
openQuotedMessage?: () => void; openQuotedMessage?: () => void;
quoterAuthorColor?: string, quoterAuthorColor?: string;
isIncoming: boolean, text: string;
} }
interface QuotedAttachment { interface QuotedAttachment {
fileName: string;
contentType: string; contentType: string;
thumbnail?: Attachment, fileName: string;
/* Not included in protobuf */ /* Not included in protobuf */
isVoiceMessage: boolean; isVoiceMessage: boolean;
thumbnail?: Attachment;
} }
interface Attachment { interface Attachment {
@ -53,14 +53,15 @@ function getObjectUrl(thumbnail: Attachment | undefined): string | null {
export class Quote extends React.Component<Props, {}> { export class Quote extends React.Component<Props, {}> {
public renderImage(url: string, icon?: string) { public renderImage(url: string, icon?: string) {
const iconElement = icon
? <div className={classnames('icon', icon)} />
: null;
return ( return (
<div className="icon-container"> <div className="icon-container">
<div className="inner"> <div className="inner">
<img src={url} /> <img src={url} />
{icon {iconElement}
? <div className={classnames('icon', icon)}></div>
: null
}
</div> </div>
</div> </div>
); );
@ -73,9 +74,9 @@ export class Quote extends React.Component<Props, {}> {
const iconColor = isIncoming ? quoterAuthorColor : 'white'; const iconColor = isIncoming ? quoterAuthorColor : 'white';
return ( return (
<div className='icon-container'> <div className="icon-container">
<div className={classnames('circle-background', backgroundColor)}></div> <div className={classnames('circle-background', backgroundColor)} />
<div className={classnames('icon', icon, iconColor)}></div> <div className={classnames('icon', icon, iconColor)} />
</div> </div>
); );
} }
@ -111,7 +112,7 @@ export class Quote extends React.Component<Props, {}> {
const { i18n, text, attachments } = this.props; const { i18n, text, attachments } = this.props;
if (text) { if (text) {
return <div className='text'>{text}</div>; return <div className="text">{text}</div>;
} }
if (!attachments || attachments.length === 0) { if (!attachments || attachments.length === 0) {
@ -122,19 +123,19 @@ export class Quote extends React.Component<Props, {}> {
const { contentType, fileName, isVoiceMessage } = first; const { contentType, fileName, isVoiceMessage } = first;
if (Mime.isVideo(contentType)) { if (Mime.isVideo(contentType)) {
return <div className='type-label'>{i18n('video')}</div>; return <div className="type-label">{i18n('video')}</div>;
} }
if (Mime.isImage(contentType)) { if (Mime.isImage(contentType)) {
return <div className='type-label'>{i18n('photo')}</div>; return <div className="type-label">{i18n('photo')}</div>;
} }
if (Mime.isAudio(contentType) && isVoiceMessage) { if (Mime.isAudio(contentType) && isVoiceMessage) {
return <div className='type-label'>{i18n('voiceMessage')}</div>; return <div className="type-label">{i18n('voiceMessage')}</div>;
} }
if (Mime.isAudio(contentType)) { if (Mime.isAudio(contentType)) {
return <div className='type-label'>{i18n('audio')}</div>; return <div className="type-label">{i18n('audio')}</div>;
} }
return <div className='filename-label'>{fileName}</div>; return <div className="filename-label">{fileName}</div>;
} }
public render() { public render() {
@ -149,15 +150,15 @@ export class Quote extends React.Component<Props, {}> {
return null; return null;
} }
const authorProfileElement = authorProfileName
? <span className="profile-name">~{authorProfileName}</span>
: null;
return ( return (
<div onClick={openQuotedMessage} className={classnames(authorColor, 'quote')} > <div onClick={openQuotedMessage} className={classnames(authorColor, 'quote')} >
<div className="primary"> <div className="primary">
<div className={classnames(authorColor, 'author')}> <div className={classnames(authorColor, 'author')}>
{authorTitle}{' '} {authorTitle}{' '}{authorProfileElement}
{authorProfileName
? <span className='profile-name'>~{authorProfileName}</span>
: null
}
</div> </div>
{this.renderText()} {this.renderText()}
</div> </div>

View file

@ -1,9 +1,12 @@
import moment from 'moment'; import moment from 'moment';
import qs from 'qs'; import qs from 'qs';
import { sample, padStart } from 'lodash';
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import {
padStart,
sample,
} from 'lodash';
// Helper components used in the Style Guide, exposed at 'util' in the global scope via // Helper components used in the Style Guide, exposed at 'util' in the global scope via
@ -53,7 +56,7 @@ export {
mp4ObjectUrl, mp4ObjectUrl,
txt, txt,
txtObjectUrl, txtObjectUrl,
ourNumber ourNumber,
}; };
@ -65,6 +68,8 @@ const urlOptions = qs.parse(query);
const theme = urlOptions.theme || 'android'; const theme = urlOptions.theme || 'android';
const locale = urlOptions.locale || 'en'; const locale = urlOptions.locale || 'en';
import HTML from '../ts/html';
// @ts-ignore // @ts-ignore
import localeMessages from '../../_locales/en/messages.json'; import localeMessages from '../../_locales/en/messages.json';
@ -95,6 +100,7 @@ parent.moment.locale(locale);
parent.React = React; parent.React = React;
parent.ReactDOM = ReactDOM; parent.ReactDOM = ReactDOM;
parent.Signal.HTML = HTML;
parent.Signal.Components = { parent.Signal.Components = {
Quote, Quote,
}; };
@ -141,7 +147,7 @@ const CONTACTS = COLORS.map((color, index) => {
export { export {
COLORS, COLORS,
CONTACTS, CONTACTS,
} };
parent.textsecure.storage.user.getNumber = () => ourNumber; parent.textsecure.storage.user.getNumber = () => ourNumber;