From 02fe176fd4bc095cd6819606cc310cc8bc234e91 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 3 Jan 2025 22:51:51 +0100 Subject: [PATCH 1/6] Fix audio player modal having white-on-white buttons in light theme (#33444) --- .../mastodon/features/ui/components/audio_modal.jsx | 13 +++++++++++++ .../mastodon/features/ui/components/video_modal.jsx | 4 ++++ 2 files changed, 17 insertions(+) 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 || {}; From af7d6e59af48bc66ead7d3c04f935d7c8cabef7b Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 3 Jan 2025 16:52:16 -0500 Subject: [PATCH 2/6] Replace deprecated `STATS_DIRECTORIES` with `Rails::CodeStatistics.register_directory` approach (#33445) --- config/initializers/statistics.rb | 13 +++++++++++++ lib/tasks/statistics.rake | 21 --------------------- 2 files changed, 13 insertions(+), 21 deletions(-) create mode 100644 config/initializers/statistics.rb delete mode 100644 lib/tasks/statistics.rake diff --git a/config/initializers/statistics.rb b/config/initializers/statistics.rb new file mode 100644 index 0000000000..a266607445 --- /dev/null +++ b/config/initializers/statistics.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +[ + %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 From 9712518b2fb2585df3bcff95a687c291f04a4199 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 3 Jan 2025 23:00:52 +0100 Subject: [PATCH 3/6] Refactor status `handleClick` and `handleHotkeyOpen` handlers (#33435) --- app/javascript/mastodon/components/status.jsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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); From d878ca267c2790537ebe4c3502f98b02aa3b90e6 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 3 Jan 2025 22:51:51 +0100 Subject: [PATCH 4/6] [Glitch] Fix audio player modal having white-on-white buttons in light theme Port 02fe176fd4bc095cd6819606cc310cc8bc234e91 to glitch-soc Signed-off-by: Claire --- .../glitch/features/ui/components/audio_modal.jsx | 13 +++++++++++++ .../glitch/features/ui/components/video_modal.jsx | 4 ++++ 2 files changed, 17 insertions(+) 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 || {}; From 0327db3db0483ce055192c374d6a077522aff7a1 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 3 Jan 2025 23:00:52 +0100 Subject: [PATCH 5/6] [Glitch] Refactor status `handleClick` and `handleHotkeyOpen` handlers Port 9712518b2fb2585df3bcff95a687c291f04a4199 to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/components/status.jsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/javascript/flavours/glitch/components/status.jsx b/app/javascript/flavours/glitch/components/status.jsx index b38fac46fb..b220460ef1 100644 --- a/app/javascript/flavours/glitch/components/status.jsx +++ b/app/javascript/flavours/glitch/components/status.jsx @@ -272,7 +272,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 => { @@ -349,7 +354,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; @@ -364,7 +373,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); From 9b82bedc6f589b19c1cf9dc8f566f4c19702d965 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sat, 4 Jan 2025 12:44:49 -0500 Subject: [PATCH 6/6] Only register stats dirs when command available (#33454) --- config/initializers/statistics.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/initializers/statistics.rb b/config/initializers/statistics.rb index a266607445..9b35ac96c4 100644 --- a/config/initializers/statistics.rb +++ b/config/initializers/statistics.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +return unless defined?(Rails::Command::StatsCommand) + [ %w(AppLibs app/lib), %w(Policies app/policies),