diff --git a/app/helpers/rooms_helper.rb b/app/helpers/rooms_helper.rb index cf0f3dd7..009fd77d 100644 --- a/app/helpers/rooms_helper.rb +++ b/app/helpers/rooms_helper.rb @@ -37,7 +37,7 @@ module RoomsHelper # Does not apply to admin or users that aren't signed in # 15+ option is used as unlimited - return false if !current_user || current_user&.has_role?(:admin) || limit == 15 + return false if current_user&.has_role?(:admin) || limit == 15 current_user.rooms.length >= limit end @@ -45,8 +45,10 @@ module RoomsHelper def current_room_exceeds_limit(room) # Get how many rooms need to be deleted to reach allowed room number limit = Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Limit").to_i - @diff = current_user.rooms.count - limit + return false if current_user&.has_role?(:admin) || limit == 15 + + @diff = current_user.rooms.count - limit @diff.positive? && current_user.rooms.pluck(:id).index(room.id) + 1 > limit end end