Filter out selected list from lists dropdown
This commit is contained in:
parent
c5efbee938
commit
14199059b4
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue