diff options
author | ThibG <thib@sitedethib.com> | 2019-09-06 12:06:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-06 12:06:59 +0200 |
commit | 286bf110c3e69042049968440f1eb99372a7e0e6 (patch) | |
tree | ddf1c32803022cb200087a8c4c6818612ca76d3b /app/javascript/flavours/glitch/features/directory/components | |
parent | 0128509605ed90ee5a29d6af2347ab32bd46aeb9 (diff) | |
parent | 4434e2eb7f9942b44561c2f7702af3ed3854b8db (diff) |
Merge pull request #1211 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/javascript/flavours/glitch/features/directory/components')
-rw-r--r-- | app/javascript/flavours/glitch/features/directory/components/account_card.js | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/app/javascript/flavours/glitch/features/directory/components/account_card.js b/app/javascript/flavours/glitch/features/directory/components/account_card.js index 5ba263825..d1c406933 100644 --- a/app/javascript/flavours/glitch/features/directory/components/account_card.js +++ b/app/javascript/flavours/glitch/features/directory/components/account_card.js @@ -82,6 +82,43 @@ class AccountCard extends ImmutablePureComponent { onMute: PropTypes.func.isRequired, }; + _updateEmojis () { + const node = this.node; + + if (!node || autoPlayGif) { + return; + } + + const emojis = node.querySelectorAll('.custom-emoji'); + + for (var i = 0; i < emojis.length; i++) { + let emoji = emojis[i]; + if (emoji.classList.contains('status-emoji')) { + continue; + } + emoji.classList.add('status-emoji'); + + emoji.addEventListener('mouseenter', this.handleEmojiMouseEnter, false); + emoji.addEventListener('mouseleave', this.handleEmojiMouseLeave, false); + } + } + + componentDidMount () { + this._updateEmojis(); + } + + componentDidUpdate () { + this._updateEmojis(); + } + + handleEmojiMouseEnter = ({ target }) => { + target.src = target.getAttribute('data-original'); + } + + handleEmojiMouseLeave = ({ target }) => { + target.src = target.getAttribute('data-static'); + } + handleFollow = () => { this.props.onFollow(this.props.account); } @@ -94,6 +131,10 @@ class AccountCard extends ImmutablePureComponent { this.props.onMute(this.props.account); } + setRef = (c) => { + this.node = c; + } + render () { const { account, intl } = this.props; @@ -133,7 +174,7 @@ class AccountCard extends ImmutablePureComponent { </div> </div> - <div className='directory__card__extra'> + <div className='directory__card__extra' ref={this.setRef}> <div className='account__header__content' dangerouslySetInnerHTML={{ __html: account.get('note_emojified') }} /> </div> |