Skip to content

Commit

Permalink
Merge commit '23e32a4b3031d1da8b911e0145d61b4dd47c4f96' into glitch-s…
Browse files Browse the repository at this point in the history
…oc/merge-upstream

Conflicts:
- `Gemfile.lock`:
  Conflict because we had updated the `json-ld` gem to fix a yanked dependency.
  Kept our version of `json-ld` while updating other dependencies.
  • Loading branch information
ClearlyClaire committed Dec 18, 2023
2 parents 3d3fa75 + 23e32a4 commit bc33be0
Show file tree
Hide file tree
Showing 45 changed files with 788 additions and 1,060 deletions.
1 change: 0 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ RSpec/AnyInstance:
- 'spec/controllers/activitypub/inboxes_controller_spec.rb'
- 'spec/controllers/admin/accounts_controller_spec.rb'
- 'spec/controllers/admin/resets_controller_spec.rb'
- 'spec/controllers/admin/settings/branding_controller_spec.rb'
- 'spec/controllers/auth/sessions_controller_spec.rb'
- 'spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb'
- 'spec/controllers/settings/two_factor_authentication/recovery_codes_controller_spec.rb'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ gem 'simple-navigation', '~> 4.4'
gem 'simple_form', '~> 5.2'
gem 'sprockets-rails', '~> 3.4', require: 'sprockets/railtie'
gem 'stoplight', '~> 3.0.1'
gem 'strong_migrations', '1.3.0'
gem 'strong_migrations', '1.6.4'
gem 'tty-prompt', '~> 0.23', require: false
gem 'twitter-text', '~> 3.1.0'
gem 'tzinfo-data', '~> 1.2023'
Expand Down Expand Up @@ -195,7 +195,7 @@ gem 'xorcist', '~> 1.1'

gem 'cocoon', '~> 1.2'

gem 'net-http', '~> 0.3.2'
gem 'net-http', '~> 0.4.0'
gem 'rubyzip', '~> 2.3'

gem 'hcaptcha', '~> 7.1'
34 changes: 17 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ GEM
attr_required (1.0.1)
awrence (1.2.1)
aws-eventstream (1.2.0)
aws-partitions (1.809.0)
aws-sdk-core (3.181.0)
aws-partitions (1.828.0)
aws-sdk-core (3.183.1)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.71.0)
aws-sdk-core (~> 3, >= 3.177.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.133.0)
aws-sdk-s3 (1.136.0)
aws-sdk-core (~> 3, >= 3.181.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.6)
Expand Down Expand Up @@ -389,10 +389,10 @@ GEM
multi_json (~> 1.15)
rack (>= 2.2, < 4)
rdf (~> 3.3)
json-ld-preloaded (3.2.2)
json-ld (~> 3.2)
rdf (~> 3.2)
json-schema (4.0.0)
json-ld-preloaded (3.3.0)
json-ld (~> 3.3)
rdf (~> 3.3)
json-schema (4.1.1)
addressable (>= 2.8)
jsonapi-renderer (0.2.2)
jwt (2.7.1)
Expand Down Expand Up @@ -454,13 +454,13 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2023.0808)
mini_mime (1.1.5)
mini_portile2 (2.8.4)
mini_portile2 (2.8.5)
minitest (5.20.0)
msgpack (1.7.2)
multi_json (1.15.0)
multipart-post (2.3.0)
mutex_m (0.1.2)
net-http (0.3.2)
net-http (0.4.0)
uri
net-http-persistent (4.0.2)
connection_pool (~> 2.2)
Expand Down Expand Up @@ -689,13 +689,13 @@ GEM
fugit (~> 1.1, >= 1.1.6)
safety_net_attestation (0.4.0)
jwt (~> 2.0)
sanitize (6.0.2)
sanitize (6.1.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
scenic (1.7.0)
activerecord (>= 4.0.0)
railties (>= 4.0.0)
selenium-webdriver (4.13.1)
selenium-webdriver (4.15.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
Expand All @@ -710,15 +710,15 @@ GEM
rufus-scheduler (~> 3.2)
sidekiq (>= 6, < 8)
tilt (>= 1.4.0)
sidekiq-unique-jobs (7.1.29)
sidekiq-unique-jobs (7.1.30)
brpoplpush-redis_script (> 0.1.1, <= 2.0.0)
concurrent-ruby (~> 1.0, >= 1.0.5)
redis (< 5.0)
sidekiq (>= 5.0, < 7.0)
thor (>= 0.20, < 3.0)
simple-navigation (4.4.0)
activesupport (>= 2.3.2)
simple_form (5.2.0)
simple_form (5.3.0)
actionpack (>= 5.2)
activemodel (>= 5.2)
simplecov (0.22.0)
Expand All @@ -740,7 +740,7 @@ GEM
stoplight (3.0.2)
redlock (~> 1.0)
stringio (3.0.8)
strong_migrations (1.3.0)
strong_migrations (1.6.4)
activerecord (>= 5.2)
swd (1.3.0)
activesupport (>= 3)
Expand All @@ -753,7 +753,7 @@ GEM
terrapin (0.6.0)
climate_control (>= 0.0.3, < 1.0)
test-prof (1.2.3)
thor (1.2.2)
thor (1.3.0)
tilt (2.3.0)
timeout (0.4.0)
tpm-key_attestation (0.12.0)
Expand Down Expand Up @@ -883,7 +883,7 @@ DEPENDENCIES
md-paperclip-azure (~> 2.2)
memory_profiler
mime-types (~> 3.5.0)
net-http (~> 0.3.2)
net-http (~> 0.4.0)
net-ldap (~> 0.18)
nokogiri (~> 1.15)
nsa!
Expand Down Expand Up @@ -941,7 +941,7 @@ DEPENDENCIES
sprockets-rails (~> 3.4)
stackprof
stoplight (~> 3.0.1)
strong_migrations (= 1.3.0)
strong_migrations (= 1.6.4)
test-prof
thor (~> 1.2)
tty-prompt (~> 0.23)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/admin/account_moderation_notes_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def admin_account_link_to(account, path: nil)

link_to path || admin_account_path(account.id), class: name_tag_classes(account), title: account.acct do
safe_join([
image_tag(account.avatar.url, width: 15, height: 15, alt: display_name(account), class: 'avatar'),
image_tag(account.avatar.url, width: 15, height: 15, alt: '', class: 'avatar'),
content_tag(:span, account.acct, class: 'username'),
], ' ')
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/settings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def compact_account_link_to(account)
return if account.nil?

link_to ActivityPub::TagManager.instance.url_for(account), class: 'name-tag', title: account.acct do
safe_join([image_tag(account.avatar.url, width: 15, height: 15, alt: display_name(account), class: 'avatar'), content_tag(:span, account.acct, class: 'username')], ' ')
safe_join([image_tag(account.avatar.url, width: 15, height: 15, alt: '', class: 'avatar'), content_tag(:span, account.acct, class: 'username')], ' ')
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports[`<Avatar /> Autoplay renders a animated avatar 1`] = `
}
>
<img
alt="alice"
alt=""
src="/animated/alice.gif"
/>
</div>
Expand All @@ -32,7 +32,7 @@ exports[`<Avatar /> Still renders a still avatar 1`] = `
}
>
<img
alt="alice"
alt=""
src="/static/alice.jpg"
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/components/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const Avatar: React.FC<Props> = ({
onMouseLeave={handleMouseLeave}
style={style}
>
{src && <img src={src} alt={account?.get('acct')} />}
{src && <img src={src} alt='' />}
</div>
);
};
80 changes: 80 additions & 0 deletions app/javascript/mastodon/features/__tests__/toggle-play.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';

import { render, fireEvent } from '@testing-library/react';

class Media extends Component {

constructor(props) {
super(props);

this.state = {
paused: props.paused || false,
};
}

handleMediaClick = () => {
const { onClick } = this.props;

this.setState(prevState => ({
paused: !prevState.paused,
}));

if (typeof onClick === 'function') {
onClick();
}

const { title } = this.props;
const mediaElements = document.querySelectorAll(`div[title="${title}"]`);

setTimeout(() => {
mediaElements.forEach(element => {
if (element !== this && !element.classList.contains('paused')) {
element.click();
}
});
}, 0);
};

render() {
const { title } = this.props;
const { paused } = this.state;

return (
<button title={title} onClick={this.handleMediaClick}>
Media Component - {paused ? 'Paused' : 'Playing'}
</button>
);
}

}

Media.propTypes = {
title: PropTypes.string.isRequired,
onClick: PropTypes.func,
paused: PropTypes.bool,
};

describe('Media attachments test', () => {
let currentMedia = null;
const togglePlayMock = jest.fn();

it('plays a new media file and pauses others that were playing', () => {
const container = render(
<div>
<Media title='firstMedia' paused onClick={togglePlayMock} />
<Media title='secondMedia' paused onClick={togglePlayMock} />
</div>,
);

fireEvent.click(container.getByTitle('firstMedia'));
expect(togglePlayMock).toHaveBeenCalledTimes(1);
currentMedia = container.getByTitle('firstMedia');
expect(currentMedia.textContent).toMatch(/Playing/);

fireEvent.click(container.getByTitle('secondMedia'));
expect(togglePlayMock).toHaveBeenCalledTimes(2);
currentMedia = container.getByTitle('secondMedia');
expect(currentMedia.textContent).toMatch(/Playing/);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
modalType: 'IMAGE',
modalProps: {
src: account.get('avatar'),
alt: account.get('acct'),
alt: '',
},
}));
},
Expand Down
33 changes: 26 additions & 7 deletions app/javascript/mastodon/features/audio/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { formatTime, getPointerPosition, fileNameFromURL } from 'mastodon/featur

import { Blurhash } from '../../components/blurhash';
import { displayMedia, useBlurhash } from '../../initial_state';
import { currentMedia, setCurrentMedia } from '../../reducers/media_attachments';

import Visualizer from './visualizer';

Expand Down Expand Up @@ -165,15 +166,32 @@ class Audio extends PureComponent {
}

togglePlay = () => {
if (!this.audioContext) {
this._initAudioContext();
}
const audios = document.querySelectorAll('audio');

audios.forEach((audio) => {
const button = audio.previousElementSibling;
button.addEventListener('click', () => {
if(audio.paused) {
audios.forEach((e) => {
if (e !== audio) {
e.pause();
}
});
audio.play();
this.setState({ paused: false });
} else {
audio.pause();
this.setState({ paused: true });
}
});
});

if (this.state.paused) {
this.setState({ paused: false }, () => this.audio.play());
} else {
this.setState({ paused: true }, () => this.audio.pause());
if (currentMedia !== null) {
currentMedia.pause();
}

this.audio.play();
setCurrentMedia(this.audio);
};

handleResize = debounce(() => {
Expand All @@ -195,6 +213,7 @@ class Audio extends PureComponent {
};

handlePause = () => {
this.audio.pause();
this.setState({ paused: true });

if (this.audioContext) {
Expand Down
Loading

0 comments on commit bc33be0

Please sign in to comment.