]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Add support for links to statuses in announcements to be opened in web UI
authorThibG <thib@sitedethib.com>
Sun, 8 Mar 2020 15:10:48 +0000 (16:10 +0100)
committerThibaut Girka <thib@sitedethib.com>
Sun, 8 Mar 2020 19:46:15 +0000 (20:46 +0100)
Port aa67036b41d37935210c8b5094ac20c153a62011 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
app/javascript/flavours/glitch/features/getting_started/components/announcements.js

index e34c9009b5198b48bdec3404aa5ab0688e2af349..48e1766e2083c8238e3b15926ec0d379cc0a7c17 100644 (file)
@@ -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');
   }