From e7a7f88df7a763be6dad3a982829ef5a1b1dea09 Mon Sep 17 00:00:00 2001 From: ThibG Date: Mon, 25 Nov 2019 01:42:51 +0100 Subject: Fix OCR with delete & redraft (#12465) --- app/javascript/mastodon/features/ui/components/focal_point_modal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/javascript/mastodon/features/ui/components/focal_point_modal.js b/app/javascript/mastodon/features/ui/components/focal_point_modal.js index ddbe3961d..7d1509f71 100644 --- a/app/javascript/mastodon/features/ui/components/focal_point_modal.js +++ b/app/javascript/mastodon/features/ui/components/focal_point_modal.js @@ -214,7 +214,7 @@ class FocalPointModal extends ImmutablePureComponent { langPath: `${assetHost}/ocr/lang-data`, }); - let media_url = media.get('file'); + let media_url = media.get('url'); if (window.URL && URL.createObjectURL) { try { -- cgit From 00c219aa4536206a3f5f8e0e46f1c132c4282b65 Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 26 Nov 2019 22:46:31 +0100 Subject: Fix empty poll options not being filtered on remote poll update (#12484) If a poll contains empty options (which is apparently possible on Pleroma), it is created without them. However, the poll update code doesn't filter empty options, and thus: 1. Clear known votes, as it assumes the set of options has changed 2. Errors out because it tries adding empty options, which fails validation This commit fixes that by filtering them out the same way they are filtered out at poll creation time. --- app/services/activitypub/process_poll_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/services/activitypub/process_poll_service.rb b/app/services/activitypub/process_poll_service.rb index cb4a0d460..903b6a78a 100644 --- a/app/services/activitypub/process_poll_service.rb +++ b/app/services/activitypub/process_poll_service.rb @@ -30,7 +30,7 @@ class ActivityPub::ProcessPollService < BaseService voters_count = @json['votersCount'] - latest_options = items.map { |item| item['name'].presence || item['content'] } + latest_options = items.map { |item| item['name'].presence || item['content'] }.compact # If for some reasons the options were changed, it invalidates all previous # votes, so we need to remove them -- cgit From d9793b2367ec6171256e46dde9657f664c2b4268 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 28 Nov 2019 04:07:49 +0100 Subject: Fix proofs API being inaccessible in secure mode (#12495) --- app/controllers/api/proofs_controller.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/controllers/api/proofs_controller.rb b/app/controllers/api/proofs_controller.rb index a98599eee..dd32cd577 100644 --- a/app/controllers/api/proofs_controller.rb +++ b/app/controllers/api/proofs_controller.rb @@ -3,6 +3,8 @@ class Api::ProofsController < Api::BaseController include AccountOwnedConcern + skip_before_action :require_authenticated_user! + before_action :set_provider def index -- cgit From 07da35c17c4ff8e0fc7b90aba0b619dae119a633 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 28 Nov 2019 04:08:00 +0100 Subject: Fix n+1 query for bookmarks on statuses (#12494) --- app/presenters/status_relationships_presenter.rb | 3 ++- app/serializers/rest/status_serializer.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/presenters/status_relationships_presenter.rb b/app/presenters/status_relationships_presenter.rb index 64e688d87..3cc905a75 100644 --- a/app/presenters/status_relationships_presenter.rb +++ b/app/presenters/status_relationships_presenter.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class StatusRelationshipsPresenter - attr_reader :reblogs_map, :favourites_map, :mutes_map, :pins_map + attr_reader :reblogs_map, :favourites_map, :mutes_map, :pins_map, + :bookmarks_map def initialize(statuses, current_account_id = nil, **options) if current_account_id.nil? diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index 08bc4d82a..1ed8948da 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -95,8 +95,8 @@ class REST::StatusSerializer < ActiveModel::Serializer end def bookmarked - if instance_options && instance_options[:bookmarks] - instance_options[:bookmarks].bookmarks_map[object.id] || false + if instance_options && instance_options[:relationships] + instance_options[:relationships].bookmarks_map[object.id] || false else current_user.account.bookmarked?(object) end -- cgit From 667708f5b00ee8b7795eacd9c20d29f77c8ae602 Mon Sep 17 00:00:00 2001 From: ThibG Date: Fri, 29 Nov 2019 17:02:18 +0100 Subject: Fix pending upload count not being decremented on error (#12499) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The arguments were passed to the wrong function… also, there is no need to have a conditional decrementation: failure to upload means we marked an upload as pending, in all cases. --- app/javascript/mastodon/actions/compose.js | 5 ++--- app/javascript/mastodon/reducers/compose.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js index 727f02718..c3c6ff1a1 100644 --- a/app/javascript/mastodon/actions/compose.js +++ b/app/javascript/mastodon/actions/compose.js @@ -236,7 +236,7 @@ export function uploadCompose(files) { dispatch(uploadComposeProgress(progress.reduce((a, v) => a + v, 0), total)); }, }).then(({ data }) => dispatch(uploadComposeSuccess(data, f))); - }).catch(error => dispatch(uploadComposeFail(error, true))); + }).catch(error => dispatch(uploadComposeFail(error))); }; }; }; @@ -267,11 +267,10 @@ export function changeUploadComposeSuccess(media) { }; }; -export function changeUploadComposeFail(error, decrement = false) { +export function changeUploadComposeFail(error) { return { type: COMPOSE_UPLOAD_CHANGE_FAIL, error: error, - decrement: decrement, skipLoading: true, }; }; diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index 4c3342ccc..c6653fe4c 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -328,7 +328,7 @@ export default function compose(state = initialState, action) { case COMPOSE_UPLOAD_SUCCESS: return appendMedia(state, fromJS(action.media), action.file); case COMPOSE_UPLOAD_FAIL: - return state.set('is_uploading', false).update('pending_media_attachments', n => action.decrement ? n - 1 : n); + return state.set('is_uploading', false).update('pending_media_attachments', n => n - 1); case COMPOSE_UPLOAD_UNDO: return removeMedia(state, action.media_id); case COMPOSE_UPLOAD_PROGRESS: -- cgit From a690b3e470ed85cc6f3f8fa7aec57d04b60a4705 Mon Sep 17 00:00:00 2001 From: ThibG Date: Fri, 29 Nov 2019 17:02:36 +0100 Subject: Add hotkey for opening media files (#12498) * [WiP] Add hotkey to open media * Give focus to play/pause button when opening video modal --- app/javascript/mastodon/components/status.js | 17 +++++++++++++++++ .../mastodon/features/keyboard_shortcuts/index.js | 4 ++++ app/javascript/mastodon/features/status/index.js | 17 +++++++++++++++++ app/javascript/mastodon/features/ui/index.js | 1 + app/javascript/mastodon/features/video/index.js | 2 +- 5 files changed, 40 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index 6cfa96040..3176bda89 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -214,6 +214,22 @@ class Status extends ImmutablePureComponent { this.props.onOpenVideo(media, startTime); } + handleHotkeyOpenMedia = e => { + const { status, onOpenMedia, onOpenVideo } = this.props; + + e.preventDefault(); + + if (status.get('media_attachments').size > 0) { + if (status.getIn(['media_attachments', 0, 'type']) === 'audio') { + // TODO: toggle play/paused? + } else if (status.getIn(['media_attachments', 0, 'type']) === 'video') { + onOpenVideo(status.getIn(['media_attachments', 0]), 0); + } else { + onOpenMedia(status.get('media_attachments'), 0); + } + } + } + handleHotkeyReply = e => { e.preventDefault(); this.props.onReply(this._properStatus(), this.context.router.history); @@ -293,6 +309,7 @@ class Status extends ImmutablePureComponent { moveDown: this.handleHotkeyMoveDown, toggleHidden: this.handleHotkeyToggleHidden, toggleSensitive: this.handleHotkeyToggleSensitive, + openMedia: this.handleHotkeyOpenMedia, }; if (hidden) { diff --git a/app/javascript/mastodon/features/keyboard_shortcuts/index.js b/app/javascript/mastodon/features/keyboard_shortcuts/index.js index 90dc87cbb..666baf621 100644 --- a/app/javascript/mastodon/features/keyboard_shortcuts/index.js +++ b/app/javascript/mastodon/features/keyboard_shortcuts/index.js @@ -56,6 +56,10 @@ class KeyboardShortcuts extends ImmutablePureComponent { enter, o + + e + + x diff --git a/app/javascript/mastodon/features/status/index.js b/app/javascript/mastodon/features/status/index.js index 55bd99886..ab468b5e8 100644 --- a/app/javascript/mastodon/features/status/index.js +++ b/app/javascript/mastodon/features/status/index.js @@ -281,6 +281,22 @@ class Status extends ImmutablePureComponent { this.props.dispatch(openModal('VIDEO', { media, time })); } + handleHotkeyOpenMedia = e => { + const { status } = this.props; + + e.preventDefault(); + + if (status.get('media_attachments').size > 0) { + if (status.getIn(['media_attachments', 0, 'type']) === 'audio') { + // TODO: toggle play/paused? + } else if (status.getIn(['media_attachments', 0, 'type']) === 'video') { + this.handleOpenVideo(status.getIn(['media_attachments', 0]), 0); + } else { + this.handleOpenMedia(status.get('media_attachments'), 0); + } + } + } + handleMuteClick = (account) => { this.props.dispatch(initMuteModal(account)); } @@ -506,6 +522,7 @@ class Status extends ImmutablePureComponent { openProfile: this.handleHotkeyOpenProfile, toggleHidden: this.handleHotkeyToggleHidden, toggleSensitive: this.handleHotkeyToggleSensitive, + openMedia: this.handleHotkeyOpenMedia, }; return ( diff --git a/app/javascript/mastodon/features/ui/index.js b/app/javascript/mastodon/features/ui/index.js index b0e38c5cb..957e80737 100644 --- a/app/javascript/mastodon/features/ui/index.js +++ b/app/javascript/mastodon/features/ui/index.js @@ -100,6 +100,7 @@ const keyMap = { goToRequests: 'g r', toggleHidden: 'x', toggleSensitive: 'h', + openMedia: 'e', }; class SwitchingColumnsArea extends React.PureComponent { diff --git a/app/javascript/mastodon/features/video/index.js b/app/javascript/mastodon/features/video/index.js index 7ca477d35..f6aeb8c9a 100644 --- a/app/javascript/mastodon/features/video/index.js +++ b/app/javascript/mastodon/features/video/index.js @@ -467,7 +467,7 @@ class Video extends React.PureComponent {
- +
-- cgit From fd45f5bbaabcc83ae66e507414c657beba9b3ce5 Mon Sep 17 00:00:00 2001 From: Sasha Sorokin Date: Fri, 29 Nov 2019 23:03:06 +0700 Subject: Improve notifications page (#12497) Currently notifications page seems a bit cluttered with no clear separation between e-mail and filtering settings. This commit tries to address them by adding clear separation with headers, hints and removing continuously reused texts for events checkboxes. --- .../settings/preferences/notifications/show.html.haml | 6 ++++++ config/locales/en.yml | 4 ++++ config/locales/simple_form.en.yml | 16 ++++++++-------- 3 files changed, 18 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/views/settings/preferences/notifications/show.html.haml b/app/views/settings/preferences/notifications/show.html.haml index f666ae4ff..f71b930e7 100644 --- a/app/views/settings/preferences/notifications/show.html.haml +++ b/app/views/settings/preferences/notifications/show.html.haml @@ -4,6 +4,10 @@ = simple_form_for current_user, url: settings_preferences_notifications_path, html: { method: :put } do |f| = render 'shared/error_messages', object: current_user + %h4= t('notifications.email_events') + + %p.hint = t('notifications.email_events_hint') + .fields-group = f.simple_fields_for :notification_emails, hash_to_object(current_user.settings.notification_emails) do |ff| = ff.input :follow, as: :boolean, wrapper: :with_label @@ -21,6 +25,8 @@ = f.simple_fields_for :notification_emails, hash_to_object(current_user.settings.notification_emails) do |ff| = ff.input :digest, as: :boolean, wrapper: :with_label + %h4 = t('notifications.other_settings') + .fields-group = f.simple_fields_for :interactions, hash_to_object(current_user.settings.interactions) do |ff| = ff.input :must_be_follower, as: :boolean, wrapper: :with_label diff --git a/config/locales/en.yml b/config/locales/en.yml index 531036a63..783b7a4f6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -886,6 +886,10 @@ en: body: 'Your status was boosted by %{name}:' subject: "%{name} boosted your status" title: New boost + notifications: + email_events: Events for e-mail notifications + email_events_hint: 'Select events that you want to receive notifications for:' + other_settings: Other notifications settings number: human: decimal_units: diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 65951b73b..66f518c1b 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -150,14 +150,14 @@ en: text: Why do you want to join? notification_emails: digest: Send digest e-mails - favourite: Send e-mail when someone favourites your status - follow: Send e-mail when someone follows you - follow_request: Send e-mail when someone requests to follow you - mention: Send e-mail when someone mentions you - pending_account: Send e-mail when a new account needs review - reblog: Send e-mail when someone boosts your status - report: Send e-mail when a new report is submitted - trending_tag: Send e-mail when an unreviewed hashtag is trending + favourite: Someone favourited your status + follow: Someone followed you + follow_request: Someone requested to follow you + mention: Someone mentioned you + pending_account: New account needs review + reblog: Someone boosted your status + report: New report is submitted + trending_tag: An unreviewed hashtag is trending tag: listable: Allow this hashtag to appear in searches and on the profile directory name: Hashtag -- cgit From b532ead798c481fd03be9eb78e910d62654cdaa8 Mon Sep 17 00:00:00 2001 From: Sasha Sorokin Date: Fri, 29 Nov 2019 23:03:38 +0700 Subject: Fix counter sizing (#12446) Counter size is currently set to strict 33.3% width, but with it counter may break in other languages than English. For example it is already broken on Gargron's profile on mastodon.social using Russian locale. This commit changes "width" to "min-width", so counters still displayed correctly, but if they need more width to fit text, they are now allowed to take as many width as they need. --- app/javascript/styles/mastodon/containers.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/javascript/styles/mastodon/containers.scss b/app/javascript/styles/mastodon/containers.scss index 319f8c94d..51d9b46b0 100644 --- a/app/javascript/styles/mastodon/containers.scss +++ b/app/javascript/styles/mastodon/containers.scss @@ -646,7 +646,7 @@ } .counter { - width: 33.3%; + min-width: 33.3%; box-sizing: border-box; flex: 0 0 auto; color: $darker-text-color; -- cgit