/favorites: replace favorites view with ordfav: search.

Make /favorites redirect to a ordfav:<user> search instead of having a
separate view just for favorites. This duplicated a lot of code for no
good reason.
This commit is contained in:
evazion
2019-08-31 19:58:38 -05:00
parent 7f7730d249
commit b77eebf136
8 changed files with 19 additions and 249 deletions

View File

@@ -1,35 +0,0 @@
module PostSets
class Favorite < PostSets::Base
attr_reader :user, :page, :favorites, :params
def initialize(user_id, page = 1, params = {})
@params = params
@user = ::User.find(user_id)
@favorites = ::Favorite.for_user(user.id).paginate(page, :limit => limit).order("favorites.id desc")
end
def limit
params[:limit] || CurrentUser.user.per_page
end
def tag_array
@tag_array ||= ["fav:#{user.name}"]
end
def tag_string
tag_array.uniq.join(" ")
end
def humanized_tag_string
"fav:#{user.pretty_name}"
end
def posts
@posts ||= favorites.includes(:post).map(&:post).compact
end
def presenter
@presenter ||= ::PostSetPresenters::Favorite.new(self)
end
end
end