diff --git a/app/javascript/flavours/glitch/components/status.jsx b/app/javascript/flavours/glitch/components/status.jsx index dab6107441..49f88242bb 100644 --- a/app/javascript/flavours/glitch/components/status.jsx +++ b/app/javascript/flavours/glitch/components/status.jsx @@ -277,7 +277,12 @@ class Status extends ImmutablePureComponent { handleClick = e => { e.preventDefault(); - this.handleHotkeyOpen(e); + + if (e?.button === 0 && !(e?.ctrlKey || e?.metaKey)) { + this._openStatus(); + } else if (e?.button === 1 || (e?.button === 0 && (e?.ctrlKey || e?.metaKey))) { + this._openStatus(true); + } }; handleMouseUp = e => { @@ -354,7 +359,11 @@ class Status extends ImmutablePureComponent { this.props.onMention(this.props.status.get('account')); }; - handleHotkeyOpen = (e) => { + handleHotkeyOpen = () => { + this._openStatus(); + }; + + _openStatus = (newTab = false) => { if (this.props.onClick) { this.props.onClick(); return; @@ -369,7 +378,7 @@ class Status extends ImmutablePureComponent { const path = `/@${status.getIn(['account', 'acct'])}/${status.get('id')}`; - if (e?.button === 1 || (e?.button === 0 && (e?.ctrlKey || e?.metaKey))) { + if (newTab) { window.open(path, '_blank', 'noopener'); } else { history.push(path); diff --git a/app/javascript/flavours/glitch/features/ui/components/audio_modal.jsx b/app/javascript/flavours/glitch/features/ui/components/audio_modal.jsx index 09897c1634..5f10936b60 100644 --- a/app/javascript/flavours/glitch/features/ui/components/audio_modal.jsx +++ b/app/javascript/flavours/glitch/features/ui/components/audio_modal.jsx @@ -4,6 +4,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { connect } from 'react-redux'; +import { getAverageFromBlurhash } from 'flavours/glitch/blurhash'; import Audio from 'flavours/glitch/features/audio'; import Footer from 'flavours/glitch/features/picture_in_picture/components/footer'; @@ -26,6 +27,18 @@ class AudioModal extends ImmutablePureComponent { onChangeBackgroundColor: PropTypes.func.isRequired, }; + componentDidMount () { + const { media, onChangeBackgroundColor } = this.props; + + const backgroundColor = getAverageFromBlurhash(media.get('blurhash')); + + onChangeBackgroundColor(backgroundColor || { r: 255, g: 255, b: 255 }); + } + + componentWillUnmount () { + this.props.onChangeBackgroundColor(null); + } + render () { const { media, status, accountStaticAvatar, onClose } = this.props; const options = this.props.options || {}; diff --git a/app/javascript/flavours/glitch/features/ui/components/video_modal.jsx b/app/javascript/flavours/glitch/features/ui/components/video_modal.jsx index 489e26a909..beb9ad3c8f 100644 --- a/app/javascript/flavours/glitch/features/ui/components/video_modal.jsx +++ b/app/javascript/flavours/glitch/features/ui/components/video_modal.jsx @@ -37,6 +37,10 @@ class VideoModal extends ImmutablePureComponent { } } + componentWillUnmount () { + this.props.onChangeBackgroundColor(null); + } + render () { const { media, status, onClose } = this.props; const options = this.props.options || {}; diff --git a/app/javascript/mastodon/components/status.jsx b/app/javascript/mastodon/components/status.jsx index 2be3b94285..fb1fcb87fe 100644 --- a/app/javascript/mastodon/components/status.jsx +++ b/app/javascript/mastodon/components/status.jsx @@ -167,7 +167,12 @@ class Status extends ImmutablePureComponent { handleClick = e => { e.preventDefault(); - this.handleHotkeyOpen(e); + + if (e?.button === 0 && !(e?.ctrlKey || e?.metaKey)) { + this._openStatus(); + } else if (e?.button === 1 || (e?.button === 0 && (e?.ctrlKey || e?.metaKey))) { + this._openStatus(true); + } }; handleMouseUp = e => { @@ -275,7 +280,11 @@ class Status extends ImmutablePureComponent { this.props.onMention(this._properStatus().get('account')); }; - handleHotkeyOpen = (e) => { + handleHotkeyOpen = () => { + this._openStatus(); + }; + + _openStatus = (newTab = false) => { if (this.props.onClick) { this.props.onClick(); return; @@ -290,7 +299,7 @@ class Status extends ImmutablePureComponent { const path = `/@${status.getIn(['account', 'acct'])}/${status.get('id')}`; - if (e?.button === 1 || (e?.button === 0 && (e?.ctrlKey || e?.metaKey))) { + if (newTab) { window.open(path, '_blank', 'noopener'); } else { history.push(path); diff --git a/app/javascript/mastodon/features/ui/components/audio_modal.jsx b/app/javascript/mastodon/features/ui/components/audio_modal.jsx index 5baed2b3f9..dfefe689d8 100644 --- a/app/javascript/mastodon/features/ui/components/audio_modal.jsx +++ b/app/javascript/mastodon/features/ui/components/audio_modal.jsx @@ -4,6 +4,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { connect } from 'react-redux'; +import { getAverageFromBlurhash } from 'mastodon/blurhash'; import Audio from 'mastodon/features/audio'; import Footer from 'mastodon/features/picture_in_picture/components/footer'; @@ -26,6 +27,18 @@ class AudioModal extends ImmutablePureComponent { onChangeBackgroundColor: PropTypes.func.isRequired, }; + componentDidMount () { + const { media, onChangeBackgroundColor } = this.props; + + const backgroundColor = getAverageFromBlurhash(media.get('blurhash')); + + onChangeBackgroundColor(backgroundColor || { r: 255, g: 255, b: 255 }); + } + + componentWillUnmount () { + this.props.onChangeBackgroundColor(null); + } + render () { const { media, status, accountStaticAvatar, onClose } = this.props; const options = this.props.options || {}; diff --git a/app/javascript/mastodon/features/ui/components/video_modal.jsx b/app/javascript/mastodon/features/ui/components/video_modal.jsx index cc166d8bc5..4fc3ee1728 100644 --- a/app/javascript/mastodon/features/ui/components/video_modal.jsx +++ b/app/javascript/mastodon/features/ui/components/video_modal.jsx @@ -37,6 +37,10 @@ class VideoModal extends ImmutablePureComponent { } } + componentWillUnmount () { + this.props.onChangeBackgroundColor(null); + } + render () { const { media, status, onClose } = this.props; const options = this.props.options || {}; diff --git a/config/initializers/statistics.rb b/config/initializers/statistics.rb new file mode 100644 index 0000000000..9b35ac96c4 --- /dev/null +++ b/config/initializers/statistics.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +return unless defined?(Rails::Command::StatsCommand) + +[ + %w(AppLibs app/lib), + %w(Policies app/policies), + %w(Presenters app/presenters), + %w(Serializers app/serializers), + %w(Services app/services), + %w(Validators app/validators), + %w(Workers app/workers), +].each do |name, directory| + Rails::CodeStatistics.register_directory(name.titleize, directory) +end diff --git a/lib/tasks/statistics.rake b/lib/tasks/statistics.rake deleted file mode 100644 index 82840f4fdc..0000000000 --- a/lib/tasks/statistics.rake +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -task stats: 'mastodon:stats' - -namespace :mastodon do - desc 'Report code statistics (KLOCs, etc)' - task :stats do - require 'rails/code_statistics' - [ - ['App Libraries', 'app/lib'], - %w(Presenters app/presenters), - %w(Policies app/policies), - %w(Serializers app/serializers), - %w(Services app/services), - %w(Validators app/validators), - %w(Workers app/workers), - ].each do |name, dir| - STATS_DIRECTORIES << [name, dir] - end - end -end