From 0833491f413bcb28b87cc407376a6adb18f3514f Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Mon, 25 Jan 2021 20:14:33 -0500 Subject: [PATCH] Include shared rooms in room count for search (#2470) --- app/helpers/rooms_helper.rb | 7 +++++++ app/views/rooms/show.html.erb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/helpers/rooms_helper.rb b/app/helpers/rooms_helper.rb index c14b57eb..229577ca 100644 --- a/app/helpers/rooms_helper.rb +++ b/app/helpers/rooms_helper.rb @@ -59,4 +59,11 @@ module RoomsHelper def hidden_format_public ENV.fetch("HIDDEN_FORMATS_PUBLIC", "").split(",") end + + # Returns the total number of visibile rooms for the current user + def total_room_count(user) + total = user.rooms.length + total += user.shared_rooms.length if shared_access_allowed + total + end end diff --git a/app/views/rooms/show.html.erb b/app/views/rooms/show.html.erb index 0a8bb30e..0d8903df 100644 --- a/app/views/rooms/show.html.erb +++ b/app/views/rooms/show.html.erb @@ -82,7 +82,7 @@ - <% if current_user.ordered_rooms.length > 5 %> + <% if total_room_count(current_user) > 5 %>