Refactor inbox to use a Turbo Stream-backed pagination
This commit is contained in:
parent
a7e17a07cc
commit
136f7f117d
|
@ -49,7 +49,7 @@ class InboxController < ApplicationController
|
||||||
@disabled = true if @inbox.empty?
|
@disabled = true if @inbox.empty?
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.js { render layout: false }
|
format.turbo_stream
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
= turbo_frame_tag "inbox" do
|
||||||
#entries
|
#entries
|
||||||
- @inbox.each do |i|
|
- @inbox.each do |i|
|
||||||
= render "inbox/entry", i: i
|
= render "inbox/entry", i: i
|
||||||
|
@ -5,10 +6,7 @@
|
||||||
- if @inbox.empty?
|
- if @inbox.empty?
|
||||||
= t(".empty")
|
= t(".empty")
|
||||||
|
|
||||||
= render "shared/cursored_pagination_dummy", more_data_available: @more_data_available, last_id: @inbox_last_id
|
|
||||||
|
|
||||||
- if @more_data_available
|
- if @more_data_available
|
||||||
|
.d-flex.justify-content-center.justify-content-sm-start#paginator
|
||||||
.d-flex.justify-content-center.justify-content-sm-start
|
= button_to inbox_path(last_id: @inbox_last_id), class: "btn btn-light" do
|
||||||
%button.btn.btn-light#load-more-btn{ type: :button, data: { last_id: @inbox_last_id } }
|
|
||||||
= t("voc.load")
|
= t("voc.load")
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
= turbo_stream.append "entries" do
|
||||||
|
- @inbox.each do |i|
|
||||||
|
= render "inbox/entry", i: i
|
||||||
|
|
||||||
|
= turbo_stream.update "paginator" do
|
||||||
|
- if @more_data_available
|
||||||
|
= button_to t("voc.load"), inbox_path(last_id: @inbox_last_id), class: "btn btn-light"
|
||||||
|
|
|
@ -143,8 +143,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
get "/notifications(/:type)", to: "notifications#index", as: :notifications, defaults: { type: "new" }
|
get "/notifications(/:type)", to: "notifications#index", as: :notifications, defaults: { type: "new" }
|
||||||
|
|
||||||
get "/inbox", to: "inbox#show"
|
match "/inbox(/:author)", via: [:get, :post], to: "inbox#show", as: :inbox
|
||||||
get "/inbox/:author", to: "inbox#show"
|
|
||||||
|
|
||||||
get "/user/:username(/p/:page)", to: "user#show", defaults: { page: 1 }
|
get "/user/:username(/p/:page)", to: "user#show", defaults: { page: 1 }
|
||||||
get "/@:username(/p/:page)", to: "user#show", as: :user, defaults: { page: 1 }
|
get "/@:username(/p/:page)", to: "user#show", as: :user, defaults: { page: 1 }
|
||||||
|
|
Loading…
Reference in New Issue