kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Mention repost author when replying to a reposted status
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>mention-reblog-author
rodzic
5d5a29b9f0
commit
b7fcbd9e16
|
@ -121,7 +121,7 @@ const changeCompose = (composeId: string, text: string) => ({
|
|||
text: text,
|
||||
});
|
||||
|
||||
const replyCompose = (status: Status) =>
|
||||
const replyCompose = (status: Status, rebloggedBy?: Account) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const state = getState();
|
||||
const instance = state.instance;
|
||||
|
@ -133,6 +133,7 @@ const replyCompose = (status: Status) =>
|
|||
status: status,
|
||||
account: state.accounts.get(state.me),
|
||||
explicitAddressing,
|
||||
rebloggedBy,
|
||||
});
|
||||
|
||||
dispatch(openModal('COMPOSE'));
|
||||
|
|
|
@ -82,6 +82,7 @@ const messages = defineMessages({
|
|||
|
||||
interface IStatusActionBar {
|
||||
status: Status,
|
||||
rebloggedBy?: Account,
|
||||
withDismiss?: boolean,
|
||||
withLabels?: boolean,
|
||||
expandable?: boolean,
|
||||
|
@ -94,6 +95,7 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
|||
withLabels = false,
|
||||
expandable = true,
|
||||
space = 'compact',
|
||||
rebloggedBy,
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
const history = useHistory();
|
||||
|
@ -123,7 +125,7 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
|||
|
||||
const handleReplyClick: React.MouseEventHandler = (e) => {
|
||||
if (me) {
|
||||
dispatch(replyCompose(status));
|
||||
dispatch(replyCompose(status, rebloggedBy));
|
||||
} else {
|
||||
onOpenUnauthorizedModal('REPLY');
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ const Status: React.FC<IStatus> = (props) => {
|
|||
|
||||
const handleHotkeyReply = (e?: KeyboardEvent): void => {
|
||||
e?.preventDefault();
|
||||
dispatch(replyCompose(actualStatus));
|
||||
dispatch(replyCompose(status, status.reblog && typeof status.reblog === 'object' ? status.account as AccountEntity : undefined));
|
||||
};
|
||||
|
||||
const handleHotkeyFavourite = (): void => {
|
||||
|
@ -190,7 +190,7 @@ const Status: React.FC<IStatus> = (props) => {
|
|||
};
|
||||
|
||||
if (!status) return null;
|
||||
let rebloggedByText, reblogElement, reblogElementMobile;
|
||||
let rebloggedBy, rebloggedByText, reblogElement, reblogElementMobile;
|
||||
|
||||
if (hidden) {
|
||||
return (
|
||||
|
@ -269,6 +269,8 @@ const Status: React.FC<IStatus> = (props) => {
|
|||
messages.reblogged_by,
|
||||
{ name: String(status.getIn(['account', 'acct'])) },
|
||||
);
|
||||
|
||||
rebloggedBy = status.account;
|
||||
}
|
||||
|
||||
let quote;
|
||||
|
@ -400,7 +402,7 @@ const Status: React.FC<IStatus> = (props) => {
|
|||
|
||||
{(!hideActionBar && !isUnderReview) && (
|
||||
<div className='pt-4'>
|
||||
<StatusActionBar status={actualStatus} withDismiss={withDismiss} />
|
||||
<StatusActionBar status={actualStatus} rebloggedBy={rebloggedBy as AccountEntity | undefined} withDismiss={withDismiss} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -41,7 +41,7 @@ const ReplyMentions: React.FC<IReplyMentions> = ({ composeId }) => {
|
|||
}));
|
||||
};
|
||||
|
||||
if (!parentTo || (parentTo.size === 0)) {
|
||||
if (!compose.parent_reblogged_by && (!parentTo || (parentTo.size === 0))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ const ReplyMentionsModal: React.FC<IReplyMentionsModal> = ({ composeId, onClose
|
|||
const status = useAppSelector<StatusEntity | null>(state => getStatus(state, { id: compose.in_reply_to! }));
|
||||
const account = useAppSelector((state) => state.accounts.get(state.me));
|
||||
|
||||
const mentions = statusToMentionsAccountIdsArray(status!, account!);
|
||||
const mentions = statusToMentionsAccountIdsArray(status!, account!, compose.parent_reblogged_by);
|
||||
const author = (status?.account as AccountEntity).id;
|
||||
|
||||
const onClickClose = () => {
|
||||
|
|
|
@ -99,6 +99,7 @@ export const ReducerCompose = ImmutableRecord({
|
|||
tagHistory: ImmutableList<string>(),
|
||||
text: '',
|
||||
to: ImmutableOrderedSet<string>(),
|
||||
parent_reblogged_by: null as string | null,
|
||||
});
|
||||
|
||||
type State = ImmutableMap<string, Compose>;
|
||||
|
@ -116,20 +117,22 @@ const statusToTextMentions = (status: ImmutableMap<string, any>, account: Accoun
|
|||
.join('');
|
||||
};
|
||||
|
||||
export const statusToMentionsArray = (status: ImmutableMap<string, any>, account: AccountEntity) => {
|
||||
export const statusToMentionsArray = (status: ImmutableMap<string, any>, account: AccountEntity, rebloggedBy?: AccountEntity) => {
|
||||
const author = status.getIn(['account', 'acct']) as string;
|
||||
const mentions = status.get('mentions')?.map((m: ImmutableMap<string, any>) => m.get('acct')) || [];
|
||||
|
||||
return ImmutableOrderedSet([author])
|
||||
.concat(rebloggedBy ? [rebloggedBy.acct] : [])
|
||||
.concat(mentions)
|
||||
.delete(account.get('acct')) as ImmutableOrderedSet<string>;
|
||||
};
|
||||
|
||||
export const statusToMentionsAccountIdsArray = (status: StatusEntity, account: AccountEntity) => {
|
||||
export const statusToMentionsAccountIdsArray = (status: StatusEntity, account: AccountEntity, parentRebloggedBy?: string | null) => {
|
||||
const author = (status.account as AccountEntity).id;
|
||||
const mentions = status.mentions.map((m) => m.id);
|
||||
|
||||
return ImmutableOrderedSet([author])
|
||||
.concat(parentRebloggedBy ? [parentRebloggedBy] : [])
|
||||
.concat(mentions)
|
||||
.delete(account.id) as ImmutableOrderedSet<string>;
|
||||
};
|
||||
|
@ -308,8 +311,13 @@ export default function compose(state = initialState, action: AnyAction) {
|
|||
return updateCompose(state, 'compose-modal', compose => compose.withMutations(map => {
|
||||
const defaultCompose = state.get('default')!;
|
||||
|
||||
const to = action.explicitAddressing
|
||||
? statusToMentionsArray(action.status, action.account, action.rebloggedBy)
|
||||
: ImmutableOrderedSet<string>();
|
||||
|
||||
map.set('in_reply_to', action.status.get('id'));
|
||||
map.set('to', action.explicitAddressing ? statusToMentionsArray(action.status, action.account) : ImmutableOrderedSet<string>());
|
||||
map.set('to', to);
|
||||
map.set('parent_reblogged_by', (action.rebloggedBy as AccountEntity)?.id || null);
|
||||
map.set('text', !action.explicitAddressing ? statusToTextMentions(action.status, action.account) : '');
|
||||
map.set('privacy', privacyPreference(action.status.visibility, defaultCompose.privacy));
|
||||
map.set('focusDate', new Date());
|
||||
|
@ -323,6 +331,7 @@ export default function compose(state = initialState, action: AnyAction) {
|
|||
|
||||
map.set('quote', action.status.get('id'));
|
||||
map.set('to', ImmutableOrderedSet());
|
||||
map.set('parent_reblogged_by', null);
|
||||
map.set('text', '');
|
||||
map.set('privacy', privacyPreference(action.status.visibility, defaultCompose.privacy));
|
||||
map.set('focusDate', new Date());
|
||||
|
@ -404,11 +413,13 @@ export default function compose(state = initialState, action: AnyAction) {
|
|||
})));
|
||||
case COMPOSE_SET_STATUS:
|
||||
return updateCompose(state, 'compose-modal', compose => compose.withMutations(map => {
|
||||
const to = action.explicitAddressing ? getExplicitMentions(action.status.account.id, action.status) : ImmutableOrderedSet<string>();
|
||||
if (!action.withRedraft) {
|
||||
map.set('id', action.status.get('id'));
|
||||
}
|
||||
map.set('text', action.rawText || unescapeHTML(expandMentions(action.status)));
|
||||
map.set('to', action.explicitAddressing ? getExplicitMentions(action.status.account.id, action.status) : ImmutableOrderedSet<string>());
|
||||
map.set('to', to);
|
||||
map.set('parent_reblogged_by', null);
|
||||
map.set('in_reply_to', action.status.get('in_reply_to_id'));
|
||||
map.set('privacy', action.status.get('visibility'));
|
||||
map.set('focusDate', new Date());
|
||||
|
|
Ładowanie…
Reference in New Issue