|
6 | 6 | user : User to check the following status for |
7 | 7 | "%> |
8 | 8 |
|
9 | | -<%= form_tag follow_post_comments_path(post_id: post.id), method: :post do %> |
10 | | - <% if post.followed_by?(user) %> |
11 | | - <%= button_tag type: :submit, |
12 | | - class: "button is-muted is-outlined is-small js-follow-comments", |
13 | | - data: { post_id: post.id, action: 'unfollow' }, |
14 | | - title: 'Don\'t follow new comment threads on this post', |
15 | | - 'aria-label': 'Unfollow new comment threads on this post' do %> |
16 | | - <i class="fas fa-fw fa-bell-slash"></i> Unfollow new |
17 | | - <% end %> |
18 | | - <% else %> |
19 | | - <%= button_tag type: :submit, |
20 | | - class: "button is-muted is-outlined is-small js-follow-comments", |
21 | | - data: { post_id: post.id, action: 'follow' }, |
22 | | - title: 'Follow all new comment threads on this post', |
23 | | - 'aria-label': 'Follow all new comment threads on this post' do %> |
24 | | - <i class="fas fa-fw fa-bell"></i> Follow new |
25 | | - <% end %> |
| 9 | +<% |
| 10 | + is_followed = post.followed_by?(user) |
| 11 | + action_path = is_followed ? |
| 12 | + unfollow_post_comments_path(post_id: post.id) : |
| 13 | + follow_post_comments_path(post_id: post.id) |
| 14 | + text = "#{is_followed ? 'Unfollow' : 'Follow'} new" |
| 15 | + title = 'Switch following new comment threads on this post' |
| 16 | +%> |
| 17 | + |
| 18 | +<%= form_tag action_path, method: :post do %> |
| 19 | + <%= button_tag type: :submit, |
| 20 | + class: "button is-muted is-outlined is-small js-follow-comments", |
| 21 | + data: { post_id: post.id, action: is_followed ? 'unfollow' : 'follow' }, |
| 22 | + aria: { label: title }, |
| 23 | + title: title do %> |
| 24 | + <i class="fas fa-fw <%= is_followed ? 'fa-bell-slash' : 'fa-bell' %>"></i> <%= text %> |
26 | 25 | <% end %> |
27 | 26 | <% end %> |
0 commit comments