Move public & list timelines into `TimelineController`

This commit is contained in:
Karina Kwiatek 2022-07-18 22:26:13 +02:00 committed by Karina Kwiatek
parent 98d7bec924
commit 6344b55b44
8 changed files with 25 additions and 31 deletions

View File

@ -1,15 +0,0 @@
class ListController < ApplicationController
before_action :authenticate_user!
def index
@list = current_user.lists.find_by_name!(params[:list_name])
@timeline = @list.cursored_timeline(last_id: params[:last_id])
@timeline_last_id = @timeline.map(&:id).min
@more_data_available = !@list.cursored_timeline(last_id: @timeline_last_id, size: 1).count.zero?
respond_to do |format|
format.html
format.js { render layout: false }
end
end
end

View File

@ -1,14 +0,0 @@
class PublicController < ApplicationController
before_action :authenticate_user!
def index
@timeline = Answer.cursored_public_timeline(last_id: params[:last_id])
@timeline_last_id = @timeline.map(&:id).min
@more_data_available = !Answer.cursored_public_timeline(last_id: @timeline_last_id, size: 1).count.zero?
respond_to do |format|
format.html
format.js { render layout: false }
end
end
end

View File

@ -13,4 +13,27 @@ class TimelineController < ApplicationController
format.js { render layout: false } format.js { render layout: false }
end end
end end
def list
@list = current_user.lists.find_by_name!(params[:list_name])
@timeline = @list.cursored_timeline(last_id: params[:last_id])
@timeline_last_id = @timeline.map(&:id).min
@more_data_available = !@list.cursored_timeline(last_id: @timeline_last_id, size: 1).count.zero?
respond_to do |format|
format.html
format.js { render layout: false }
end
end
def public
@timeline = Answer.cursored_public_timeline(last_id: params[:last_id])
@timeline_last_id = @timeline.map(&:id).min
@more_data_available = !Answer.cursored_public_timeline(last_id: @timeline_last_id, size: 1).count.zero?
respond_to do |format|
format.html
format.js { render layout: false }
end
end
end end

View File

@ -138,8 +138,8 @@ Rails.application.routes.draw do
end end
match '/discover', to: 'discover#index', via: :get, as: :discover match '/discover', to: 'discover#index', via: :get, as: :discover
match '/public', to: 'public#index', via: :get, as: :public_timeline if APP_CONFIG.dig(:features, :public, :enabled) match '/public', to: 'timeline#public', via: :get, as: :public_timeline if APP_CONFIG.dig(:features, :public, :enabled)
match '/list/:list_name', to: 'list#index', via: :get, as: :list_timeline match '/list/:list_name', to: 'timeline#list', via: :get, as: :list_timeline
match '/notifications(/:type)', to: 'notifications#index', via: :get, as: :notifications, defaults: {type: 'new'} match '/notifications(/:type)', to: 'notifications#index', via: :get, as: :notifications, defaults: {type: 'new'}