From bb715293223c2ab9840a6c11b23091f4de92917b Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Wed, 20 Apr 2016 10:44:26 -0700 Subject: [PATCH] fix(attachments): Don't show the paperclip for inline attachments < 3k (signatures, etc.) --- .../message-list/lib/message-item.cjsx | 2 +- .../thread-list/lib/thread-list-columns.cjsx | 19 +++++++++++++------ src/flux/models/utils.coffee | 4 ++++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/internal_packages/message-list/lib/message-item.cjsx b/internal_packages/message-list/lib/message-item.cjsx index d4058a3c3..d971d5b72 100644 --- a/internal_packages/message-list/lib/message-item.cjsx +++ b/internal_packages/message-list/lib/message-item.cjsx @@ -54,7 +54,7 @@ class MessageItem extends React.Component _renderCollapsed: => attachmentIcon = [] - if @props.message.files.length > 0 + if Utils.showIconForAttachments(@props.message.files) attachmentIcon =
diff --git a/internal_packages/thread-list/lib/thread-list-columns.cjsx b/internal_packages/thread-list/lib/thread-list-columns.cjsx index 85547e16a..6fe156fd5 100644 --- a/internal_packages/thread-list/lib/thread-list-columns.cjsx +++ b/internal_packages/thread-list/lib/thread-list-columns.cjsx @@ -76,8 +76,11 @@ c3 = new ListTabular.Column name: "Message" flex: 4 resolver: (thread) => - attachment = [] - if thread.hasAttachments + attachment = false + metadata = (thread.metadata ? []) + + hasAttachments = thread.hasAttachments and metadata.find (m) -> Utils.showIconForAttachments(m.files) + if hasAttachments attachment =
@@ -114,11 +117,15 @@ cNarrow = new ListTabular.Column name: "Item" flex: 1 resolver: (thread) => - pencil = [] - attachment = [] - hasDraft = _.find (thread.metadata ? []), (m) -> m.draft - if thread.hasAttachments + pencil = false + attachment = false + metadata = (thread.metadata ? []) + + hasAttachments = thread.hasAttachments and metadata.find (m) -> Utils.showIconForAttachments(m.files) + if hasAttachments attachment =
+ + hasDraft = _.find metadata, (m) -> m.draft if hasDraft pencil = diff --git a/src/flux/models/utils.coffee b/src/flux/models/utils.coffee index 65e528641..8145fa400 100644 --- a/src/flux/models/utils.coffee +++ b/src/flux/models/utils.coffee @@ -22,6 +22,10 @@ Utils = window.requestAnimationFrame(attempt) attempt() + showIconForAttachments: (files) -> + return false unless files instanceof Array + return files.find (f) -> !f.contentId or f.size > 3 * 1024 + extractTextFromHtml: (html, {maxLength} = {}) -> if (html ? "").trim().length is 0 then return "" if maxLength and html.length > maxLength