about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSTJrInuyasha <MattWCSTRFAN@gmail.com>2017-07-06 12:30:37 -0700
committerEugen Rochko <eugen@zeonfederated.com>2017-07-06 21:30:37 +0200
commit6bf6d35637abc691cf85b1c96a54c74af8b8bc2e (patch)
tree5b0c8e6079dbc431c4d126f9d882af9aaea60f0e
parent9c03fd9caef575792f08fd4e5c396d8d72bad09f (diff)
Parse links in status content on update as well as mount (#4042)
* Update links in status content on update as well as mount
Fixes occasional bugs with mentions and hashtags not being set to open in a new column like they should, and instead opening in a new page

* use classList instead of raw className
-rw-r--r--app/javascript/mastodon/components/status_content.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/javascript/mastodon/components/status_content.js b/app/javascript/mastodon/components/status_content.js
index 19bde01bd..78656571d 100644
--- a/app/javascript/mastodon/components/status_content.js
+++ b/app/javascript/mastodon/components/status_content.js
@@ -25,12 +25,17 @@ export default class StatusContent extends React.PureComponent {
     hidden: true,
   };
 
-  componentDidMount () {
+  _updateStatusLinks () {
     const node  = this.node;
     const links = node.querySelectorAll('a');
 
     for (var i = 0; i < links.length; ++i) {
-      let link    = links[i];
+      let link = links[i];
+      if (link.classList.contains('status-link')) {
+        continue;
+      }
+      link.classList.add('status-link');
+
       let mention = this.props.status.get('mentions').find(item => link.href === item.get('url'));
 
       if (mention) {
@@ -46,10 +51,15 @@ export default class StatusContent extends React.PureComponent {
     }
   }
 
+  componentDidMount () {
+    this._updateStatusLinks();
+  }
+
   componentDidUpdate () {
     if (this.props.onHeightUpdate) {
       this.props.onHeightUpdate();
     }
+    this._updateStatusLinks();
   }
 
   onMentionClick = (mention, e) => {