about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/getting_started
diff options
context:
space:
mode:
authorStarfall <root@starfall.blue>2020-04-11 20:04:56 -0500
committerStarfall <root@starfall.blue>2020-04-11 20:04:56 -0500
commitb107e4f771f036b214563764fcd95786f8016ee7 (patch)
tree22397105f42f30eceacdf84671d1c4d807c9dd73 /app/javascript/flavours/glitch/features/getting_started
parent144ecfcfc7d9974117f1563084409a9558290a60 (diff)
parentc47be5bd864a1f5244f35122ba7fae31a149c73d (diff)
Merge branch 'glitch'
Diffstat (limited to 'app/javascript/flavours/glitch/features/getting_started')
-rw-r--r--app/javascript/flavours/glitch/features/getting_started/components/announcements.js19
1 files changed, 19 insertions, 0 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 e34c9009b..acaa78fe3 100644
--- a/app/javascript/flavours/glitch/features/getting_started/components/announcements.js
+++ b/app/javascript/flavours/glitch/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');
   }
@@ -367,6 +378,14 @@ class Announcements extends ImmutablePureComponent {
     index: 0,
   };
 
+  static getDerivedStateFromProps(props, state) {
+    if (props.announcements.size > 0 && state.index >= props.announcements.size) {
+      return { index: props.announcements.size - 1 };
+    } else {
+      return null;
+    }
+  }
+
   componentDidMount () {
     this._markAnnouncementAsRead();
   }