Sorry, this message could not be loaded. (Status code {@state.error.statusCode})
Try Again
else
_renderQuotedTextControl: =>
return null unless QuotedHTMLTransformer.hasQuotedHTML(@props.message.body)
•••
_toggleQuotedText: =>
@setState
showQuotedText: !@state.showQuotedText
_onFetchBody: =>
NylasAPI.makeRequest
path: "/messages/#{@props.message.id}"
accountId: @props.message.accountId
returnsModel: true
.then =>
return if @_unmounted
@setState({error: null})
# message will be put into the database and the MessageBodyProcessor
# will provide us with the new body once it's been processed.
.catch (error) =>
return if @_unmounted
@setState({error})
_mergeBodyWithFiles: (body) =>
# Replace cid:// references with the paths to downloaded files
for file in @props.message.files
download = @props.downloads[file.id]
cidRegexp = new RegExp("cid:#{file.contentId}(['\"]+)", 'gi')
if download and download.state isnt 'finished'
# Render a spinner and inject a `style` tag that injects object-position / object-fit
body = body.replace cidRegexp, (text, quoteCharacter) ->
dataUri = CanvasUtils.dataURIForLoadedPercent(download.percent)
"#{dataUri}#{quoteCharacter} style=#{quoteCharacter} object-position: 50% 50%; object-fit: none; "
else
# Render the completed download
body = body.replace cidRegexp, (text, quoteCharacter) ->
"#{FileDownloadStore.pathForFile(file)}#{quoteCharacter}"
# Replace remaining cid:// references - we will not display them since they'll
# throw "unknown ERR_UNKNOWN_URL_SCHEME". Show a transparent pixel so that there's
# no "missing image" region shown, just a space.
body = body.replace(MessageUtils.cidRegex, "src=\"#{TransparentPixel}\"")
return body
module.exports = MessageItemBody