Skip to content

Commit

Permalink
fix(comment) comments via email notification
Browse files Browse the repository at this point in the history
Github sends emails to users who are subscribed to
notifications. The Gitalk comment behavior should match that of
Github.

The previous behavior does not hide extended email replys.
Often times the email response contains the complete email
chain. The visible email chain confuses the user with
unformatted html strings.

Incorrect comment formatting for email replies. #224
  • Loading branch information
garrettbryan committed Jan 30, 2019
1 parent 7f04a89 commit 9886ffb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/component/comment.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import Avatar from './avatar'
import Svg from './svg'
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now'
Expand Down Expand Up @@ -28,6 +29,22 @@ if (typeof window !== `undefined`) {


export default class Comment extends Component {
shouldComponentUpdate () {
return false
}

componentDidMount () {
const comment = ReactDOM.findDOMNode(this)
const emailResponse = comment.querySelector('.email-hidden-toggle>a')
if (emailResponse) {
emailResponse.setAttribute('href', '')
emailResponse.addEventListener('click', e => {
e.preventDefault()
comment.querySelector('.email-hidden-reply').classList.toggle('expanded')
}, true)
}
}

render () {
const {
comment,
Expand Down
5 changes: 5 additions & 0 deletions src/style/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ $gt-size-avatar-mobi := em(32px)
right: 0
&-body
color: $gt-color-comment-txt !important
.email-hidden-reply
display: none;
white-space: pre-wrap
.email-hidden-reply.expanded
display: block
&-admin
.gt-comment-content
background-color: $gt-color-comment-adminbg
Expand Down

0 comments on commit 9886ffb

Please sign in to comment.