diff options
author | ThibG <thib@sitedethib.com> | 2020-03-08 16:10:48 +0100 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2020-03-08 20:46:15 +0100 |
commit | 9c2922958783f7e499cdda5bb874d6096e47eb0a (patch) | |
tree | 8254538ed33f4c4b974b5379f3b5a0b489ba095a /app | |
parent | 669cf49c542bdfacedbe149a66f3b308ad0044f0 (diff) |
[Glitch] Add support for links to statuses in announcements to be opened in web UI
Port aa67036b41d37935210c8b5094ac20c153a62011 to glitch-soc Signed-off-by: Thibaut Girka <thib@sitedethib.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/javascript/flavours/glitch/features/getting_started/components/announcements.js | 11 |
1 files changed, 11 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..48e1766e2 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'); } |