diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/status.rb | 8 | ||||
-rw-r--r-- | app/views/stream_entries/_status.html.haml | 5 |
2 files changed, 11 insertions, 2 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index 08b5ee75e..2fdd8d123 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -76,6 +76,14 @@ class Status < ActiveRecord::Base m end + def ancestors + Status.where(id: Status.find_by_sql(['WITH RECURSIVE search_tree(id, in_reply_to_id, path) AS (SELECT id, in_reply_to_id, ARRAY[id] FROM statuses WHERE id = ? UNION ALL SELECT statuses.id, statuses.in_reply_to_id, path || statuses.id FROM search_tree JOIN statuses ON statuses.id = search_tree.in_reply_to_id WHERE NOT statuses.id = ANY(path)) SELECT id FROM search_tree ORDER BY path DESC', self.id]) - [self]) + end + + def descendants + Status.where(id: Status.find_by_sql(['WITH RECURSIVE search_tree(id, path) AS (SELECT id, ARRAY[id] FROM statuses WHERE id = ? UNION ALL SELECT statuses.id, path || statuses.id FROM search_tree JOIN statuses ON statuses.in_reply_to_id = search_tree.id WHERE NOT statuses.id = ANY(path)) SELECT id FROM search_tree ORDER BY path', self.id]) - [self]) + end + after_create do self.account.stream_entries.create!(activity: self) end diff --git a/app/views/stream_entries/_status.html.haml b/app/views/stream_entries/_status.html.haml index 16f036ad3..dff03716c 100644 --- a/app/views/stream_entries/_status.html.haml +++ b/app/views/stream_entries/_status.html.haml @@ -1,5 +1,6 @@ - if status.reply? && include_threads - = render partial: 'status', locals: { status: status.thread, include_threads: false, is_predecessor: true, is_successor: false } + - status.ancestors.with_includes.with_counters.each do |status| + = render partial: 'status', locals: { status: status, include_threads: false, is_predecessor: true, is_successor: false } .entry{ class: entry_classes(status, is_predecessor, is_successor, include_threads) } - if status.reblog? @@ -32,5 +33,5 @@ = status.reblog? ? (status.reblog.local? ? linkify(status.reblog) : status.reblog.content.html_safe) : (status.local? ? linkify(status) : status.content.html_safe) - if include_threads - - status.replies.each do |status| + - status.descendants.with_includes.with_counters.each do |status| = render partial: 'status', locals: { status: status, include_threads: false, is_successor: true, is_predecessor: false } |