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:
parent
c6d893a71d
commit
3f9708edc4
9 changed files with 121 additions and 32 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue