From a3680345b76b0dd1b3b413ecf5579cf07958c3e1 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 22 Dec 2016 23:07:46 +0100 Subject: [PATCH] Hide follow/unfollow button from public page if follow already requested --- app/models/account.rb | 4 ++++ app/views/accounts/_header.html.haml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/account.rb b/app/models/account.rb index 273c098331..5c1f6e7c1c 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -91,6 +91,10 @@ class Account < ApplicationRecord blocking.include?(other_account) end + def requested?(other_account) + follow_requests.where(target_account: other_account).exists? + end + def local? domain.nil? end diff --git a/app/views/accounts/_header.html.haml b/app/views/accounts/_header.html.haml index c132a6896c..77fd6c457f 100644 --- a/app/views/accounts/_header.html.haml +++ b/app/views/accounts/_header.html.haml @@ -1,5 +1,5 @@ .card{ style: "background-image: url(#{@account.header.url( :original)})" } - - if user_signed_in? && current_account.id != @account.id + - if user_signed_in? && current_account.id != @account.id && !current_account.requested?(@account) .controls - if current_account.following?(@account) = link_to t('accounts.unfollow'), unfollow_account_path(@account), data: { method: :post }, class: 'button'