Skip to content

Commit

Permalink
Merge commit 'b7bdcd4f395aaa1e85930940975439d10b570f40' into glitch-s…
Browse files Browse the repository at this point in the history
…oc/merge-upstream
  • Loading branch information
ClearlyClaire committed Dec 21, 2023
2 parents 30ee733 + b7bdcd4 commit 92aa6e2
Show file tree
Hide file tree
Showing 25 changed files with 2,980 additions and 226 deletions.
8 changes: 8 additions & 0 deletions app/controllers/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def require_not_suspended!
render json: { error: 'Your login is currently disabled' }, status: 403 if current_user&.account&.unavailable?
end

def require_valid_pagination_options!
render json: { error: 'Pagination values for `offset` and `limit` must be positive' }, status: 400 if pagination_options_invalid?
end

def require_user!
if !current_user
render json: { error: 'This method requires an authenticated user' }, status: 422
Expand Down Expand Up @@ -136,6 +140,10 @@ def disallow_unauthenticated_api_access?

private

def pagination_options_invalid?
params.slice(:limit, :offset).values.map(&:to_i).any?(&:negative?)
end

def respond_with_error(code)
render json: { error: Rack::Utils::HTTP_STATUS_CODES[code] }, status: code
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/api/v2/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Api::V2::SearchController < Api::BaseController
before_action :query_pagination_error, if: :pagination_requested?
before_action :remote_resolve_error, if: :remote_resolve_requested?
end
before_action :require_valid_pagination_options!

def index
@search = Search.new(search_results)
Expand Down
30 changes: 15 additions & 15 deletions app/javascript/mastodon/actions/accounts_typed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ function actionWithSkipLoadingTrue<Args extends object>(args: Args) {
}

export const followAccountSuccess = createAction(
'accounts/followAccountSuccess',
'accounts/followAccount/SUCCESS',
actionWithSkipLoadingTrue<{
relationship: ApiRelationshipJSON;
alreadyFollowing: boolean;
}>,
);

export const unfollowAccountSuccess = createAction(
'accounts/unfollowAccountSuccess',
'accounts/unfollowAccount/SUCCESS',
actionWithSkipLoadingTrue<{
relationship: ApiRelationshipJSON;
statuses: unknown;
Expand All @@ -38,60 +38,60 @@ export const unfollowAccountSuccess = createAction(
);

export const authorizeFollowRequestSuccess = createAction<{ id: string }>(
'accounts/followRequestAuthorizeSuccess',
'accounts/followRequestAuthorize/SUCCESS',
);

export const rejectFollowRequestSuccess = createAction<{ id: string }>(
'accounts/followRequestRejectSuccess',
'accounts/followRequestReject/SUCCESS',
);

export const followAccountRequest = createAction(
'accounts/followRequest',
'accounts/follow/REQUEST',
actionWithSkipLoadingTrue<{ id: string; locked: boolean }>,
);

export const followAccountFail = createAction(
'accounts/followFail',
'accounts/follow/FAIL',
actionWithSkipLoadingTrue<{ id: string; error: string; locked: boolean }>,
);

export const unfollowAccountRequest = createAction(
'accounts/unfollowRequest',
'accounts/unfollow/REQUEST',
actionWithSkipLoadingTrue<{ id: string }>,
);

export const unfollowAccountFail = createAction(
'accounts/unfollowFail',
'accounts/unfollow/FAIL',
actionWithSkipLoadingTrue<{ id: string; error: string }>,
);

export const blockAccountSuccess = createAction<{
relationship: ApiRelationshipJSON;
statuses: unknown;
}>('accounts/blockSuccess');
}>('accounts/block/SUCCESS');

export const unblockAccountSuccess = createAction<{
relationship: ApiRelationshipJSON;
}>('accounts/unblockSuccess');
}>('accounts/unblock/SUCCESS');

export const muteAccountSuccess = createAction<{
relationship: ApiRelationshipJSON;
statuses: unknown;
}>('accounts/muteSuccess');
}>('accounts/mute/SUCCESS');

export const unmuteAccountSuccess = createAction<{
relationship: ApiRelationshipJSON;
}>('accounts/unmuteSuccess');
}>('accounts/unmute/SUCCESS');

export const pinAccountSuccess = createAction<{
relationship: ApiRelationshipJSON;
}>('accounts/pinSuccess');
}>('accounts/pin/SUCCESS');

export const unpinAccountSuccess = createAction<{
relationship: ApiRelationshipJSON;
}>('accounts/unpinSuccess');
}>('accounts/unpin/SUCCESS');

export const fetchRelationshipsSuccess = createAction(
'relationships/fetchSuccess',
'relationships/fetch/SUCCESS',
actionWithSkipLoadingTrue<{ relationships: ApiRelationshipJSON[] }>,
);
4 changes: 2 additions & 2 deletions app/javascript/mastodon/actions/domain_blocks_typed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import type { Account } from 'mastodon/models/account';
export const blockDomainSuccess = createAction<{
domain: string;
accounts: Account[];
}>('domain_blocks/blockSuccess');
}>('domain_blocks/block/SUCCESS');

export const unblockDomainSuccess = createAction<{
domain: string;
accounts: Account[];
}>('domain_blocks/unblockSuccess');
}>('domain_blocks/unblock/SUCCESS');
2 changes: 1 addition & 1 deletion app/javascript/mastodon/components/dropdown_menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class Dropdown extends PureComponent {
};

findTarget = () => {
return this.target?.buttonRef?.current;
return this.target?.buttonRef?.current ?? this.target;
};

componentWillUnmount = () => {
Expand Down
80 changes: 0 additions & 80 deletions app/javascript/mastodon/features/__tests__/toggle-play.jsx

This file was deleted.

33 changes: 7 additions & 26 deletions app/javascript/mastodon/features/audio/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ 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 @@ -166,32 +165,15 @@ class Audio extends PureComponent {
}

togglePlay = () => {
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 (currentMedia !== null) {
currentMedia.pause();
if (!this.audioContext) {
this._initAudioContext();
}

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

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

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

if (this.audioContext) {
Expand Down
31 changes: 4 additions & 27 deletions app/javascript/mastodon/features/video/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { Icon } from 'mastodon/components/icon';
import { playerSettings } from 'mastodon/settings';

import { displayMedia, useBlurhash } from '../../initial_state';
import { currentMedia, setCurrentMedia } from '../../reducers/media_attachments';
import { isFullscreen, requestFullscreen, exitFullscreen } from '../ui/util/fullscreen';

const messages = defineMessages({
Expand Down Expand Up @@ -182,7 +181,6 @@ class Video extends PureComponent {
};

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

Expand Down Expand Up @@ -346,32 +344,11 @@ class Video extends PureComponent {
};

togglePlay = () => {
const videos = document.querySelectorAll('video');

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

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

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

toggleFullscreen = () => {
Expand Down
Loading

0 comments on commit 92aa6e2

Please sign in to comment.