diff --git a/app/controllers/timeline_controller.rb b/app/controllers/timeline_controller.rb index a7542134..14a27a5c 100644 --- a/app/controllers/timeline_controller.rb +++ b/app/controllers/timeline_controller.rb @@ -2,14 +2,15 @@ class TimelineController < ApplicationController before_action :authenticate_user! + before_action :set_list, only: %i[list] + before_action :set_lists def index paginate_timeline { |args| current_user.cursored_timeline(**args) } end def list - @list = current_user.lists.find_by!(name: params[:list_name]) - @title = list_title(current_user.lists.find_by!(name: params[:list_name])) + @title = list_title(@list) paginate_timeline { |args| @list.cursored_timeline(**args) } end @@ -20,6 +21,15 @@ class TimelineController < ApplicationController private + def set_list + @list = current_user.lists.find_by!(name: params[:list_name]) if params[:list_name].present? + end + + def set_lists + @lists = current_user.lists + @lists = @lists.where.not(id: @list.id) if @list.present? + end + def paginate_timeline @timeline = yield(last_id: params[:last_id]) @timeline_last_id = @timeline.map(&:id).min diff --git a/app/views/layouts/feed.haml b/app/views/layouts/feed.haml index e9239c39..ee86df7c 100644 --- a/app/views/layouts/feed.haml +++ b/app/views/layouts/feed.haml @@ -2,6 +2,6 @@ .row .col-sm-10.col-md-10.col-lg-9.mx-auto = render 'layouts/messages' - = render 'tabs/feed', list: @list + = render 'tabs/feed', lists: @lists, list: @list = yield .d-block.d-sm-none= render 'shared/links' diff --git a/app/views/tabs/_feed.haml b/app/views/tabs/_feed.haml index 54c66280..c0a1bec2 100644 --- a/app/views/tabs/_feed.haml +++ b/app/views/tabs/_feed.haml @@ -15,12 +15,11 @@ - if list.members.empty? %p.text-muted= t(".list.members.none") - else - %p.px-4 + %p.px-4.pb-2 - list.members.each do |member| %a{ href: user_path(member.user), title: member.user.screen_name, data: { toggle: :tooltip, placement: :top } } %img.avatar-xs{ src: member.user.profile_picture.url(:small), loading: :lazy } - %li.dropdown-divider - - if current_user.lists.empty? + - if !list && lists.empty? .p-3= t(".lists.notice_html") - - current_user.lists.each do |list| + - lists.each do |list| %a.dropdown-item{ href: list_timeline_path(list.name) }= list.display_name