Filter out selected list from lists dropdown
This commit is contained in:
parent
c5efbee938
commit
14199059b4
|
@ -2,14 +2,15 @@
|
||||||
|
|
||||||
class TimelineController < ApplicationController
|
class TimelineController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
before_action :set_list, only: %i[list]
|
||||||
|
before_action :set_lists
|
||||||
|
|
||||||
def index
|
def index
|
||||||
paginate_timeline { |args| current_user.cursored_timeline(**args) }
|
paginate_timeline { |args| current_user.cursored_timeline(**args) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def list
|
def list
|
||||||
@list = current_user.lists.find_by!(name: params[:list_name])
|
@title = list_title(@list)
|
||||||
@title = list_title(current_user.lists.find_by!(name: params[:list_name]))
|
|
||||||
paginate_timeline { |args| @list.cursored_timeline(**args) }
|
paginate_timeline { |args| @list.cursored_timeline(**args) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -20,6 +21,15 @@ class TimelineController < ApplicationController
|
||||||
|
|
||||||
private
|
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
|
def paginate_timeline
|
||||||
@timeline = yield(last_id: params[:last_id])
|
@timeline = yield(last_id: params[:last_id])
|
||||||
@timeline_last_id = @timeline.map(&:id).min
|
@timeline_last_id = @timeline.map(&:id).min
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
.row
|
.row
|
||||||
.col-sm-10.col-md-10.col-lg-9.mx-auto
|
.col-sm-10.col-md-10.col-lg-9.mx-auto
|
||||||
= render 'layouts/messages'
|
= render 'layouts/messages'
|
||||||
= render 'tabs/feed', list: @list
|
= render 'tabs/feed', lists: @lists, list: @list
|
||||||
= yield
|
= yield
|
||||||
.d-block.d-sm-none= render 'shared/links'
|
.d-block.d-sm-none= render 'shared/links'
|
||||||
|
|
|
@ -15,12 +15,11 @@
|
||||||
- if list.members.empty?
|
- if list.members.empty?
|
||||||
%p.text-muted= t(".list.members.none")
|
%p.text-muted= t(".list.members.none")
|
||||||
- else
|
- else
|
||||||
%p.px-4
|
%p.px-4.pb-2
|
||||||
- list.members.each do |member|
|
- list.members.each do |member|
|
||||||
%a{ href: user_path(member.user), title: member.user.screen_name, data: { toggle: :tooltip, placement: :top } }
|
%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 }
|
%img.avatar-xs{ src: member.user.profile_picture.url(:small), loading: :lazy }
|
||||||
%li.dropdown-divider
|
- if !list && lists.empty?
|
||||||
- if current_user.lists.empty?
|
|
||||||
.p-3= t(".lists.notice_html")
|
.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
|
%a.dropdown-item{ href: list_timeline_path(list.name) }= list.display_name
|
||||||
|
|
Loading…
Reference in New Issue