diff --git a/Gemfile b/Gemfile index 27d65f2720..9826a59ebf 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'thor', '~> 0.20' gem 'hamlit-rails', '~> 0.2' gem 'pg', '~> 1.0' gem 'makara', '~> 0.4' -gem 'pghero', '~> 2.1' +gem 'pghero', '~> 2.2' gem 'dotenv-rails', '~> 2.2', '< 2.3' gem 'aws-sdk-s3', '~> 1.9', require: false @@ -24,13 +24,13 @@ gem 'streamio-ffmpeg', '~> 3.0' gem 'active_model_serializers', '~> 0.10' gem 'addressable', '~> 2.5' -gem 'bootsnap', '~> 1.3' +gem 'bootsnap', '~> 1.3', require: false gem 'browser' gem 'charlock_holmes', '~> 0.7.6' gem 'iso-639' gem 'chewy', '~> 5.0' gem 'cld3', '~> 3.2.0' -gem 'devise', '~> 4.4' +gem 'devise', '~> 4.5' gem 'devise-two-factor', '~> 3.0' group :pam_authentication, optional: true do @@ -57,10 +57,10 @@ gem 'httplog', '~> 1.0' gem 'idn-ruby', require: 'idn' gem 'kaminari', '~> 1.1' gem 'link_header', '~> 0.0' -gem 'mime-types', '~> 3.1', require: 'mime/types/columnar' +gem 'mime-types', '~> 3.2', require: 'mime/types/columnar' gem 'nokogiri', '~> 1.8' gem 'nsa', '~> 0.2' -gem 'oj', '~> 3.5' +gem 'oj', '~> 3.6' gem 'ostatus2', '~> 2.0' gem 'ox', '~> 2.9' gem 'posix-spawn', git: 'https://github.com/rtomayko/posix-spawn', ref: '58465d2e213991f8afb13b984854a49fcdcc980c' @@ -75,8 +75,8 @@ gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock' gem 'rqrcode', '~> 0.10' gem 'ruby-progressbar', '~> 1.4' gem 'sanitize', '~> 4.6' -gem 'sidekiq', '~> 5.1' -gem 'sidekiq-scheduler', '~> 2.2' +gem 'sidekiq', '~> 5.2' +gem 'sidekiq-scheduler', '~> 3.0' gem 'sidekiq-unique-jobs', '~> 5.0' gem 'sidekiq-bulk', '~>0.1.1' gem 'simple-navigation', '~> 4.0' @@ -85,7 +85,7 @@ gem 'sprockets-rails', '~> 3.2', require: 'sprockets/railtie' gem 'stoplight', '~> 2.1.3' gem 'strong_migrations', '~> 0.2' gem 'tty-command', '~> 0.8', require: false -gem 'tty-prompt', '~> 0.16', require: false +gem 'tty-prompt', '~> 0.17', require: false gem 'twitter-text', '~> 1.14' gem 'tzinfo-data', '~> 1.2018' gem 'webpacker', '~> 3.5' @@ -104,7 +104,7 @@ group :development, :test do end group :production, :test do - gem 'private_address_check', '~> 0.4.1' + gem 'private_address_check', '~> 0.5' end group :test do @@ -133,7 +133,7 @@ group :development do gem 'bundler-audit', '~> 0.6', require: false gem 'scss_lint', '~> 0.57', require: false - gem 'capistrano', '~> 3.10' + gem 'capistrano', '~> 3.11' gem 'capistrano-rails', '~> 1.3' gem 'capistrano-rbenv', '~> 2.1' gem 'capistrano-yarn', '~> 2.0' diff --git a/Gemfile.lock b/Gemfile.lock index e4e1c69df5..44fa27fe2f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,7 +96,7 @@ GEM rack (>= 0.9.0) binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) - bootsnap (1.3.0) + bootsnap (1.3.2) msgpack (~> 1.0) brakeman (4.2.1) browser (2.5.3) @@ -108,7 +108,7 @@ GEM bundler (~> 1.2) thor (~> 0.18) byebug (10.0.2) - capistrano (3.10.2) + capistrano (3.11.0) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) @@ -147,7 +147,7 @@ GEM coderay (1.1.2) colorize (0.8.1) concurrent-ruby (1.0.5) - connection_pool (2.2.1) + connection_pool (2.2.2) crack (0.4.3) safe_yaml (~> 1.0.0) crass (1.0.4) @@ -162,7 +162,7 @@ GEM rack (>= 1) rake (> 10, < 13) thor (~> 0.19) - devise (4.4.3) + devise (4.5.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0, < 6.0) @@ -202,7 +202,7 @@ GEM encryptor (3.0.0) equatable (0.5.0) erubi (1.7.1) - et-orbi (1.1.0) + et-orbi (1.1.6) tzinfo excon (0.62.0) fabrication (2.20.1) @@ -212,7 +212,7 @@ GEM multipart-post (>= 1.2, < 3) fast_blank (1.0.0) fastimage (2.1.1) - ffi (1.9.23) + ffi (1.9.25) fog-core (1.45.0) builder excon (~> 0.58) @@ -225,6 +225,9 @@ GEM fog-json (>= 1.0) ipaddress (>= 0.8) formatador (0.2.5) + fugit (1.1.6) + et-orbi (~> 1.1, >= 1.1.6) + raabro (~> 1.1) fuubar (2.3.1) rspec-core (~> 3.0) ruby-progressbar (~> 1.4) @@ -252,7 +255,7 @@ GEM heapy (0.1.3) highline (1.7.10) hiredis (0.6.1) - hitimes (1.2.6) + hitimes (1.3.0) hkdf (0.3.0) html2text (0.2.1) nokogiri (~> 1.6) @@ -328,14 +331,14 @@ GEM mimemagic (~> 0.3.2) mario-redis-lock (1.2.1) redis (>= 3.0.5) - memory_profiler (0.9.10) + memory_profiler (0.9.11) method_source (0.9.0) microformats (4.0.7) json nokogiri - mime-types (3.1) + mime-types (3.2.2) mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) + mime-types-data (3.2018.0812) mimemagic (0.3.2) mini_mime (1.0.0) mini_portile2 (2.3.0) @@ -347,7 +350,7 @@ GEM net-ldap (0.16.1) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (4.2.0) + net-ssh (5.0.2) nio4r (2.3.1) nokogiri (1.8.4) mini_portile2 (~> 2.3.0) @@ -358,7 +361,7 @@ GEM concurrent-ruby (~> 1.0.0) sidekiq (>= 3.5.0) statsd-ruby (~> 1.2.0) - oj (3.5.1) + oj (3.6.11) omniauth (1.8.1) hashie (>= 3.4.6, < 3.6.0) rack (>= 1.6.2, < 3) @@ -393,9 +396,9 @@ GEM equatable (~> 0.5.0) tty-color (~> 0.4.0) pg (1.0.0) - pghero (2.1.0) + pghero (2.2.0) activerecord - pkg-config (1.3.0) + pkg-config (1.3.1) powerpack (0.1.1) premailer (1.11.1) addressable @@ -404,7 +407,7 @@ GEM premailer-rails (1.10.2) actionmailer (>= 3, < 6) premailer (~> 1.7, >= 1.7.9) - private_address_check (0.4.1) + private_address_check (0.5.0) pry (0.11.3) coderay (~> 1.1.0) method_source (~> 0.9.0) @@ -417,11 +420,12 @@ GEM puma (3.11.4) pundit (1.1.0) activesupport (>= 3.0.0) + raabro (1.1.6) rack (2.0.5) rack-attack (5.2.0) rack rack-cors (1.0.2) - rack-protection (2.0.1) + rack-protection (2.0.4) rack rack-proxy (0.6.4) rack @@ -528,10 +532,10 @@ GEM ruby-progressbar (1.9.0) ruby-saml (1.7.2) nokogiri (>= 1.5.10) - rufus-scheduler (3.4.2) - et-orbi (~> 1.0) + rufus-scheduler (3.5.2) + fugit (~> 1.1, >= 1.1.5) safe_yaml (1.0.4) - sanitize (4.6.4) + sanitize (4.6.6) crass (~> 1.0.2) nokogiri (>= 1.4.4) nokogumbo (~> 1.4) @@ -543,15 +547,14 @@ GEM scss_lint (0.57.0) rake (>= 0.9, < 13) sass (~> 3.5.5) - sidekiq (5.1.3) - concurrent-ruby (~> 1.0) - connection_pool (~> 2.2, >= 2.2.0) + sidekiq (5.2.2) + connection_pool (~> 2.2, >= 2.2.2) rack-protection (>= 1.5.0) redis (>= 3.3.5, < 5) sidekiq-bulk (0.1.1) activesupport sidekiq - sidekiq-scheduler (2.2.1) + sidekiq-scheduler (3.0.0) redis (>= 3, < 5) rufus-scheduler (~> 3.2) sidekiq (>= 3) @@ -561,9 +564,9 @@ GEM thor (~> 0) simple-navigation (4.0.5) activesupport (>= 2.3.2) - simple_form (4.0.0) - actionpack (> 4) - activemodel (> 4) + simple_form (4.0.1) + actionpack (>= 5.0) + activemodel (>= 5.0) simplecov (0.16.1) docile (~> 1.1) json (>= 1.8, < 3) @@ -576,15 +579,15 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sshkit (1.16.0) + sshkit (1.17.0) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - stackprof (0.2.11) + stackprof (0.2.12) statsd-ruby (1.2.1) stoplight (2.1.3) streamio-ffmpeg (3.0.2) multi_json (~> 1.8) - strong_migrations (0.2.2) + strong_migrations (0.2.3) activerecord (>= 3.2.0) temple (0.8.0) terminal-table (1.8.0) @@ -597,26 +600,26 @@ GEM tilt (2.0.8) timers (4.1.2) hitimes - tty-color (0.4.2) - tty-command (0.8.0) + tty-color (0.4.3) + tty-command (0.8.2) pastel (~> 0.7.0) - tty-cursor (0.5.0) - tty-prompt (0.16.0) + tty-cursor (0.6.0) + tty-prompt (0.17.0) necromancer (~> 0.4.0) pastel (~> 0.7.0) timers (~> 4.0) - tty-cursor (~> 0.5.0) - tty-reader (~> 0.2.0) - tty-reader (0.2.0) - tty-cursor (~> 0.5.0) + tty-cursor (~> 0.6.0) + tty-reader (~> 0.4.0) + tty-reader (0.4.0) + tty-cursor (~> 0.6.0) tty-screen (~> 0.6.4) wisper (~> 2.0.0) - tty-screen (0.6.4) + tty-screen (0.6.5) twitter-text (1.14.7) unf (~> 0.1.0) tzinfo (1.2.5) thread_safe (~> 0.1) - tzinfo-data (1.2018.4) + tzinfo-data (1.2018.5) tzinfo (>= 1.0.0) unf (0.1.4) unf_ext @@ -659,7 +662,7 @@ DEPENDENCIES browser bullet (~> 5.7) bundler-audit (~> 0.6) - capistrano (~> 3.10) + capistrano (~> 3.11) capistrano-rails (~> 1.3) capistrano-rbenv (~> 2.1) capistrano-yarn (~> 2.0) @@ -669,7 +672,7 @@ DEPENDENCIES cld3 (~> 3.2.0) climate_control (~> 0.2) derailed_benchmarks - devise (~> 4.4) + devise (~> 4.5) devise-two-factor (~> 3.0) devise_pam_authenticatable2 (~> 9.2) doorkeeper (~> 5.0) @@ -703,11 +706,11 @@ DEPENDENCIES mario-redis-lock (~> 1.2) memory_profiler microformats (~> 4.0) - mime-types (~> 3.1) + mime-types (~> 3.2) net-ldap (~> 0.10) nokogiri (~> 1.8) nsa (~> 0.2) - oj (~> 3.5) + oj (~> 3.6) omniauth (~> 1.2) omniauth-cas (~> 1.1) omniauth-saml (~> 1.10) @@ -717,11 +720,11 @@ DEPENDENCIES paperclip-av-transcoder (~> 0.6) parallel_tests (~> 2.21) pg (~> 1.0) - pghero (~> 2.1) + pghero (~> 2.2) pkg-config (~> 1.3) posix-spawn! premailer-rails - private_address_check (~> 0.4.1) + private_address_check (~> 0.5) pry-byebug (~> 3.6) pry-rails (~> 0.3) puma (~> 3.11) @@ -743,9 +746,9 @@ DEPENDENCIES ruby-progressbar (~> 1.4) sanitize (~> 4.6) scss_lint (~> 0.57) - sidekiq (~> 5.1) + sidekiq (~> 5.2) sidekiq-bulk (~> 0.1.1) - sidekiq-scheduler (~> 2.2) + sidekiq-scheduler (~> 3.0) sidekiq-unique-jobs (~> 5.0) simple-navigation (~> 4.0) simple_form (~> 4.0) @@ -757,7 +760,7 @@ DEPENDENCIES strong_migrations (~> 0.2) thor (~> 0.20) tty-command (~> 0.8) - tty-prompt (~> 0.16) + tty-prompt (~> 0.17) twitter-text (~> 1.14) tzinfo-data (~> 1.2018) webmock (~> 3.3) diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index 90f42251e1..ac8de5fc0f 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -53,6 +53,10 @@ class Api::BaseController < ApplicationController [params[:limit].to_i.abs, default_limit * 2].min end + def params_slice(*keys) + params.slice(*keys).permit(*keys) + end + def current_resource_owner @current_user ||= User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token end diff --git a/app/controllers/api/v1/accounts/statuses_controller.rb b/app/controllers/api/v1/accounts/statuses_controller.rb index 06fa6c7623..b68a8805fa 100644 --- a/app/controllers/api/v1/accounts/statuses_controller.rb +++ b/app/controllers/api/v1/accounts/statuses_controller.rb @@ -28,10 +28,9 @@ class Api::V1::Accounts::StatusesController < Api::BaseController def account_statuses statuses = truthy_param?(:pinned) ? pinned_scope : permitted_account_statuses - statuses = statuses.paginate_by_max_id( + statuses = statuses.paginate_by_id( limit_param(DEFAULT_STATUSES_LIMIT), - params[:max_id], - params[:since_id] + params_slice(:max_id, :since_id, :min_id) ) statuses.merge!(only_media_scope) if truthy_param?(:only_media) @@ -82,7 +81,7 @@ class Api::V1::Accounts::StatusesController < Api::BaseController def prev_path unless @statuses.empty? - api_v1_account_statuses_url pagination_params(since_id: pagination_since_id) + api_v1_account_statuses_url pagination_params(min_id: pagination_since_id) end end diff --git a/app/controllers/api/v1/favourites_controller.rb b/app/controllers/api/v1/favourites_controller.rb index ab5204355c..db827f9d4a 100644 --- a/app/controllers/api/v1/favourites_controller.rb +++ b/app/controllers/api/v1/favourites_controller.rb @@ -26,10 +26,9 @@ class Api::V1::FavouritesController < Api::BaseController end def results - @_results ||= account_favourites.paginate_by_max_id( + @_results ||= account_favourites.paginate_by_id( limit_param(DEFAULT_STATUSES_LIMIT), - params[:max_id], - params[:since_id] + params_slice(:max_id, :since_id, :min_id) ) end @@ -49,7 +48,7 @@ class Api::V1::FavouritesController < Api::BaseController def prev_path unless results.empty? - api_v1_favourites_url pagination_params(since_id: pagination_since_id) + api_v1_favourites_url pagination_params(min_id: pagination_since_id) end end diff --git a/app/controllers/api/v1/instances_controller.rb b/app/controllers/api/v1/instances_controller.rb index 1c6971c182..5686e8d7c3 100644 --- a/app/controllers/api/v1/instances_controller.rb +++ b/app/controllers/api/v1/instances_controller.rb @@ -4,6 +4,8 @@ class Api::V1::InstancesController < Api::BaseController respond_to :json def show - render json: {}, serializer: REST::InstanceSerializer + render_cached_json('api:v1:instances', expires_in: 5.minutes) do + ActiveModelSerializers::SerializableResource.new({}, serializer: REST::InstanceSerializer) + end end end diff --git a/app/controllers/api/v1/notifications_controller.rb b/app/controllers/api/v1/notifications_controller.rb index a8ed5a63b9..3b492c5163 100644 --- a/app/controllers/api/v1/notifications_controller.rb +++ b/app/controllers/api/v1/notifications_controller.rb @@ -46,10 +46,9 @@ class Api::V1::NotificationsController < Api::BaseController end def paginated_notifications - browserable_account_notifications.paginate_by_max_id( + browserable_account_notifications.paginate_by_id( limit_param(DEFAULT_NOTIFICATIONS_LIMIT), - params[:max_id], - params[:since_id] + params_slice(:max_id, :since_id, :min_id) ) end @@ -73,7 +72,7 @@ class Api::V1::NotificationsController < Api::BaseController def prev_path unless @notifications.empty? - api_v1_notifications_url pagination_params(since_id: pagination_since_id) + api_v1_notifications_url pagination_params(min_id: pagination_since_id) end end diff --git a/app/controllers/api/v1/reports_controller.rb b/app/controllers/api/v1/reports_controller.rb index a954101cb8..9c6ee0a50c 100644 --- a/app/controllers/api/v1/reports_controller.rb +++ b/app/controllers/api/v1/reports_controller.rb @@ -7,11 +7,6 @@ class Api::V1::ReportsController < Api::BaseController respond_to :json - def index - @reports = current_account.reports - render json: @reports, each_serializer: REST::ReportSerializer - end - def create @report = ReportService.new.call( current_account, diff --git a/app/controllers/api/v1/timelines/home_controller.rb b/app/controllers/api/v1/timelines/home_controller.rb index 4412aaaa39..fcd0757f1a 100644 --- a/app/controllers/api/v1/timelines/home_controller.rb +++ b/app/controllers/api/v1/timelines/home_controller.rb @@ -30,7 +30,8 @@ class Api::V1::Timelines::HomeController < Api::BaseController account_home_feed.get( limit_param(DEFAULT_STATUSES_LIMIT), params[:max_id], - params[:since_id] + params[:since_id], + params[:min_id] ) end @@ -51,7 +52,7 @@ class Api::V1::Timelines::HomeController < Api::BaseController end def prev_path - api_v1_timelines_home_url pagination_params(since_id: pagination_since_id) + api_v1_timelines_home_url pagination_params(min_id: pagination_since_id) end def pagination_max_id diff --git a/app/controllers/api/v1/timelines/list_controller.rb b/app/controllers/api/v1/timelines/list_controller.rb index cfc5f3b5e4..a15eae468d 100644 --- a/app/controllers/api/v1/timelines/list_controller.rb +++ b/app/controllers/api/v1/timelines/list_controller.rb @@ -32,7 +32,8 @@ class Api::V1::Timelines::ListController < Api::BaseController list_feed.get( limit_param(DEFAULT_STATUSES_LIMIT), params[:max_id], - params[:since_id] + params[:since_id], + params[:min_id] ) end @@ -53,7 +54,7 @@ class Api::V1::Timelines::ListController < Api::BaseController end def prev_path - api_v1_timelines_list_url params[:id], pagination_params(since_id: pagination_since_id) + api_v1_timelines_list_url params[:id], pagination_params(min_id: pagination_since_id) end def pagination_max_id diff --git a/app/controllers/api/v1/timelines/public_controller.rb b/app/controllers/api/v1/timelines/public_controller.rb index 13fe015b7d..aabe243243 100644 --- a/app/controllers/api/v1/timelines/public_controller.rb +++ b/app/controllers/api/v1/timelines/public_controller.rb @@ -21,10 +21,9 @@ class Api::V1::Timelines::PublicController < Api::BaseController end def public_statuses - statuses = public_timeline_statuses.paginate_by_max_id( + statuses = public_timeline_statuses.paginate_by_id( limit_param(DEFAULT_STATUSES_LIMIT), - params[:max_id], - params[:since_id] + params_slice(:max_id, :since_id, :min_id) ) if truthy_param?(:only_media) @@ -53,7 +52,7 @@ class Api::V1::Timelines::PublicController < Api::BaseController end def prev_path - api_v1_timelines_public_url pagination_params(since_id: pagination_since_id) + api_v1_timelines_public_url pagination_params(min_id: pagination_since_id) end def pagination_max_id diff --git a/app/controllers/api/v1/timelines/tag_controller.rb b/app/controllers/api/v1/timelines/tag_controller.rb index 7de49a5ed6..cf58d5cf40 100644 --- a/app/controllers/api/v1/timelines/tag_controller.rb +++ b/app/controllers/api/v1/timelines/tag_controller.rb @@ -29,10 +29,9 @@ class Api::V1::Timelines::TagController < Api::BaseController if @tag.nil? [] else - statuses = tag_timeline_statuses.paginate_by_max_id( + statuses = tag_timeline_statuses.paginate_by_id( limit_param(DEFAULT_STATUSES_LIMIT), - params[:max_id], - params[:since_id] + params_slice(:max_id, :since_id, :min_id) ) if truthy_param?(:only_media) @@ -62,7 +61,7 @@ class Api::V1::Timelines::TagController < Api::BaseController end def prev_path - api_v1_timelines_tag_url params[:id], pagination_params(since_id: pagination_since_id) + api_v1_timelines_tag_url params[:id], pagination_params(min_id: pagination_since_id) end def pagination_max_id diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index d60e6a89f9..5c5f31d2bb 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -37,7 +37,8 @@ class Settings::PreferencesController < Settings::BaseController :setting_favourite_modal, :setting_delete_modal, :setting_auto_play_gif, - :setting_display_sensitive_media, + :setting_display_media, + :setting_expand_spoilers, :setting_reduce_motion, :setting_system_font_ui, :setting_noindex, diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6b41fd36eb..c002017ef6 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -7,8 +7,8 @@ module ApplicationHelper follow ).freeze - def active_nav_class(path) - current_page?(path) ? 'active' : '' + def active_nav_class(*paths) + paths.any? { |path| current_page?(path) } ? 'active' : '' end def active_link_to(label, path, **options) diff --git a/app/javascript/mastodon/actions/importer/normalizer.js b/app/javascript/mastodon/actions/importer/normalizer.js index 10a39e0504..a2af3222e7 100644 --- a/app/javascript/mastodon/actions/importer/normalizer.js +++ b/app/javascript/mastodon/actions/importer/normalizer.js @@ -1,6 +1,7 @@ import escapeTextContentForBrowser from 'escape-html'; import emojify from '../../features/emoji/emoji'; import { unescapeHTML } from '../../utils/html'; +import { expandSpoilers } from '../../initial_state'; const domParser = new DOMParser(); @@ -57,7 +58,7 @@ export function normalizeStatus(status, normalOldStatus) { normalStatus.search_index = domParser.parseFromString(searchContent, 'text/html').documentElement.textContent; normalStatus.contentHtml = emojify(normalStatus.content, emojiMap); normalStatus.spoilerHtml = emojify(escapeTextContentForBrowser(spoilerText), emojiMap); - normalStatus.hidden = spoilerText.length > 0 || normalStatus.sensitive; + normalStatus.hidden = expandSpoilers ? false : spoilerText.length > 0 || normalStatus.sensitive; } return normalStatus; diff --git a/app/javascript/mastodon/components/__tests__/__snapshots__/autosuggest_emoji-test.js.snap b/app/javascript/mastodon/components/__tests__/__snapshots__/autosuggest_emoji-test.js.snap new file mode 100644 index 0000000000..1c37278483 --- /dev/null +++ b/app/javascript/mastodon/components/__tests__/__snapshots__/autosuggest_emoji-test.js.snap @@ -0,0 +1,27 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` renders emoji with custom url 1`] = ` +
+ foobar + :foobar: +
+`; + +exports[` renders native emoji 1`] = ` +
+ 💙 + :foobar: +
+`; diff --git a/app/javascript/mastodon/components/__tests__/autosuggest_emoji-test.js b/app/javascript/mastodon/components/__tests__/autosuggest_emoji-test.js new file mode 100644 index 0000000000..05616e4448 --- /dev/null +++ b/app/javascript/mastodon/components/__tests__/autosuggest_emoji-test.js @@ -0,0 +1,29 @@ +import React from 'react'; +import renderer from 'react-test-renderer'; +import AutosuggestEmoji from '../autosuggest_emoji'; + +describe('', () => { + it('renders native emoji', () => { + const emoji = { + native: '💙', + colons: ':foobar:', + }; + const component = renderer.create(); + const tree = component.toJSON(); + + expect(tree).toMatchSnapshot(); + }); + + it('renders emoji with custom url', () => { + const emoji = { + custom: true, + imageUrl: 'http://example.com/emoji.png', + native: 'foobar', + colons: ':foobar:', + }; + const component = renderer.create(); + const tree = component.toJSON(); + + expect(tree).toMatchSnapshot(); + }); +}); diff --git a/app/javascript/mastodon/components/media_gallery.js b/app/javascript/mastodon/components/media_gallery.js index a1785196f7..ed0e4ff1b6 100644 --- a/app/javascript/mastodon/components/media_gallery.js +++ b/app/javascript/mastodon/components/media_gallery.js @@ -6,7 +6,7 @@ import IconButton from './icon_button'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { isIOS } from '../is_mobile'; import classNames from 'classnames'; -import { autoPlayGif, displaySensitiveMedia } from '../initial_state'; +import { autoPlayGif, displayMedia } from '../initial_state'; const messages = defineMessages({ toggle_visible: { id: 'media_gallery.toggle_visible', defaultMessage: 'Toggle visibility' }, @@ -197,7 +197,7 @@ class MediaGallery extends React.PureComponent { }; state = { - visible: !this.props.sensitive || displaySensitiveMedia, + visible: displayMedia !== 'hide_all' && !this.props.sensitive || displayMedia === 'show_all', }; componentWillReceiveProps (nextProps) { diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index 6c595c712f..90c689a75a 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -285,7 +285,7 @@ class Status extends ImmutablePureComponent { - + {media} diff --git a/app/javascript/mastodon/components/status_content.js b/app/javascript/mastodon/components/status_content.js index 81013747ef..eda7d6ac3f 100644 --- a/app/javascript/mastodon/components/status_content.js +++ b/app/javascript/mastodon/components/status_content.js @@ -6,6 +6,8 @@ import { FormattedMessage } from 'react-intl'; import Permalink from './permalink'; import classnames from 'classnames'; +const MAX_HEIGHT = 642; // 20px * 32 (+ 2px padding at the top) + export default class StatusContent extends React.PureComponent { static contextTypes = { @@ -17,10 +19,12 @@ export default class StatusContent extends React.PureComponent { expanded: PropTypes.bool, onExpandedToggle: PropTypes.func, onClick: PropTypes.func, + collapsable: PropTypes.bool, }; state = { hidden: true, + collapsed: null, // `collapsed: null` indicates that an element doesn't need collapsing, while `true` or `false` indicates that it does (and is/isn't). }; _updateStatusLinks () { @@ -53,6 +57,16 @@ export default class StatusContent extends React.PureComponent { link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener'); } + + if ( + this.props.collapsable + && this.props.onClick + && this.state.collapsed === null + && node.clientHeight > MAX_HEIGHT + && this.props.status.get('spoiler_text').length === 0 + ) { + this.setState({ collapsed: true }); + } } componentDidMount () { @@ -113,6 +127,11 @@ export default class StatusContent extends React.PureComponent { } } + handleCollapsedClick = (e) => { + e.preventDefault(); + this.setState({ collapsed: !this.state.collapsed }); + } + setRef = (c) => { this.node = c; } @@ -132,12 +151,19 @@ export default class StatusContent extends React.PureComponent { const classNames = classnames('status__content', { 'status__content--with-action': this.props.onClick && this.context.router, 'status__content--with-spoiler': status.get('spoiler_text').length > 0, + 'status__content--collapsed': this.state.collapsed === true, }); if (isRtl(status.get('search_index'))) { directionStyle.direction = 'rtl'; } + const readMoreButton = ( + + ); + if (status.get('spoiler_text').length > 0) { let mentionsPlaceholder = ''; @@ -167,17 +193,23 @@ export default class StatusContent extends React.PureComponent { ); } else if (this.props.onClick) { - return ( + const output = [
- ); + />, + ]; + + if (this.state.collapsed) { + output.push(readMoreButton); + } + + return output; } else { return (
{ diff --git a/app/javascript/mastodon/features/notifications/components/column_settings.js b/app/javascript/mastodon/features/notifications/components/column_settings.js index d9638aaf35..fcdf5c6e65 100644 --- a/app/javascript/mastodon/features/notifications/components/column_settings.js +++ b/app/javascript/mastodon/features/notifications/components/column_settings.js @@ -27,7 +27,6 @@ export default class ColumnSettings extends React.PureComponent { const showPushSettings = pushSettings.get('browserSupport') && pushSettings.get('isSubscribed'); const pushStr = showPushSettings && ; - const pushMeta = showPushSettings && ; return (
@@ -40,7 +39,7 @@ export default class ColumnSettings extends React.PureComponent {
- {showPushSettings && } + {showPushSettings && }
@@ -51,7 +50,7 @@ export default class ColumnSettings extends React.PureComponent {
- {showPushSettings && } + {showPushSettings && }
@@ -62,7 +61,7 @@ export default class ColumnSettings extends React.PureComponent {
- {showPushSettings && } + {showPushSettings && }
@@ -73,7 +72,7 @@ export default class ColumnSettings extends React.PureComponent {
- {showPushSettings && } + {showPushSettings && }
diff --git a/app/javascript/mastodon/features/notifications/components/notification.js b/app/javascript/mastodon/features/notifications/components/notification.js index ed4a44ca67..8df6830c52 100644 --- a/app/javascript/mastodon/features/notifications/components/notification.js +++ b/app/javascript/mastodon/features/notifications/components/notification.js @@ -85,8 +85,9 @@ class Notification extends ImmutablePureComponent {
- - + + +