Skip to content

Commit 08f487c

Browse files
committed
switched post_follow & post_unfollow to set_post action callback
1 parent bbca43b commit 08f487c

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

app/assets/javascripts/comments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ $(() => {
366366

367367
const icon = document.createElement('i');
368368
icon.classList.add('fas', 'fa-fw', shouldFollow ? 'fa-bell-slash' : 'fa-bell');
369-
const text = document.createTextNode(` ${ shouldFollow ? 'Unfollow' : 'Follow' } new`);
369+
const text = document.createTextNode(` ${shouldFollow ? 'Unfollow' : 'Follow'} new`);
370370
target.replaceChildren(icon, text);
371371

372372
const form = target.closest('form');

app/controllers/comments_controller.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class CommentsController < ApplicationController
44
before_action :authenticate_user!, except: [:post, :show, :thread, :thread_content]
55

66
before_action :set_comment, only: [:update, :destroy, :undelete, :show]
7-
before_action :set_post, only: [:create_thread]
7+
before_action :set_post, only: [:create_thread, :post_follow, :post_unfollow]
88
before_action :set_thread,
99
only: [:create, :thread, :thread_content, :thread_rename, :thread_restrict, :thread_unrestrict,
1010
:thread_followers]
@@ -274,7 +274,6 @@ def post
274274
end
275275

276276
def post_follow
277-
@post = Post.find(params[:post_id])
278277
if ThreadFollower.where(post: @post, user: current_user).none?
279278
ThreadFollower.create(post: @post, user: current_user)
280279
end
@@ -286,7 +285,6 @@ def post_follow
286285
end
287286

288287
def post_unfollow
289-
@post = Post.find(params[:post_id])
290288
ThreadFollower.where(post: @post, user: current_user).destroy_all
291289

292290
respond_to do |format|
@@ -308,7 +306,7 @@ def comment_params
308306
end
309307

310308
def set_comment
311-
@comment = Comment.unscoped.find params[:id]
309+
@comment = Comment.unscoped.find(params[:id])
312310
end
313311

314312
def set_post

0 commit comments

Comments
 (0)