Skip to content

Commit

Permalink
Merge pull request #2786 from ClearlyClaire/glitch-soc/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream changes up to 0397df9
  • Loading branch information
ClearlyClaire authored Jul 19, 2024
2 parents 2e63e80 + 95984b7 commit c72b6e0
Show file tree
Hide file tree
Showing 143 changed files with 572 additions and 440 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ gem 'sidekiq-unique-jobs', '~> 7.1'
gem 'simple_form', '~> 5.2'
gem 'simple-navigation', '~> 4.4'
gem 'stoplight', '~> 4.1'
gem 'strong_migrations', '1.8.0'
gem 'strong_migrations'
gem 'tty-prompt', '~> 0.23', require: false
gem 'twitter-text', '~> 3.1.0'
gem 'tzinfo-data', '~> 1.2023'
Expand Down
10 changes: 5 additions & 5 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 @@ -821,8 +821,8 @@ GEM
stoplight (4.1.0)
redlock (~> 1.0)
stringio (3.1.1)
strong_migrations (1.8.0)
activerecord (>= 5.2)
strong_migrations (2.0.0)
activerecord (>= 6.1)
strscan (3.1.0)
swd (1.3.0)
activesupport (>= 3)
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 Expand Up @@ -1046,7 +1046,7 @@ DEPENDENCIES
simplecov-lcov (~> 0.8)
stackprof
stoplight (~> 4.1)
strong_migrations (= 1.8.0)
strong_migrations
test-prof
thor (~> 1.2)
tty-prompt (~> 0.23)
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
30 changes: 15 additions & 15 deletions app/javascript/flavours/glitch/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 'flavours/glitch/api';
import { browserHistory } from 'flavours/glitch/components/router';
import { search as emojiSearch } from 'flavours/glitch/features/emoji/emoji_mart_search_light';
import { tagHistory } from 'flavours/glitch/settings';
import { recoverHashtags } from 'flavours/glitch/utils/hashtag';
Expand Down Expand Up @@ -94,9 +95,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 @@ -117,7 +118,7 @@ export function changeCompose(text) {
};
}

export function replyCompose(status, routerHistory) {
export function replyCompose(status) {
return (dispatch, getState) => {
const prependCWRe = getState().getIn(['local_settings', 'prepend_cw_re']);
dispatch({
Expand All @@ -126,7 +127,7 @@ export function replyCompose(status, routerHistory) {
prependCWRe: prependCWRe,
});

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

Expand All @@ -142,38 +143,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, overridePrivacy = null) {
export function submitCompose(overridePrivacy = null) {
return function (dispatch, getState) {
let status = getState().getIn(['compose', 'text'], '');
const media = getState().getIn(['compose', 'media_attachments']);
Expand Down Expand Up @@ -230,11 +231,10 @@ export function submitCompose(routerHistory, overridePrivacy = null) {
'Idempotency-Key': getState().getIn(['compose', 'idempotencyKey']),
},
}).then(function (response) {
if (routerHistory
&& (routerHistory.location.pathname === '/publish' || routerHistory.location.pathname === '/statuses/new')
if ((browserHistory.location.pathname === '/publish' || browserHistory.location.pathname === '/statuses/new')
&& window.history.state
&& !getState().getIn(['compose', 'advanced_options', 'threaded_mode'])) {
routerHistory.goBack();
browserHistory.goBack();
}

dispatch(insertIntoTagHistory(response.data.tags, status));
Expand Down Expand Up @@ -272,7 +272,7 @@ export function submitCompose(routerHistory, overridePrivacy = null) {
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) {
Expand Down
8 changes: 4 additions & 4 deletions app/javascript/flavours/glitch/actions/statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function redraft(status, raw_text, content_type) {
};
}

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 @@ -105,7 +105,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, response.data.content_type));
}).catch(error => {
dispatch(fetchStatusSourceFail(error));
Expand All @@ -125,7 +125,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 @@ -142,7 +142,7 @@ export function deleteStatus(id, routerHistory, withRedraft = false) {

if (withRedraft) {
dispatch(redraft(status, response.data.text, response.data.content_type));
ensureComposeIsVisible(getState, routerHistory);
ensureComposeIsVisible(getState);
}
}).catch(error => {
dispatch(deleteStatusFail(id, error));
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/flavours/glitch/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/flavours/glitch/components/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class Status extends ImmutablePureComponent {

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

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

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

handleHotkeyOpen = () => {
Expand Down
12 changes: 6 additions & 6 deletions app/javascript/flavours/glitch/components/status_action_bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,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 @@ -145,27 +145,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/flavours/glitch/containers/status_container.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const makeMapStateToProps = () => {

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

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

Expand All @@ -104,11 +104,11 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
message: intl.formatMessage(messages.replyMessage),
confirm: intl.formatMessage(messages.replyConfirm),
onDoNotAsk: () => dispatch(changeLocalSetting(['confirm_before_clearing_draft'], false)),
onConfirm: () => dispatch(replyCompose(status, router)),
onConfirm: () => dispatch(replyCompose(status)),
},
}));
} else {
dispatch(replyCompose(status, router));
dispatch(replyCompose(status));
}
});
},
Expand Down Expand Up @@ -182,22 +182,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 @@ -206,11 +206,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 @@ -223,12 +223,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
Loading

0 comments on commit c72b6e0

Please sign in to comment.