]> git.openstreetmap.org Git - rails.git/commitdiff
Initialize dashboard followings and nearby users in controller
authorAnton Khorev <tony29@yandex.ru>
Wed, 19 Feb 2025 00:53:29 +0000 (03:53 +0300)
committerAnton Khorev <tony29@yandex.ru>
Wed, 19 Feb 2025 01:02:40 +0000 (04:02 +0300)
app/controllers/dashboards_controller.rb
app/views/dashboards/show.html.erb

index 540683d25ea0e89c2ed63b55f8d7949d5cdbfe9d..54dba26d33de85f12ccaacf1d54681382ec5c906 100644 (file)
@@ -10,5 +10,7 @@ class DashboardsController < ApplicationController
 
   def show
     @user = current_user
+    @followings = current_user.followings
+    @nearby_users = current_user.nearby - @followings
   end
 end
index 70dae774e86eef0a3e5e9567b2f75d46d9791755..a198f534df1a685134beb19bbfaeb3bcf9a42f47 100644 (file)
            } %>
         <%= tag.div "", :id => "map", :class => "content_map border border-secondary-subtle rounded z-0", :data => { :user => user_data } %>
       <% end %>
-
-      <% followings = @user.followings %>
-      <% nearby = @user.nearby - followings %>
     </div>
 
     <div class="col-md">
       <h2><%= t ".followings" %></h2>
 
-      <% if followings.empty? %>
+      <% if @followings.empty? %>
         <%= t ".no followings" %>
       <% else %>
         <nav class='secondary-actions mb-3'>
@@ -39,7 +36,7 @@
           </ul>
         </nav>
         <div>
-          <%= render :partial => "contact", :collection => followings, :locals => { :type => "following" } %>
+          <%= render :partial => "contact", :collection => @followings, :locals => { :type => "following" } %>
         </div>
       <% end %>
 
@@ -47,7 +44,7 @@
 
       <h2><%= t ".nearby users" %></h2>
 
-      <% if nearby.empty? %>
+      <% if @nearby_users.empty? %>
         <%= t ".no nearby users" %>
       <% else %>
         <nav class='secondary-actions mb-3'>
@@ -57,7 +54,7 @@
           </ul>
         </nav>
         <div id="nearbyusers">
-          <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %>
+          <%= render :partial => "contact", :collection => @nearby_users, :locals => { :type => "nearby mapper" } %>
         </div>
       <% end %>
     </div>