about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/getting_started/components/announcements.js
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-03-08 16:10:48 +0100
committerGitHub <noreply@github.com>2020-03-08 16:10:48 +0100
commitaa67036b41d37935210c8b5094ac20c153a62011 (patch)
tree27afe119c6d80b7100e2e92d73df40fc3db2dc7c /app/javascript/mastodon/features/getting_started/components/announcements.js
parent5e4b6496557b5ef167518dbc6015307158e30ccf (diff)
Add support for links to statuses in announcements to be opened in web UI (#13212)
* Add support for links to public statuses in announcements to be opened in WebUI

* Please CodeClimate
Diffstat (limited to 'app/javascript/mastodon/features/getting_started/components/announcements.js')
-rw-r--r--app/javascript/mastodon/features/getting_started/components/announcements.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/javascript/mastodon/features/getting_started/components/announcements.js b/app/javascript/mastodon/features/getting_started/components/announcements.js
index 91cf6215e..fb4a6bf0d 100644
--- a/app/javascript/mastodon/features/getting_started/components/announcements.js
+++ b/app/javascript/mastodon/features/getting_started/components/announcements.js
@@ -95,6 +95,10 @@ class Content extends ImmutablePureComponent {
       } else if (link.textContent[0] === '#' || (link.previousSibling && link.previousSibling.textContent && link.previousSibling.textContent[link.previousSibling.textContent.length - 1] === '#')) {
         link.addEventListener('click', this.onHashtagClick.bind(this, link.text), false);
       } else {
+        let status = this.props.announcement.get('statuses').find(item => link.href === item.get('url'));
+        if (status) {
+          link.addEventListener('click', this.onStatusClick.bind(this, status), false);
+        }
         link.setAttribute('title', link.href);
         link.classList.add('unhandled-link');
       }
@@ -120,6 +124,13 @@ class Content extends ImmutablePureComponent {
     }
   }
 
+  onStatusClick = (status, e) => {
+    if (this.context.router && e.button === 0 && !(e.ctrlKey || e.metaKey)) {
+      e.preventDefault();
+      this.context.router.history.push(`/statuses/${status.get('id')}`);
+    }
+  }
+
   handleEmojiMouseEnter = ({ target }) => {
     target.src = target.getAttribute('data-original');
   }