diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 73a9460e..119bd17a 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -26,11 +26,11 @@ class UserController < ApplicationController @relationships_last_id = @relationships.map(&:id).min @more_data_available = !@user.cursored_follower_relationships(last_id: @relationships_last_id, size: 1).count.zero? @users = @relationships.map(&:source) - @type = :friend + @type = :follower respond_to do |format| format.html { render "show_follow" } - format.js { render "show_follow", layout: false } + format.turbo_stream { render "show_follow" } end end @@ -46,7 +46,7 @@ class UserController < ApplicationController respond_to do |format| format.html { render "show_follow" } - format.js { render "show_follow", layout: false } + format.turbo_stream { render "show_follow" } end end # rubocop:enable Metrics/AbcSize diff --git a/app/views/user/show_follow.haml b/app/views/user/show_follow.haml index 183a2457..1d939922 100644 --- a/app/views/user/show_follow.haml +++ b/app/views/user/show_follow.haml @@ -1,14 +1,17 @@ -.row.row-cols-1.row-cols-sm-2.row-cols-md-3#users - - @users.each do |user| - .col.pb-3 - = render 'shared/userbox', user: user, type: @type += turbo_frame_tag "user_#{@type}" do + .row.row-cols-1.row-cols-sm-2.row-cols-md-3#users + - @users.each do |user| + .col.pb-3 + = render 'shared/userbox', user: user, type: @type -= render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @relationships_last_id - -- if @more_data_available - .d-flex.justify-content-center.justify-content-sm-start - %button.btn.btn-light#load-more-btn{ type: :button, data: { last_id: @relationships_last_id } } - = t("voc.load") + - if @more_data_available + .d-flex.justify-content-center.justify-content-sm-start#paginator + - if @type === :follower + = button_to show_user_followers_path(@user, last_id: @relationships_last_id), class: "btn btn-light" do + = t("voc.load") + - else + = button_to show_user_followings_path(@user, last_id: @relationships_last_id), class: "btn btn-light" do + = t("voc.load") - provide(:title, user_title(@user, 'friends and followers')) - parent_layout 'user/profile' diff --git a/app/views/user/show_follow.js.erb b/app/views/user/show_follow.js.erb deleted file mode 100644 index c164badb..00000000 --- a/app/views/user/show_follow.js.erb +++ /dev/null @@ -1,8 +0,0 @@ -$('#users').append('<% @users.each do |user| - %>