Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mention booster when replying to a boosted post #2334

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/javascript/flavours/glitch/actions/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ export function cycleElefriendCompose() {
};
}

export function replyCompose(status, routerHistory) {
export function replyCompose(status, routerHistory, statusRebloggedBy) {
return (dispatch, getState) => {
const prependCWRe = getState().getIn(['local_settings', 'prepend_cw_re']);
const mentionReblogger = getState().getIn(['local_settings', 'mention_reblogger']);
dispatch({
type: COMPOSE_REPLY,
status: status,
statusRebloggedBy: mentionReblogger ? statusRebloggedBy : undefined,
prependCWRe: prependCWRe,
});

Expand Down
14 changes: 11 additions & 3 deletions app/javascript/flavours/glitch/containers/status_container.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,16 @@ const makeMapStateToProps = () => {
return mapStateToProps;
};

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

onReply (status, router) {
const getStatus = makeGetStatus();

dispatch((_, getState) => {
const { intl } = ownProps;
let state = getState();
const statusFromState = getStatus(state, ownProps);
const rebloggedBy = statusFromState.get('reblog') ? statusFromState.get('account') : undefined;

if (state.getIn(['local_settings', 'confirm_before_clearing_draft']) && state.getIn(['compose', 'text']).trim().length !== 0) {
dispatch(openModal({
Expand All @@ -105,11 +110,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, router, rebloggedBy)),
},
}));
} else {
dispatch(replyCompose(status, router));
dispatch(replyCompose(status, router, rebloggedBy));
}
});
},
Expand Down Expand Up @@ -184,6 +189,7 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
},

onDelete (status, history, withRedraft = false) {
const { intl } = ownProps;
if (!deleteModal) {
dispatch(deleteStatus(status.get('id'), history, withRedraft));
} else {
Expand All @@ -199,6 +205,7 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
},

onEdit (status, history) {
const { intl } = ownProps;
dispatch((_, getState) => {
let state = getState();
if (state.getIn(['compose', 'text']).trim().length !== 0) {
Expand Down Expand Up @@ -256,6 +263,7 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
},

onAddFilter (status) {
const { contextType } = ownProps;
dispatch(initAddFilter(status, { contextType }));
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ class LocalSettingsPage extends PureComponent {
>
<FormattedMessage id='settings.always_show_spoilers_field' defaultMessage='Always enable the Content Warning field' />
</LocalSettingsPageItem>
<LocalSettingsPageItem
settings={settings}
item={['mention_reblogger']}
id='mastodon-settings--mention_reblogger'
onChange={onChange}
>
<FormattedMessage id='settings.mention_reblogger' defaultMessage='Mention booster when replying to a boosted post' />
</LocalSettingsPageItem>
<LocalSettingsPageItem
settings={settings}
item={['prepend_cw_re']}
Expand Down
1 change: 1 addition & 0 deletions app/javascript/flavours/glitch/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
"settings.pop_in_position": "Pop-in player position:",
"settings.pop_in_right": "Right",
"settings.preferences": "User preferences",
"settings.mention_reblogger": "Mention booster when replying to a boosted post",
"settings.prepend_cw_re": "Prepend “re: ” to content warnings when replying",
"settings.preselect_on_reply": "Pre-select usernames on reply",
"settings.preselect_on_reply_hint": "When replying to a conversation with multiple participants, pre-select usernames past the first",
Expand Down
7 changes: 5 additions & 2 deletions app/javascript/flavours/glitch/reducers/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,15 @@ const initialPoll = ImmutableMap({
multiple: false,
});

function statusToTextMentions(state, status) {
function statusToTextMentions(state, status, statusRebloggedBy) {
let set = ImmutableOrderedSet([]);

if (status.getIn(['account', 'id']) !== me) {
set = set.add(`@${status.getIn(['account', 'acct'])} `);
}
if (statusRebloggedBy) {
set = set.add(`@${statusRebloggedBy.get('acct')}`);
}

return set.union(status.get('mentions').filterNot(mention => mention.get('id') === me).map(mention => `@${mention.get('acct')} `)).join('');
}
Expand Down Expand Up @@ -415,7 +418,7 @@ export default function compose(state = initialState, action) {
return state.withMutations(map => {
map.set('id', null);
map.set('in_reply_to', action.status.get('id'));
map.set('text', statusToTextMentions(state, action.status));
map.set('text', statusToTextMentions(state, action.status, action.statusRebloggedBy));
map.set('privacy', privacyPreference(action.status.get('visibility'), state.get('default_privacy')));
map.update(
'advanced_options',
Expand Down
1 change: 1 addition & 0 deletions app/javascript/flavours/glitch/reducers/local_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const initialState = ImmutableMap({
confirm_missing_media_description: false,
confirm_boost_missing_media_description: false,
confirm_before_clearing_draft: true,
mention_reblogger: false,
prepend_cw_re: true,
preselect_on_reply: true,
inline_preview_cards: true,
Expand Down