about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/getting_started
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2021-02-08 15:01:01 -0600
committerStarfall <us@starfall.systems>2021-02-08 15:01:01 -0600
commit3693000bf6a94219e3cc4a29a6cb4ac51b78cf2a (patch)
tree5e0a9757d315ca3aafe4db1ce10d3c4d84769408 /app/javascript/flavours/glitch/features/getting_started
parentab4c09a7041050e4aa4b8333484e311f26a36b4a (diff)
parent4ed9576cd28abc033a094fed6babe9825014f1af (diff)
Merge remote-tracking branch 'glitchsoc/main' into main
Diffstat (limited to 'app/javascript/flavours/glitch/features/getting_started')
-rw-r--r--app/javascript/flavours/glitch/features/getting_started/components/announcements.js53
1 files changed, 24 insertions, 29 deletions
diff --git a/app/javascript/flavours/glitch/features/getting_started/components/announcements.js b/app/javascript/flavours/glitch/features/getting_started/components/announcements.js
index 1ab5d9ba6..4eebe83ef 100644
--- a/app/javascript/flavours/glitch/features/getting_started/components/announcements.js
+++ b/app/javascript/flavours/glitch/features/getting_started/components/announcements.js
@@ -39,35 +39,10 @@ class Content extends ImmutablePureComponent {
 
   componentDidMount () {
     this._updateLinks();
-    this._updateEmojis();
   }
 
   componentDidUpdate () {
     this._updateLinks();
-    this._updateEmojis();
-  }
-
-  _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);
-    }
   }
 
   _updateLinks () {
@@ -132,12 +107,30 @@ class Content extends ImmutablePureComponent {
     }
   }
 
-  handleEmojiMouseEnter = ({ target }) => {
-    target.src = target.getAttribute('data-original');
+  handleMouseEnter = ({ currentTarget }) => {
+    if (autoPlayGif) {
+      return;
+    }
+
+    const emojis = currentTarget.querySelectorAll('.custom-emoji');
+
+    for (var i = 0; i < emojis.length; i++) {
+      let emoji = emojis[i];
+      emoji.src = emoji.getAttribute('data-original');
+    }
   }
 
-  handleEmojiMouseLeave = ({ target }) => {
-    target.src = target.getAttribute('data-static');
+  handleMouseLeave = ({ currentTarget }) => {
+    if (autoPlayGif) {
+      return;
+    }
+
+    const emojis = currentTarget.querySelectorAll('.custom-emoji');
+
+    for (var i = 0; i < emojis.length; i++) {
+      let emoji = emojis[i];
+      emoji.src = emoji.getAttribute('data-static');
+    }
   }
 
   render () {
@@ -148,6 +141,8 @@ class Content extends ImmutablePureComponent {
         className='announcements__item__content translate'
         ref={this.setRef}
         dangerouslySetInnerHTML={{ __html: announcement.get('contentHtml') }}
+        onMouseEnter={this.handleMouseEnter}
+        onMouseLeave={this.handleMouseLeave}
       />
     );
   }