From 061feb63ed852acb5d70e2678c9e63425e6ca71b Mon Sep 17 00:00:00 2001 From: ThibG Date: Mon, 21 Jan 2019 20:03:04 +0100 Subject: Fix scheduled toot with media immediately creating a toot (#9894) * Add test for not persisting status when attaching media to scheduled toot * Prevent status used for validation from being persisted to the database Fixes #9893 Thanks to tateisu for the help investigating this. --- app/services/post_status_service.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index cc3453f99..1f5a3f4cf 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -66,7 +66,10 @@ class PostStatusService < BaseService end def schedule_status! - if @account.statuses.build(status_attributes).valid? + status_for_validation = @account.statuses.build(status_attributes) + if status_for_validation.valid? + status_for_validation.destroy + # The following transaction block is needed to wrap the UPDATEs to # the media attachments when the scheduled status is created -- cgit From d50e824168a32d41ec1efce13beef22a4d7ff7c5 Mon Sep 17 00:00:00 2001 From: Jeong Arm Date: Tue, 22 Jan 2019 04:03:44 +0900 Subject: Apply style for .landing-page strong (#9892) --- app/javascript/styles/mastodon/about.scss | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app') diff --git a/app/javascript/styles/mastodon/about.scss b/app/javascript/styles/mastodon/about.scss index c6f249fab..b6c92a09e 100644 --- a/app/javascript/styles/mastodon/about.scss +++ b/app/javascript/styles/mastodon/about.scss @@ -845,6 +845,18 @@ $small-breakpoint: 960px; margin-bottom: 0; } + strong { + display: inline; + margin: 0; + padding: 0; + font-weight: 700; + background: transparent; + font-family: inherit; + font-size: inherit; + line-height: inherit; + color: lighten($darker-text-color, 10%); + } + .account { border-bottom: 0; padding: 0; -- cgit From c30da25c5fa98c4972b5a7dc57440e4020114aa2 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Wed, 23 Jan 2019 18:29:18 +0100 Subject: Fix crash in Direct Messages column settings Fixes #892 --- .../glitch/features/direct_timeline/components/column_settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/javascript/flavours/glitch/features/direct_timeline/components/column_settings.js b/app/javascript/flavours/glitch/features/direct_timeline/components/column_settings.js index a992b27bb..5adb44f2c 100644 --- a/app/javascript/flavours/glitch/features/direct_timeline/components/column_settings.js +++ b/app/javascript/flavours/glitch/features/direct_timeline/components/column_settings.js @@ -26,7 +26,7 @@ export default class ColumnSettings extends React.PureComponent {
- +
); -- cgit From c87863bdd18213a7181914b76752959b0617ade1 Mon Sep 17 00:00:00 2001 From: trwnh Date: Thu, 24 Jan 2019 06:32:23 -0600 Subject: Fix Firefox scrollbar color regression in #9210 (#9908) In #9210 the track color was changed to transparent for no apparent reason. This PR restores the previous color selections implemented in #8653 while keeping the updated property name. Per https://github.com/tootsuite/mastodon/pull/9210#issuecomment-441788776 there is no particular reason for the color change in #9210. --- app/javascript/styles/mastodon/reset.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/javascript/styles/mastodon/reset.scss b/app/javascript/styles/mastodon/reset.scss index e24ba8c1c..f54ed5bc7 100644 --- a/app/javascript/styles/mastodon/reset.scss +++ b/app/javascript/styles/mastodon/reset.scss @@ -54,7 +54,7 @@ table { } html { - scrollbar-color: lighten($ui-base-color, 4%) transparent; + scrollbar-color: lighten($ui-base-color, 4%) rgba($base-overlay-background, 0.1); } ::-webkit-scrollbar { -- cgit From e1ec3a9f09add8a34b1a77ce217be8e51ebd4936 Mon Sep 17 00:00:00 2001 From: "Renato \"Lond\" Cerqueira" Date: Thu, 24 Jan 2019 15:38:18 +0100 Subject: Rescue SSL error in verify link service (#9914) If the first link to be verified contains a rel=me link with a SSL error, the VerifyAccountLinksWorker will fail and not try the following links. This rescues the SSL error when fetching the link, avoiding this issue. --- app/services/verify_link_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/services/verify_link_service.rb b/app/services/verify_link_service.rb index c65578761..878a2188d 100644 --- a/app/services/verify_link_service.rb +++ b/app/services/verify_link_service.rb @@ -10,7 +10,7 @@ class VerifyLinkService < BaseService return unless link_back_present? field.mark_verified! - rescue HTTP::Error, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError => e + rescue OpenSSL::SSL::SSLError, HTTP::Error, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError => e Rails.logger.debug "Error fetching link #{@url}: #{e}" nil end -- cgit From 77394156dd43bb5a711d3434504a26c8d1e2acf5 Mon Sep 17 00:00:00 2001 From: Jeong Arm Date: Tue, 22 Jan 2019 04:03:44 +0900 Subject: Apply style for .landing-page strong (#9892) --- app/javascript/flavours/glitch/styles/about.scss | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app') diff --git a/app/javascript/flavours/glitch/styles/about.scss b/app/javascript/flavours/glitch/styles/about.scss index e8f46766a..302de020b 100644 --- a/app/javascript/flavours/glitch/styles/about.scss +++ b/app/javascript/flavours/glitch/styles/about.scss @@ -847,6 +847,18 @@ $small-breakpoint: 960px; margin-bottom: 0; } + strong { + display: inline; + margin: 0; + padding: 0; + font-weight: 700; + background: transparent; + font-family: inherit; + font-size: inherit; + line-height: inherit; + color: lighten($darker-text-color, 10%); + } + .account { border-bottom: 0; padding: 0; -- cgit From 8ef0498f1ca4ff4dab7d8255f15577a86907c392 Mon Sep 17 00:00:00 2001 From: trwnh Date: Thu, 24 Jan 2019 06:32:23 -0600 Subject: Fix Firefox scrollbar color regression in #9210 (#9908) In #9210 the track color was changed to transparent for no apparent reason. This PR restores the previous color selections implemented in #8653 while keeping the updated property name. Per https://github.com/tootsuite/mastodon/pull/9210#issuecomment-441788776 there is no particular reason for the color change in #9210. --- app/javascript/flavours/glitch/styles/reset.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/javascript/flavours/glitch/styles/reset.scss b/app/javascript/flavours/glitch/styles/reset.scss index e24ba8c1c..f54ed5bc7 100644 --- a/app/javascript/flavours/glitch/styles/reset.scss +++ b/app/javascript/flavours/glitch/styles/reset.scss @@ -54,7 +54,7 @@ table { } html { - scrollbar-color: lighten($ui-base-color, 4%) transparent; + scrollbar-color: lighten($ui-base-color, 4%) rgba($base-overlay-background, 0.1); } ::-webkit-scrollbar { -- cgit From 9519d55332a1f22891e5ad8a1de1d2ba027bafc7 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 25 Jan 2019 12:36:54 +0100 Subject: Fix SSO authentication not working due to missing agreement boolean (#9915) Fix #9906 --- app/models/concerns/omniauthable.rb | 1 + app/models/user.rb | 2 ++ 2 files changed, 3 insertions(+) (limited to 'app') diff --git a/app/models/concerns/omniauthable.rb b/app/models/concerns/omniauthable.rb index f263fe7af..4dd2e9383 100644 --- a/app/models/concerns/omniauthable.rb +++ b/app/models/concerns/omniauthable.rb @@ -63,6 +63,7 @@ module Omniauthable { email: email || "#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com", password: Devise.friendly_token[0, 20], + agreement: true, account_attributes: { username: ensure_unique_username(auth.uid), display_name: display_name, diff --git a/app/models/user.rb b/app/models/user.rb index 5aa5c2b15..fdd2741c1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -295,6 +295,7 @@ class User < ApplicationRecord def self.pam_get_user(attributes = {}) return nil unless attributes[:email] + resource = if Devise.check_at_sign && !attributes[:email].index('@') joins(:account).find_by(accounts: { username: attributes[:email] }) @@ -304,6 +305,7 @@ class User < ApplicationRecord if resource.blank? resource = new(email: attributes[:email], agreement: true) + if Devise.check_at_sign && !resource[:email].index('@') resource[:email] = Rpam2.getenv(resource.find_pam_service, attributes[:email], attributes[:password], 'email', false) resource[:email] = "#{attributes[:email]}@#{resource.find_pam_suffix}" unless resource[:email] -- cgit From e2a5be6e9a070792fa72711c812f75bc61990052 Mon Sep 17 00:00:00 2001 From: ThibG Date: Sat, 26 Jan 2019 23:59:39 +0100 Subject: Prevent posting toots with media attachments from someone else (#9921) --- app/services/post_status_service.rb | 2 +- spec/services/post_status_service_spec.rb | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 1f5a3f4cf..9959bb1fb 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -93,7 +93,7 @@ class PostStatusService < BaseService raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if @options[:media_ids].size > 4 - @media = MediaAttachment.where(status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i)) + @media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i)) raise Mastodon::ValidationError, I18n.t('media_attachments.validations.images_and_video') if @media.size > 1 && @media.find(&:video?) end diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index 680cebbcf..facbe977f 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -167,7 +167,7 @@ RSpec.describe PostStatusService, type: :service do it 'attaches the given media to the created status' do account = Fabricate(:account) - media = Fabricate(:media_attachment) + media = Fabricate(:media_attachment, account: account) status = subject.call( account, @@ -178,6 +178,19 @@ RSpec.describe PostStatusService, type: :service do expect(media.reload.status).to eq status end + it 'does not attach media from another account to the created status' do + account = Fabricate(:account) + media = Fabricate(:media_attachment, account: Fabricate(:account)) + + status = subject.call( + account, + text: "test status update", + media_ids: [media.id], + ) + + expect(media.reload.status).to eq nil + end + it 'does not allow attaching more than 4 files' do account = Fabricate(:account) -- cgit From 05415fa5d38e988d967cc783dd2eb0852852fce2 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Mon, 21 Jan 2019 19:36:33 +0100 Subject: Make storing and displaying application used to toot opt-in --- app/controllers/settings/preferences_controller.rb | 1 + app/lib/user_settings_decorator.rb | 5 +++++ app/models/account.rb | 1 + app/models/user.rb | 6 +++++- app/serializers/rest/status_serializer.rb | 6 +++++- app/services/post_status_service.rb | 1 + app/views/settings/preferences/show.html.haml | 3 +++ app/views/stream_entries/_detailed_status.html.haml | 2 +- config/locales/simple_form.en.yml | 2 ++ config/settings.yml | 1 + 10 files changed, 25 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index d4932afd6..241053261 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -45,6 +45,7 @@ class Settings::PreferencesController < Settings::BaseController :setting_hide_network, :setting_hide_followers_count, :setting_aggregate_reblogs, + :setting_show_application, notification_emails: %i(follow follow_request reblog favourite mention digest report), interactions: %i(must_be_follower must_be_following) ) diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index 569255f6e..367ba9a83 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -35,6 +35,7 @@ class UserSettingsDecorator user.settings['skin'] = skin_preference if change?('setting_skin') user.settings['hide_network'] = hide_network_preference if change?('setting_hide_network') user.settings['aggregate_reblogs'] = aggregate_reblogs_preference if change?('setting_aggregate_reblogs') + user.settings['show_application'] = show_application_preference if change?('setting_show_application') end def merged_notification_emails @@ -109,6 +110,10 @@ class UserSettingsDecorator boolean_cast_setting 'setting_hide_network' end + def show_application_preference + boolean_cast_setting 'setting_show_application' + end + def default_language_preference settings['setting_default_language'] end diff --git a/app/models/account.rb b/app/models/account.rb index 1ee63c738..c86c6fdb5 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -113,6 +113,7 @@ class Account < ApplicationRecord :staff?, :locale, :hides_network?, + :shows_application?, to: :user, prefix: true, allow_nil: true diff --git a/app/models/user.rb b/app/models/user.rb index fbb6545db..ce9ef2a13 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -100,7 +100,7 @@ class User < ApplicationRecord delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal, :reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, :hide_followers_count, - :expand_spoilers, :default_language, :aggregate_reblogs, to: :settings, prefix: :setting, allow_nil: false + :expand_spoilers, :default_language, :aggregate_reblogs, :show_application, to: :settings, prefix: :setting, allow_nil: false attr_reader :invite_code @@ -244,6 +244,10 @@ class User < ApplicationRecord @aggregates_reblogs ||= settings.aggregate_reblogs end + def shows_application? + @shows_application ||= settings.shows_application + end + def token_for_app(a) return nil if a.nil? || a.owner != self Doorkeeper::AccessToken diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index dd8482eea..f2b5febae 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -14,7 +14,7 @@ class REST::StatusSerializer < ActiveModel::Serializer attribute :local_only if :local? belongs_to :reblog, serializer: REST::StatusSerializer - belongs_to :application + belongs_to :application, if: :user_shows_application? belongs_to :account, serializer: REST::AccountSerializer has_many :media_attachments, serializer: REST::MediaAttachmentSerializer @@ -40,6 +40,10 @@ class REST::StatusSerializer < ActiveModel::Serializer !current_user.nil? end + def user_shows_application? + object.account.user_shows_application? + end + def visibility # This visibility is masked behind "private" # to avoid API changes because there are no diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index e4b61ee35..24a853373 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -22,6 +22,7 @@ class PostStatusService < BaseService @options = options @text = @options[:text] || '' @in_reply_to = @options[:thread] + @options.delete(:application) unless @account.user&.setting_show_application return idempotency_duplicate if idempotency_given? && idempotency_duplicate? diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml index 6510e0560..c666bafb5 100644 --- a/app/views/settings/preferences/show.html.haml +++ b/app/views/settings/preferences/show.html.haml @@ -34,6 +34,9 @@ .fields-group = f.input :setting_hide_network, as: :boolean, wrapper: :with_label + .fields-group + = f.input :setting_show_application, as: :boolean, wrapper: :with_label + - unless Setting.hide_followers_count .fields-group = f.input :setting_hide_followers_count, as: :boolean, wrapper: :with_label diff --git a/app/views/stream_entries/_detailed_status.html.haml b/app/views/stream_entries/_detailed_status.html.haml index 18265e110..e123d657f 100644 --- a/app/views/stream_entries/_detailed_status.html.haml +++ b/app/views/stream_entries/_detailed_status.html.haml @@ -39,7 +39,7 @@ = link_to TagManager.instance.url_for(status), class: 'detailed-status__datetime u-url u-uid', target: stream_link_target, rel: 'noopener' do %time.formatted{ datetime: status.created_at.iso8601, title: l(status.created_at) }= l(status.created_at) ยท - - if status.application + - if status.application && @account.user&.setting_show_application - if status.application.website.blank? %strong.detailed-status__application= status.application.name - else diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index c75471658..674abff63 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -33,6 +33,7 @@ en: setting_display_media_show_all: Always show media marked as sensitive setting_hide_network: Who you follow and who follows you will not be shown on your profile setting_noindex: Affects your public profile and status pages + setting_show_application: The application you use to toot will be displayed in the detailed view of your toots setting_skin: Reskins the selected Mastodon flavour username: Your username will be unique on %{domain} whole_word: When the keyword or phrase is alphanumeric only, it will only be applied if it matches the whole word @@ -102,6 +103,7 @@ en: setting_hide_network: Hide your network setting_noindex: Opt-out of search engine indexing setting_reduce_motion: Reduce motion in animations + setting_show_application: Disclose application used to send toots setting_skin: Skin setting_system_font_ui: Use system's default font setting_unfollow_modal: Show confirmation dialog before unfollowing someone diff --git a/config/settings.yml b/config/settings.yml index 4f070240a..af596b738 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -27,6 +27,7 @@ defaults: &defaults expand_spoilers: false preview_sensitive_media: false reduce_motion: false + show_application: false system_font_ui: false noindex: false hide_followers_count: false -- cgit From f938800ef4fcd7f63310e3f1d021c809f60ea448 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Mon, 21 Jan 2019 22:40:26 +0100 Subject: Revert to storing application info, and display it to the author via API --- app/serializers/rest/status_serializer.rb | 6 +++--- app/services/post_status_service.rb | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index f2b5febae..b72eebb10 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -14,7 +14,7 @@ class REST::StatusSerializer < ActiveModel::Serializer attribute :local_only if :local? belongs_to :reblog, serializer: REST::StatusSerializer - belongs_to :application, if: :user_shows_application? + belongs_to :application, if: :show_application? belongs_to :account, serializer: REST::AccountSerializer has_many :media_attachments, serializer: REST::MediaAttachmentSerializer @@ -40,8 +40,8 @@ class REST::StatusSerializer < ActiveModel::Serializer !current_user.nil? end - def user_shows_application? - object.account.user_shows_application? + def show_application? + object.account.user_shows_application? || (current_user? && current_user.account_id == object.account_id) end def visibility diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 24a853373..e4b61ee35 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -22,7 +22,6 @@ class PostStatusService < BaseService @options = options @text = @options[:text] || '' @in_reply_to = @options[:thread] - @options.delete(:application) unless @account.user&.setting_show_application return idempotency_duplicate if idempotency_given? && idempotency_duplicate? -- cgit From ec5bd8b8bbe5a7500680eeab40ce36f28373d0ba Mon Sep 17 00:00:00 2001 From: ThibG Date: Sun, 27 Jan 2019 17:54:54 +0100 Subject: Implement missing hotkeys for notifications (#9927) --- .../notifications/components/notification.js | 30 ++++++++++-- .../containers/notification_container.js | 57 ++++++++++++++++++++-- 2 files changed, 79 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/features/notifications/components/notification.js b/app/javascript/mastodon/features/notifications/components/notification.js index 44da423ad..97efff69c 100644 --- a/app/javascript/mastodon/features/notifications/components/notification.js +++ b/app/javascript/mastodon/features/notifications/components/notification.js @@ -29,6 +29,10 @@ class Notification extends ImmutablePureComponent { onMoveUp: PropTypes.func.isRequired, onMoveDown: PropTypes.func.isRequired, onMention: PropTypes.func.isRequired, + onFavourite: PropTypes.func.isRequired, + onReblog: PropTypes.func.isRequired, + onToggleHidden: PropTypes.func.isRequired, + status: PropTypes.option, intl: PropTypes.object.isRequired, }; @@ -64,14 +68,32 @@ class Notification extends ImmutablePureComponent { onMention(notification.get('account'), this.context.router.history); } + handleHotkeyFavourite = () => { + const { status } = this.props; + if (status) this.props.onFavourite(status); + } + + handleHotkeyBoost = e => { + const { status } = this.props; + if (status) this.props.onReblog(status, e); + } + + handleHotkeyToggleHidden = () => { + const { status } = this.props; + if (status) this.props.onToggleHidden(status); + } + getHandlers () { return { - moveUp: this.handleMoveUp, - moveDown: this.handleMoveDown, + reply: this.handleMention, + favourite: this.handleHotkeyFavourite, + boost: this.handleHotkeyBoost, + mention: this.handleMention, open: this.handleOpen, openProfile: this.handleOpenProfile, - mention: this.handleMention, - reply: this.handleMention, + moveUp: this.handleMoveUp, + moveDown: this.handleMoveDown, + toggleHidden: this.handleHotkeyToggleHidden, }; } diff --git a/app/javascript/mastodon/features/notifications/containers/notification_container.js b/app/javascript/mastodon/features/notifications/containers/notification_container.js index 921aa460f..78576c760 100644 --- a/app/javascript/mastodon/features/notifications/containers/notification_container.js +++ b/app/javascript/mastodon/features/notifications/containers/notification_container.js @@ -1,14 +1,31 @@ import { connect } from 'react-redux'; -import { makeGetNotification } from '../../../selectors'; +import { makeGetNotification, makeGetStatus } from '../../../selectors'; import Notification from '../components/notification'; +import { openModal } from '../../../actions/modal'; import { mentionCompose } from '../../../actions/compose'; +import { + reblog, + favourite, + unreblog, + unfavourite, +} from '../../../actions/interactions'; +import { + hideStatus, + revealStatus, +} from '../../../actions/statuses'; +import { boostModal } from '../../../initial_state'; const makeMapStateToProps = () => { const getNotification = makeGetNotification(); + const getStatus = makeGetStatus(); - const mapStateToProps = (state, props) => ({ - notification: getNotification(state, props.notification, props.accountId), - }); + const mapStateToProps = (state, props) => { + const notification = getNotification(state, props.notification, props.accountId); + return { + notification: notification, + status: notification.get('status') ? getStatus(state, { id: notification.get('status') }) : null, + }; + }; return mapStateToProps; }; @@ -17,6 +34,38 @@ const mapDispatchToProps = dispatch => ({ onMention: (account, router) => { dispatch(mentionCompose(account, router)); }, + + onModalReblog (status) { + dispatch(reblog(status)); + }, + + onReblog (status, e) { + if (status.get('reblogged')) { + dispatch(unreblog(status)); + } else { + if (e.shiftKey || !boostModal) { + this.onModalReblog(status); + } else { + dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog })); + } + } + }, + + onFavourite (status) { + if (status.get('favourited')) { + dispatch(unfavourite(status)); + } else { + dispatch(favourite(status)); + } + }, + + onToggleHidden (status) { + if (status.get('hidden')) { + dispatch(revealStatus(status.get('id'))); + } else { + dispatch(hideStatus(status.get('id'))); + } + }, }); export default connect(makeMapStateToProps, mapDispatchToProps)(Notification); -- cgit From a53dcaa29869e808707efcba541b02ee8d799e75 Mon Sep 17 00:00:00 2001 From: ThibG Date: Sun, 27 Jan 2019 21:18:15 +0100 Subject: Fix initial value of volume slider in video player and handle volume changes (#9929) * Fix initial value of volume slider in video player and handle volume changes * Clean up dead/incorrect code --- app/javascript/mastodon/features/video/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/javascript/mastodon/features/video/index.js b/app/javascript/mastodon/features/video/index.js index 3650fddb6..0d0c24d71 100644 --- a/app/javascript/mastodon/features/video/index.js +++ b/app/javascript/mastodon/features/video/index.js @@ -136,6 +136,9 @@ class Video extends React.PureComponent { setVideoRef = c => { this.video = c; + if (this.video) { + this.setState({ volume: this.video.volume, muted: this.video.muted }); + } } setSeekRef = c => { @@ -302,6 +305,10 @@ class Video extends React.PureComponent { } } + handleVolumeChange = () => { + this.setState({ volume: this.video.volume, muted: this.video.muted }); + } + handleOpenVideo = () => { const { src, preview, width, height, alt } = this.props; const media = fromJS({ @@ -387,6 +394,7 @@ class Video extends React.PureComponent { onTimeUpdate={this.handleTimeUpdate} onLoadedData={this.handleLoadedData} onProgress={this.handleProgress} + onVolumeChange={this.handleVolumeChange} /> - +
Date: Sun, 27 Jan 2019 22:02:59 +0100 Subject: [Glitch] Fix initial value of volume slider in video player and handle volume changes Port a53dcaa29869e808707efcba541b02ee8d799e75 to glitch-soc --- app/javascript/flavours/glitch/features/video/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/javascript/flavours/glitch/features/video/index.js b/app/javascript/flavours/glitch/features/video/index.js index 30592707c..d8e8791a7 100644 --- a/app/javascript/flavours/glitch/features/video/index.js +++ b/app/javascript/flavours/glitch/features/video/index.js @@ -139,6 +139,9 @@ export default class Video extends React.PureComponent { setVideoRef = c => { this.video = c; + if (this.video) { + this.setState({ volume: this.video.volume, muted: this.video.muted }); + } } setSeekRef = c => { @@ -319,6 +322,10 @@ export default class Video extends React.PureComponent { } } + handleVolumeChange = () => { + this.setState({ volume: this.video.volume, muted: this.video.muted }); + } + handleOpenVideo = () => { const { src, preview, width, height, alt } = this.props; const media = fromJS({ @@ -407,6 +414,7 @@ export default class Video extends React.PureComponent { onTimeUpdate={this.handleTimeUpdate} onLoadedData={this.handleLoadedData} onProgress={this.handleProgress} + onVolumeChange={this.handleVolumeChange} /> - +