From 0f8dd7e2db9afbcf9ee068bd7d1acd5437b3fe81 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Thu, 12 Apr 2018 00:33:52 -0700 Subject: [PATCH] Fix a number of lint failures --- js/views/conversation_view.js | 2 +- styleguide.config.js | 2 +- ts/components/conversation/Quote.tsx | 55 ++++++++++++++-------------- ts/styleguide/StyleGuideUtil.ts | 12 ++++-- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index db0e29852a..b69a7b407e 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -531,7 +531,7 @@ }, scrollToMessage: function(providedOptions) { - const options = providedOptions || options; + const options = providedOptions || {}; const { id } = options; if (id) { diff --git a/styleguide.config.js b/styleguide.config.js index 778a887f33..7c2eea7d6b 100644 --- a/styleguide.config.js +++ b/styleguide.config.js @@ -28,7 +28,7 @@ module.exports = { util: 'ts/styleguide/StyleGuideUtil', }, contextDependencies: [ - path.join(__dirname, 'ts/test'), + path.join(__dirname, 'ts/styleguide'), ], // We don't want one long, single page pagePerSection: true, diff --git a/ts/components/conversation/Quote.tsx b/ts/components/conversation/Quote.tsx index c2eda0523e..b19ec1b732 100644 --- a/ts/components/conversation/Quote.tsx +++ b/ts/components/conversation/Quote.tsx @@ -6,23 +6,23 @@ import Mime from '../../../js/modules/types/mime'; interface Props { - i18n: (key: string, values?: Array) => string; - authorTitle: string; - authorProfileName?: string; - authorColor: string; - text: string; attachments: Array; + authorColor: string; + authorProfileName?: string; + authorTitle: string; + i18n: (key: string, values?: Array) => string; + isIncoming: boolean; openQuotedMessage?: () => void; - quoterAuthorColor?: string, - isIncoming: boolean, + quoterAuthorColor?: string; + text: string; } interface QuotedAttachment { - fileName: string; contentType: string; - thumbnail?: Attachment, + fileName: string; /* Not included in protobuf */ isVoiceMessage: boolean; + thumbnail?: Attachment; } interface Attachment { @@ -53,14 +53,15 @@ function getObjectUrl(thumbnail: Attachment | undefined): string | null { export class Quote extends React.Component { public renderImage(url: string, icon?: string) { + const iconElement = icon + ?
+ : null; + return (
- {icon - ?
- : null - } + {iconElement}
); @@ -73,9 +74,9 @@ export class Quote extends React.Component { const iconColor = isIncoming ? quoterAuthorColor : 'white'; return ( -
-
-
+
+
+
); } @@ -111,7 +112,7 @@ export class Quote extends React.Component { const { i18n, text, attachments } = this.props; if (text) { - return
{text}
; + return
{text}
; } if (!attachments || attachments.length === 0) { @@ -122,19 +123,19 @@ export class Quote extends React.Component { const { contentType, fileName, isVoiceMessage } = first; if (Mime.isVideo(contentType)) { - return
{i18n('video')}
; + return
{i18n('video')}
; } if (Mime.isImage(contentType)) { - return
{i18n('photo')}
; + return
{i18n('photo')}
; } if (Mime.isAudio(contentType) && isVoiceMessage) { - return
{i18n('voiceMessage')}
; + return
{i18n('voiceMessage')}
; } if (Mime.isAudio(contentType)) { - return
{i18n('audio')}
; + return
{i18n('audio')}
; } - return
{fileName}
; + return
{fileName}
; } public render() { @@ -149,15 +150,15 @@ export class Quote extends React.Component { return null; } + const authorProfileElement = authorProfileName + ? ~{authorProfileName} + : null; + return (
- {authorTitle}{' '} - {authorProfileName - ? ~{authorProfileName} - : null - } + {authorTitle}{' '}{authorProfileElement}
{this.renderText()}
diff --git a/ts/styleguide/StyleGuideUtil.ts b/ts/styleguide/StyleGuideUtil.ts index 856674b054..dbe945ca53 100644 --- a/ts/styleguide/StyleGuideUtil.ts +++ b/ts/styleguide/StyleGuideUtil.ts @@ -1,9 +1,12 @@ import moment from 'moment'; import qs from 'qs'; -import { sample, padStart } from 'lodash'; import React from 'react'; 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 @@ -53,7 +56,7 @@ export { mp4ObjectUrl, txt, txtObjectUrl, - ourNumber + ourNumber, }; @@ -65,6 +68,8 @@ const urlOptions = qs.parse(query); const theme = urlOptions.theme || 'android'; const locale = urlOptions.locale || 'en'; +import HTML from '../ts/html'; + // @ts-ignore import localeMessages from '../../_locales/en/messages.json'; @@ -95,6 +100,7 @@ parent.moment.locale(locale); parent.React = React; parent.ReactDOM = ReactDOM; +parent.Signal.HTML = HTML; parent.Signal.Components = { Quote, }; @@ -141,7 +147,7 @@ const CONTACTS = COLORS.map((color, index) => { export { COLORS, CONTACTS, -} +}; parent.textsecure.storage.user.getNumber = () => ourNumber;