diff --git a/Gemfile b/Gemfile index 8bb9ab326..680e71411 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ ruby '>= 2.3.0', '< 2.6.0' gem 'pkg-config', '~> 1.3' gem 'puma', '~> 3.12' -gem 'rails', '~> 5.2.1' +gem 'rails', '~> 5.2.2' gem 'thor', '~> 0.20' gem 'hamlit-rails', '~> 0.2' @@ -108,7 +108,7 @@ group :production, :test do end group :test do - gem 'capybara', '~> 3.11' + gem 'capybara', '~> 3.12' gem 'climate_control', '~> 0.2' gem 'faker', '~> 1.9' gem 'microformats', '~> 4.0' @@ -128,7 +128,7 @@ group :development do gem 'letter_opener', '~> 1.4' gem 'letter_opener_web', '~> 1.3' gem 'memory_profiler' - gem 'rubocop', '~> 0.60', require: false + gem 'rubocop', '~> 0.61', require: false gem 'brakeman', '~> 4.3', require: false gem 'bundler-audit', '~> 0.6', require: false gem 'scss_lint', '~> 0.57', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 56522496a..f3b07d290 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,25 +15,25 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (5.2.1.1) - actionpack (= 5.2.1.1) + actioncable (5.2.2) + actionpack (= 5.2.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.1.1) - actionpack (= 5.2.1.1) - actionview (= 5.2.1.1) - activejob (= 5.2.1.1) + actionmailer (5.2.2) + actionpack (= 5.2.2) + actionview (= 5.2.2) + activejob (= 5.2.2) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.1.1) - actionview (= 5.2.1.1) - activesupport (= 5.2.1.1) + actionpack (5.2.2) + actionview (= 5.2.2) + activesupport (= 5.2.2) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.1.1) - activesupport (= 5.2.1.1) + actionview (5.2.2) + activesupport (= 5.2.2) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -44,20 +44,20 @@ GEM case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) active_record_query_trace (1.5.4) - activejob (5.2.1.1) - activesupport (= 5.2.1.1) + activejob (5.2.2) + activesupport (= 5.2.2) globalid (>= 0.3.6) - activemodel (5.2.1.1) - activesupport (= 5.2.1.1) - activerecord (5.2.1.1) - activemodel (= 5.2.1.1) - activesupport (= 5.2.1.1) + activemodel (5.2.2) + activesupport (= 5.2.2) + activerecord (5.2.2) + activemodel (= 5.2.2) + activesupport (= 5.2.2) arel (>= 9.0) - activestorage (5.2.1.1) - actionpack (= 5.2.1.1) - activerecord (= 5.2.1.1) + activestorage (5.2.2) + actionpack (= 5.2.2) + activerecord (= 5.2.2) marcel (~> 0.3.1) - activesupport (5.2.1.1) + activesupport (5.2.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -126,7 +126,7 @@ GEM sshkit (~> 1.3) capistrano-yarn (2.0.2) capistrano (~> 3.0) - capybara (3.11.1) + capybara (3.12.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -412,13 +412,13 @@ GEM actionmailer (>= 3, < 6) premailer (~> 1.7, >= 1.7.9) private_address_check (0.5.0) - pry (0.12.0) + pry (0.12.2) coderay (~> 1.1.0) method_source (~> 0.9.0) pry-byebug (3.6.0) byebug (~> 10.0) pry (~> 0.10) - pry-rails (0.3.7) + pry-rails (0.3.8) pry (>= 0.10.4) public_suffix (3.0.3) puma (3.12.0) @@ -435,23 +435,23 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.1.1) - actioncable (= 5.2.1.1) - actionmailer (= 5.2.1.1) - actionpack (= 5.2.1.1) - actionview (= 5.2.1.1) - activejob (= 5.2.1.1) - activemodel (= 5.2.1.1) - activerecord (= 5.2.1.1) - activestorage (= 5.2.1.1) - activesupport (= 5.2.1.1) + rails (5.2.2) + actioncable (= 5.2.2) + actionmailer (= 5.2.2) + actionpack (= 5.2.2) + actionview (= 5.2.2) + activejob (= 5.2.2) + activemodel (= 5.2.2) + activerecord (= 5.2.2) + activestorage (= 5.2.2) + activesupport (= 5.2.2) bundler (>= 1.3.0) - railties (= 5.2.1.1) + railties (= 5.2.2) sprockets-rails (>= 2.0.0) - rails-controller-testing (1.0.2) - actionpack (~> 5.x, >= 5.0.1) - actionview (~> 5.x, >= 5.0.1) - activesupport (~> 5.x) + rails-controller-testing (1.0.4) + actionpack (>= 5.0.1.x) + actionview (>= 5.0.1.x) + activesupport (>= 5.0.1.x) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) @@ -462,9 +462,9 @@ GEM railties (>= 5.0, < 6) rails-settings-cached (0.6.6) rails (>= 4.2.0) - railties (5.2.1.1) - actionpack (= 5.2.1.1) - activesupport (= 5.2.1.1) + railties (5.2.2) + actionpack (= 5.2.2) + activesupport (= 5.2.2) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) @@ -527,7 +527,7 @@ GEM rspec-core (~> 3.0, >= 3.0.0) sidekiq (>= 2.4.0) rspec-support (3.8.0) - rubocop (0.60.0) + rubocop (0.61.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.5, != 2.5.1.1) @@ -669,7 +669,7 @@ DEPENDENCIES capistrano-rails (~> 1.4) capistrano-rbenv (~> 2.1) capistrano-yarn (~> 2.0) - capybara (~> 3.11) + capybara (~> 3.12) charlock_holmes (~> 0.7.6) chewy (~> 5.0) cld3 (~> 3.2.0) @@ -735,7 +735,7 @@ DEPENDENCIES pundit (~> 2.0) rack-attack (~> 5.4) rack-cors (~> 1.0) - rails (~> 5.2.1) + rails (~> 5.2.2) rails-controller-testing (~> 1.0) rails-i18n (~> 5.1) rails-settings-cached (~> 0.6) @@ -746,7 +746,7 @@ DEPENDENCIES rqrcode (~> 0.10) rspec-rails (~> 3.8) rspec-sidekiq (~> 3.0) - rubocop (~> 0.60) + rubocop (~> 0.61) sanitize (~> 5.0) scss_lint (~> 0.57) sidekiq (~> 5.2) diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rb index 145e77918..99c16157f 100644 --- a/app/controllers/statuses_controller.rb +++ b/app/controllers/statuses_controller.rb @@ -67,12 +67,13 @@ class StatusesController < ApplicationController private - def create_descendant_thread(depth, statuses) + def create_descendant_thread(starting_depth, statuses) + depth = starting_depth + statuses.size if depth < DESCENDANTS_DEPTH_LIMIT - { statuses: statuses } + { statuses: statuses, starting_depth: starting_depth } else next_status = statuses.pop - { statuses: statuses, next_status: next_status } + { statuses: statuses, starting_depth: starting_depth, next_status: next_status } end end @@ -103,16 +104,19 @@ class StatusesController < ApplicationController @descendant_threads = [] if descendants.present? - statuses = [descendants.first] - depth = 1 + statuses = [descendants.first] + starting_depth = 0 descendants.drop(1).each_with_index do |descendant, index| if descendants[index].id == descendant.in_reply_to_id - depth += 1 statuses << descendant else - @descendant_threads << create_descendant_thread(depth, statuses) + @descendant_threads << create_descendant_thread(starting_depth, statuses) + # The thread is broken, assume it's a reply to the root status + starting_depth = 0 + + # ... unless we can find its ancestor in one of the already-processed threads @descendant_threads.reverse_each do |descendant_thread| statuses = descendant_thread[:statuses] @@ -121,18 +125,16 @@ class StatusesController < ApplicationController end if index.present? - depth += index - statuses.size + starting_depth = descendant_thread[:starting_depth] + index + 1 break end - - depth -= statuses.size end statuses = [descendant] end end - @descendant_threads << create_descendant_thread(depth, statuses) + @descendant_threads << create_descendant_thread(starting_depth, statuses) end @max_descendant_thread_id = @descendant_threads.pop[:statuses].first.id if descendants.size >= DESCENDANTS_LIMIT diff --git a/app/javascript/mastodon/features/notifications/components/notification.js b/app/javascript/mastodon/features/notifications/components/notification.js index 8df6830c5..e79bd1a3c 100644 --- a/app/javascript/mastodon/features/notifications/components/notification.js +++ b/app/javascript/mastodon/features/notifications/components/notification.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import StatusContainer from '../../../containers/status_container'; import AccountContainer from '../../../containers/account_container'; +import RelativeTimestamp from '../../../components/relative_timestamp'; import { injectIntl, FormattedMessage } from 'react-intl'; import Permalink from '../../../components/permalink'; import ImmutablePureComponent from 'react-immutable-pure-component'; @@ -87,9 +88,11 @@ class Notification extends ImmutablePureComponent { + + + -