Change output of api/accounts/:id/follow and unfollow to return relationship
Track relationship in redux state. Display follow/unfollow and following-back information on account view (unstyled)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
class Api::AccountsController < ApiController
|
||||
before_action :set_account
|
||||
before_action :doorkeeper_authorize!
|
||||
before_action :set_account
|
||||
respond_to :json
|
||||
|
||||
def show
|
||||
@ -20,12 +20,14 @@ class Api::AccountsController < ApiController
|
||||
|
||||
def follow
|
||||
@follow = FollowService.new.(current_user.account, @account.acct)
|
||||
render action: :show
|
||||
set_relationship
|
||||
render action: :relationship
|
||||
end
|
||||
|
||||
def unfollow
|
||||
@unfollow = UnfollowService.new.(current_user.account, @account)
|
||||
render action: :show
|
||||
set_relationship
|
||||
render action: :relationship
|
||||
end
|
||||
|
||||
def relationships
|
||||
@ -41,4 +43,10 @@ class Api::AccountsController < ApiController
|
||||
def set_account
|
||||
@account = Account.find(params[:id])
|
||||
end
|
||||
|
||||
def set_relationship
|
||||
@following = Account.following_map([@account.id], current_user.account_id)
|
||||
@followed_by = Account.followed_by_map([@account.id], current_user.account_id)
|
||||
@blocking = {}
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user