about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/hashtag_timeline/index.js
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-09-29 04:39:33 +0200
committerClaire <claire.github-309c@sitedethib.com>2022-10-09 15:29:14 +0200
commit0ff1d62c7a5f6b62799a028364b819a5b0686af1 (patch)
tree867e570c7cca9f1b239731765628d666c6a037b5 /app/javascript/flavours/glitch/features/hashtag_timeline/index.js
parent022547fbdf28351a6cf67ef281e372e9eff455b4 (diff)
[Glitch] Add logged-out access to the web UI
Port part of 43b5d5e38d2b8ad8f1d1ad0911c3c1718159c912 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch/features/hashtag_timeline/index.js')
-rw-r--r--app/javascript/flavours/glitch/features/hashtag_timeline/index.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/javascript/flavours/glitch/features/hashtag_timeline/index.js b/app/javascript/flavours/glitch/features/hashtag_timeline/index.js
index 87a52b269..1b73f4b8a 100644
--- a/app/javascript/flavours/glitch/features/hashtag_timeline/index.js
+++ b/app/javascript/flavours/glitch/features/hashtag_timeline/index.js
@@ -31,6 +31,10 @@ class HashtagTimeline extends React.PureComponent {
 
   disconnects = [];
 
+  static contextTypes = {
+    identity: PropTypes.object,
+  };
+
   static propTypes = {
     params: PropTypes.object.isRequired,
     columnId: PropTypes.string,
@@ -158,6 +162,11 @@ class HashtagTimeline extends React.PureComponent {
   handleFollow = () => {
     const { dispatch, params, tag } = this.props;
     const { id } = params;
+    const { signedIn } = this.context.identity;
+
+    if (!signedIn) {
+      return;
+    }
 
     if (tag.get('following')) {
       dispatch(unfollowHashtag(id));
@@ -170,6 +179,7 @@ class HashtagTimeline extends React.PureComponent {
     const { hasUnread, columnId, multiColumn, tag, intl } = this.props;
     const { id, local } = this.props.params;
     const pinned = !!columnId;
+    const { signedIn } = this.context.identity;
 
     let followButton;
 
@@ -177,7 +187,7 @@ class HashtagTimeline extends React.PureComponent {
       const following = tag.get('following');
 
       followButton = (
-        <button className={classNames('column-header__button')} onClick={this.handleFollow} title={intl.formatMessage(following ? messages.unfollowHashtag : messages.followHashtag)} aria-label={intl.formatMessage(following ? messages.unfollowHashtag : messages.followHashtag)} aria-pressed={following ? 'true' : 'false'}>
+        <button className={classNames('column-header__button')} onClick={this.handleFollow} disabled={!signedIn} title={intl.formatMessage(following ? messages.unfollowHashtag : messages.followHashtag)} aria-label={intl.formatMessage(following ? messages.unfollowHashtag : messages.followHashtag)} aria-pressed={following ? 'true' : 'false'}>
           <Icon id={following ? 'user-times' : 'user-plus'} fixedWidth className='column-header__icon' />
         </button>
       );