From 81ecad25ae69d2a5efe042c81c414c17971a6c9a Mon Sep 17 00:00:00 2001 From: Thorsten Claus Date: Sat, 20 May 2023 22:55:56 +0200 Subject: [PATCH] No double message on end of stream (#105) --- app/assets/stylesheets/stream.scss | 4 ++++ app/controllers/streams_controller.rb | 2 +- app/views/streams/_stream_elements.html.haml | 4 +--- app/views/streams/_stream_flow.html.haml | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/stream.scss b/app/assets/stylesheets/stream.scss index 89e1c58..268af2a 100644 --- a/app/assets/stylesheets/stream.scss +++ b/app/assets/stylesheets/stream.scss @@ -104,6 +104,10 @@ } } +.stream_pagination_controls { + display: none; +} + .opengraph-container { width: 100%; background-color: #f0f0f0; diff --git a/app/controllers/streams_controller.rb b/app/controllers/streams_controller.rb index 2d53572..021c068 100644 --- a/app/controllers/streams_controller.rb +++ b/app/controllers/streams_controller.rb @@ -24,7 +24,7 @@ def local_public; end private - def stream_responder(stream_builder=nil) + def stream_responder(stream_builder) @stream_builder_object = stream_builder.new(current_user) @pagy, @stream = pagy_countless(@stream_builder_object.stream_posts) respond_to do |format| diff --git a/app/views/streams/_stream_elements.html.haml b/app/views/streams/_stream_elements.html.haml index 97bc8b8..4d576db 100644 --- a/app/views/streams/_stream_elements.html.haml +++ b/app/views/streams/_stream_elements.html.haml @@ -1,5 +1,3 @@ = turbo_stream_from :posts - @stream.each do |post| - = render partial: "streams/stream_element_container", locals: {post: PostPresenter.new(post, current_user)} -- if @stream.empty? - = render "streams/end_of_stream" \ No newline at end of file + = render partial: "streams/stream_element_container", locals: {post: PostPresenter.new(post, current_user)} \ No newline at end of file diff --git a/app/views/streams/_stream_flow.html.haml b/app/views/streams/_stream_flow.html.haml index d1be7c9..6949583 100644 --- a/app/views/streams/_stream_flow.html.haml +++ b/app/views/streams/_stream_flow.html.haml @@ -1,6 +1,8 @@ %div{data: {controller: "infinite-scroll"}} %div{data: {infinite_scroll_target: "entries"}} = render partial: "streams/stream_elements", locals:{stream: stream} - %div{data:{infinite_scroll_target: "pagination"}} + - if stream.empty? + = render "streams/end_of_stream" + %div{data:{infinite_scroll_target: "pagination"}, class: "stream_pagination_controls"} - if @pagy.vars[:items]>= @stream.size = countless_stream_next_tag(@pagy) \ No newline at end of file