Skip to content

Commit

Permalink
Merge branch 'mastodon:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DismalShadowX authored Jul 19, 2024
2 parents 20db1f2 + 0397df9 commit 4e0228d
Show file tree
Hide file tree
Showing 22 changed files with 101 additions and 116 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ GEM
scenic (1.8.0)
activerecord (>= 4.0.0)
railties (>= 4.0.0)
selenium-webdriver (4.22.0)
selenium-webdriver (4.23.0)
base64 (~> 0.2)
logger (~> 1.4)
rexml (~> 3.2, >= 3.2.5)
Expand Down Expand Up @@ -894,7 +894,7 @@ GEM
railties (>= 5.2)
semantic_range (>= 2.3.0)
webrick (1.8.1)
websocket (1.2.10)
websocket (1.2.11)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down
7 changes: 1 addition & 6 deletions app/controllers/api/v1/admin/domain_allows_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,13 @@ def destroy
private

def set_domain_allows
@domain_allows = filtered_domain_allows.order(id: :desc).to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
@domain_allows = DomainAllow.order(id: :desc).to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
end

def set_domain_allow
@domain_allow = DomainAllow.find(params[:id])
end

def filtered_domain_allows
# TODO: no filtering yet
DomainAllow.all
end

def next_path
api_v1_admin_domain_allows_url(pagination_params(max_id: pagination_max_id)) if records_continue?
end
Expand Down
7 changes: 1 addition & 6 deletions app/controllers/api/v1/admin/domain_blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,13 @@ def conflicts_with_existing_block?(domain_block, existing_domain_block)
end

def set_domain_blocks
@domain_blocks = filtered_domain_blocks.order(id: :desc).to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
@domain_blocks = DomainBlock.order(id: :desc).to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id))
end

def set_domain_block
@domain_block = DomainBlock.find(params[:id])
end

def filtered_domain_blocks
# TODO: no filtering yet
DomainBlock.all
end

def domain_block_params
params.permit(:severity, :reject_media, :reject_reports, :private_comment, :public_comment, :obfuscate)
end
Expand Down
29 changes: 15 additions & 14 deletions app/javascript/mastodon/actions/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import axios from 'axios';
import { throttle } from 'lodash';

import api from 'mastodon/api';
import { browserHistory } from 'mastodon/components/router';
import { search as emojiSearch } from 'mastodon/features/emoji/emoji_mart_search_light';
import { tagHistory } from 'mastodon/settings';

Expand Down Expand Up @@ -88,9 +89,9 @@ const messages = defineMessages({
saved: { id: 'compose.saved.body', defaultMessage: 'Post saved.' },
});

export const ensureComposeIsVisible = (getState, routerHistory) => {
export const ensureComposeIsVisible = (getState) => {
if (!getState().getIn(['compose', 'mounted'])) {
routerHistory.push('/publish');
browserHistory.push('/publish');
}
};

Expand All @@ -110,14 +111,14 @@ export function changeCompose(text) {
};
}

export function replyCompose(status, routerHistory) {
export function replyCompose(status) {
return (dispatch, getState) => {
dispatch({
type: COMPOSE_REPLY,
status: status,
});

ensureComposeIsVisible(getState, routerHistory);
ensureComposeIsVisible(getState);
};
}

Expand All @@ -133,38 +134,38 @@ export function resetCompose() {
};
}

export const focusCompose = (routerHistory, defaultText) => (dispatch, getState) => {
export const focusCompose = (defaultText) => (dispatch, getState) => {
dispatch({
type: COMPOSE_FOCUS,
defaultText,
});

ensureComposeIsVisible(getState, routerHistory);
ensureComposeIsVisible(getState);
};

export function mentionCompose(account, routerHistory) {
export function mentionCompose(account) {
return (dispatch, getState) => {
dispatch({
type: COMPOSE_MENTION,
account: account,
});

ensureComposeIsVisible(getState, routerHistory);
ensureComposeIsVisible(getState);
};
}

export function directCompose(account, routerHistory) {
export function directCompose(account) {
return (dispatch, getState) => {
dispatch({
type: COMPOSE_DIRECT,
account: account,
});

ensureComposeIsVisible(getState, routerHistory);
ensureComposeIsVisible(getState);
};
}

export function submitCompose(routerHistory) {
export function submitCompose() {
return function (dispatch, getState) {
const status = getState().getIn(['compose', 'text'], '');
const media = getState().getIn(['compose', 'media_attachments']);
Expand Down Expand Up @@ -214,8 +215,8 @@ export function submitCompose(routerHistory) {
'Idempotency-Key': getState().getIn(['compose', 'idempotencyKey']),
},
}).then(function (response) {
if (routerHistory && (routerHistory.location.pathname === '/publish' || routerHistory.location.pathname === '/statuses/new') && window.history.state) {
routerHistory.goBack();
if ((browserHistory.location.pathname === '/publish' || browserHistory.location.pathname === '/statuses/new') && window.history.state) {
browserHistory.goBack();
}

dispatch(insertIntoTagHistory(response.data.tags, status));
Expand Down Expand Up @@ -249,7 +250,7 @@ export function submitCompose(routerHistory) {
message: statusId === null ? messages.published : messages.saved,
action: messages.open,
dismissAfter: 10000,
onClick: () => routerHistory.push(`/@${response.data.account.username}/${response.data.id}`),
onClick: () => browserHistory.push(`/@${response.data.account.username}/${response.data.id}`),
}));
}).catch(function (error) {
dispatch(submitComposeFail(error));
Expand Down
8 changes: 4 additions & 4 deletions app/javascript/mastodon/actions/statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function redraft(status, raw_text) {
};
}

export const editStatus = (id, routerHistory) => (dispatch, getState) => {
export const editStatus = (id) => (dispatch, getState) => {
let status = getState().getIn(['statuses', id]);

if (status.get('poll')) {
Expand All @@ -104,7 +104,7 @@ export const editStatus = (id, routerHistory) => (dispatch, getState) => {

api().get(`/api/v1/statuses/${id}/source`).then(response => {
dispatch(fetchStatusSourceSuccess());
ensureComposeIsVisible(getState, routerHistory);
ensureComposeIsVisible(getState);
dispatch(setComposeToStatus(status, response.data.text, response.data.spoiler_text));
}).catch(error => {
dispatch(fetchStatusSourceFail(error));
Expand All @@ -124,7 +124,7 @@ export const fetchStatusSourceFail = error => ({
error,
});

export function deleteStatus(id, routerHistory, withRedraft = false) {
export function deleteStatus(id, withRedraft = false) {
return (dispatch, getState) => {
let status = getState().getIn(['statuses', id]);

Expand All @@ -141,7 +141,7 @@ export function deleteStatus(id, routerHistory, withRedraft = false) {

if (withRedraft) {
dispatch(redraft(status, response.data.text));
ensureComposeIsVisible(getState, routerHistory);
ensureComposeIsVisible(getState);
}
}).catch(error => {
dispatch(deleteStatusFail(id, error));
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/components/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type LocationState = MastodonLocationState | null | undefined;

type HistoryPath = Path | LocationDescriptor<LocationState>;

const browserHistory = createBrowserHistory<LocationState>();
export const browserHistory = createBrowserHistory<LocationState>();
const originalPush = browserHistory.push.bind(browserHistory);
const originalReplace = browserHistory.replace.bind(browserHistory);

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/components/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class Status extends ImmutablePureComponent {

handleHotkeyReply = e => {
e.preventDefault();
this.props.onReply(this._properStatus(), this.props.history);
this.props.onReply(this._properStatus());
};

handleHotkeyFavourite = () => {
Expand All @@ -281,7 +281,7 @@ class Status extends ImmutablePureComponent {

handleHotkeyMention = e => {
e.preventDefault();
this.props.onMention(this._properStatus().get('account'), this.props.history);
this.props.onMention(this._properStatus().get('account'));
};

handleHotkeyOpen = () => {
Expand Down
12 changes: 6 additions & 6 deletions app/javascript/mastodon/components/status_action_bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class StatusActionBar extends ImmutablePureComponent {
const { signedIn } = this.props.identity;

if (signedIn) {
this.props.onReply(this.props.status, this.props.history);
this.props.onReply(this.props.status);
} else {
this.props.onInteractionModal('reply', this.props.status);
}
Expand Down Expand Up @@ -157,27 +157,27 @@ class StatusActionBar extends ImmutablePureComponent {
};

handleDeleteClick = () => {
this.props.onDelete(this.props.status, this.props.history);
this.props.onDelete(this.props.status);
};

handleRedraftClick = () => {
this.props.onDelete(this.props.status, this.props.history, true);
this.props.onDelete(this.props.status, true);
};

handleEditClick = () => {
this.props.onEdit(this.props.status, this.props.history);
this.props.onEdit(this.props.status);
};

handlePinClick = () => {
this.props.onPin(this.props.status);
};

handleMentionClick = () => {
this.props.onMention(this.props.status.get('account'), this.props.history);
this.props.onMention(this.props.status.get('account'));
};

handleDirectClick = () => {
this.props.onDirect(this.props.status.get('account'), this.props.history);
this.props.onDirect(this.props.status.get('account'));
};

handleMuteClick = () => {
Expand Down
26 changes: 13 additions & 13 deletions app/javascript/mastodon/containers/status_container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const makeMapStateToProps = () => {

const mapDispatchToProps = (dispatch, { intl, contextType }) => ({

onReply (status, router) {
onReply (status) {
dispatch((_, getState) => {
let state = getState();

Expand All @@ -86,10 +86,10 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
modalProps: {
message: intl.formatMessage(messages.replyMessage),
confirm: intl.formatMessage(messages.replyConfirm),
onConfirm: () => dispatch(replyCompose(status, router)) },
onConfirm: () => dispatch(replyCompose(status)) },
}));
} else {
dispatch(replyCompose(status, router));
dispatch(replyCompose(status));
}
});
},
Expand Down Expand Up @@ -144,22 +144,22 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
}));
},

onDelete (status, history, withRedraft = false) {
onDelete (status, withRedraft = false) {
if (!deleteModal) {
dispatch(deleteStatus(status.get('id'), history, withRedraft));
dispatch(deleteStatus(status.get('id'), withRedraft));
} else {
dispatch(openModal({
modalType: 'CONFIRM',
modalProps: {
message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage),
confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm),
onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)),
onConfirm: () => dispatch(deleteStatus(status.get('id'), withRedraft)),
},
}));
}
},

onEdit (status, history) {
onEdit (status) {
dispatch((_, getState) => {
let state = getState();
if (state.getIn(['compose', 'text']).trim().length !== 0) {
Expand All @@ -168,11 +168,11 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
modalProps: {
message: intl.formatMessage(messages.editMessage),
confirm: intl.formatMessage(messages.editConfirm),
onConfirm: () => dispatch(editStatus(status.get('id'), history)),
onConfirm: () => dispatch(editStatus(status.get('id'))),
},
}));
} else {
dispatch(editStatus(status.get('id'), history));
dispatch(editStatus(status.get('id')));
}
});
},
Expand All @@ -185,12 +185,12 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
}
},

onDirect (account, router) {
dispatch(directCompose(account, router));
onDirect (account) {
dispatch(directCompose(account));
},

onMention (account, router) {
dispatch(mentionCompose(account, router));
onMention (account) {
dispatch(mentionCompose(account));
},

onOpenMedia (statusId, media, index, lang) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import PropTypes from 'prop-types';

import { FormattedMessage } from 'react-intl';

import { NavLink, withRouter } from 'react-router-dom';
import { NavLink } from 'react-router-dom';

import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';

import { WithRouterPropTypes } from 'mastodon/utils/react_router';

import InnerHeader from '../../account/components/header';

import MemorialNote from './memorial_note';
Expand Down Expand Up @@ -36,7 +34,6 @@ class Header extends ImmutablePureComponent {
hideTabs: PropTypes.bool,
domain: PropTypes.string.isRequired,
hidden: PropTypes.bool,
...WithRouterPropTypes,
};

handleFollow = () => {
Expand All @@ -48,11 +45,11 @@ class Header extends ImmutablePureComponent {
};

handleMention = () => {
this.props.onMention(this.props.account, this.props.history);
this.props.onMention(this.props.account);
};

handleDirect = () => {
this.props.onDirect(this.props.account, this.props.history);
this.props.onDirect(this.props.account);
};

handleReport = () => {
Expand Down Expand Up @@ -155,4 +152,4 @@ class Header extends ImmutablePureComponent {

}

export default withRouter(Header);
export default Header;
Loading

0 comments on commit 4e0228d

Please sign in to comment.