Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: app/lib/user_settings_decorator.rb app/models/user.rb app/serializers/initial_state_serializer.rb app/views/stream_entries/_simple_status.html.haml config/locales/simple_form.en.yml config/locales/simple_form.ja.yml config/locales/simple_form.pl.yml config/routes.rb
This commit is contained in:
@@ -19,5 +19,13 @@ module Paginable
|
||||
query = query.where(arel_table[:id].gt(min_id)) if min_id.present?
|
||||
query
|
||||
}
|
||||
|
||||
scope :paginate_by_id, ->(limit, options = {}) {
|
||||
if options[:min_id].present?
|
||||
paginate_by_min_id(limit, options[:min_id]).reverse
|
||||
else
|
||||
paginate_by_max_id(limit, options[:max_id], options[:since_id])
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@@ -6,16 +6,20 @@ class Feed
|
||||
@id = id
|
||||
end
|
||||
|
||||
def get(limit, max_id = nil, since_id = nil)
|
||||
from_redis(limit, max_id, since_id)
|
||||
def get(limit, max_id = nil, since_id = nil, min_id = nil)
|
||||
from_redis(limit, max_id, since_id, min_id)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def from_redis(limit, max_id, since_id)
|
||||
max_id = '+inf' if max_id.blank?
|
||||
since_id = '-inf' if since_id.blank?
|
||||
unhydrated = redis.zrevrangebyscore(key, "(#{max_id}", "(#{since_id}", limit: [0, limit], with_scores: true).map(&:first).map(&:to_i)
|
||||
def from_redis(limit, max_id, since_id, min_id)
|
||||
if min_id.blank?
|
||||
max_id = '+inf' if max_id.blank?
|
||||
since_id = '-inf' if since_id.blank?
|
||||
unhydrated = redis.zrevrangebyscore(key, "(#{max_id}", "(#{since_id}", limit: [0, limit], with_scores: true).map(&:first).map(&:to_i)
|
||||
else
|
||||
unhydrated = redis.zrangebyscore(key, "(#{min_id}", '+inf', limit: [0, limit], with_scores: true).map(&:first).map(&:to_i)
|
||||
end
|
||||
|
||||
Status.where(id: unhydrated).cache_ids
|
||||
end
|
||||
|
@@ -7,9 +7,9 @@ class HomeFeed < Feed
|
||||
@account = account
|
||||
end
|
||||
|
||||
def get(limit, max_id = nil, since_id = nil)
|
||||
def get(limit, max_id = nil, since_id = nil, min_id = nil)
|
||||
if redis.exists("account:#{@account.id}:regeneration")
|
||||
from_database(limit, max_id, since_id)
|
||||
from_database(limit, max_id, since_id, min_id)
|
||||
else
|
||||
super
|
||||
end
|
||||
@@ -17,9 +17,9 @@ class HomeFeed < Feed
|
||||
|
||||
private
|
||||
|
||||
def from_database(limit, max_id, since_id)
|
||||
def from_database(limit, max_id, since_id, min_id)
|
||||
Status.as_home_timeline(@account)
|
||||
.paginate_by_max_id(limit, max_id, since_id)
|
||||
.paginate_by_id(limit, max_id: max_id, since_id: since_id, min_id: min_id)
|
||||
.reject { |status| FeedManager.instance.filter?(:home, status, @account.id) }
|
||||
end
|
||||
end
|
||||
|
@@ -95,8 +95,8 @@ class User < ApplicationRecord
|
||||
has_many :session_activations, dependent: :destroy
|
||||
|
||||
delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal,
|
||||
:reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_sensitive_media, :hide_network,
|
||||
:default_language, to: :settings, prefix: :setting, allow_nil: false
|
||||
:reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network,
|
||||
:expand_spoilers, :default_language, to: :settings, prefix: :setting, allow_nil: false
|
||||
|
||||
attr_reader :invite_code
|
||||
|
||||
@@ -316,6 +316,14 @@ class User < ApplicationRecord
|
||||
super
|
||||
end
|
||||
|
||||
def show_all_media?
|
||||
setting_display_media == 'show_all'
|
||||
end
|
||||
|
||||
def hide_all_media?
|
||||
setting_display_media == 'hide_all'
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def send_devise_notification(notification, *args)
|
||||
|
Reference in New Issue
Block a user