1
0
Fork 0
forked from gitea/nas

Merge commit 'eaa1f9e450' into kb_migration

This commit is contained in:
KMY 2023-07-07 07:20:37 +09:00
commit 2a813d517d
73 changed files with 987 additions and 72 deletions

View file

@ -42,6 +42,7 @@ const messages = defineMessages({
admin_status: { id: 'status.admin_status', defaultMessage: 'Open this post in the moderation interface' },
admin_domain: { id: 'status.admin_domain', defaultMessage: 'Open moderation interface for {domain}' },
copy: { id: 'status.copy', defaultMessage: 'Copy link to post' },
reference: { id: 'status.reference', defaultMessage: 'Add reference' },
blockDomain: { id: 'account.block_domain', defaultMessage: 'Block domain {domain}' },
unblockDomain: { id: 'account.unblock_domain', defaultMessage: 'Unblock domain {domain}' },
unmute: { id: 'account.unmute', defaultMessage: 'Unmute @{name}' },
@ -69,6 +70,7 @@ class ActionBar extends PureComponent {
onReblogForceModal: PropTypes.func.isRequired,
onFavourite: PropTypes.func.isRequired,
onEmojiReact: PropTypes.func.isRequired,
onReference: PropTypes.func.isRequired,
onBookmark: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired,
onEdit: PropTypes.func.isRequired,
@ -190,6 +192,10 @@ class ActionBar extends PureComponent {
navigator.clipboard.writeText(url);
};
handleReference = () => {
this.props.onReference(this.props.status);
};
handleEmojiPick = (data) => {
this.props.onEmojiReact(this.props.status, data);
};
@ -227,6 +233,11 @@ class ActionBar extends PureComponent {
menu.push(null);
menu.push({ text: intl.formatMessage(messages.reblog), action: this.handleReblogForceModalClick });
if (publicStatus) {
menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
}
menu.push(null);
}

View file

@ -137,6 +137,7 @@ class DetailedStatus extends ImmutablePureComponent {
let reblogIcon = 'retweet';
let favouriteLink = '';
let emojiReactionsLink = '';
let statusReferencesLink = '';
let edited = '';
if (this.props.measureHeight) {
@ -310,6 +311,26 @@ class DetailedStatus extends ImmutablePureComponent {
);
}
if (this.context.router) {
statusReferencesLink = (
<Link to={`/@${status.getIn(['account', 'acct'])}/${status.get('id')}/references`} className='detailed-status__link'>
<Icon id='link' />
<span className='detailed-status__favorites'>
<AnimatedNumber value={status.get('status_referred_by_count')} />
</span>
</Link>
);
} else {
statusReferencesLink = (
<a href={`/interact/${status.get('id')}?type=references`} className='detailed-status__link' onClick={this.handleModalLink}>
<Icon id='link' />
<span className='detailed-status__favorites'>
<AnimatedNumber value={status.get('status_referred_by_count')} />
</span>
</a>
);
}
if (status.get('edited_at')) {
edited = (
<>
@ -347,7 +368,7 @@ class DetailedStatus extends ImmutablePureComponent {
<div className='detailed-status__meta'>
<a className='detailed-status__datetime' href={`/@${status.getIn(['account', 'acct'])}/${status.get('id')}`} target='_blank' rel='noopener noreferrer'>
<FormattedDate value={new Date(status.get('created_at'))} hour12={false} year='numeric' month='short' day='2-digit' hour='2-digit' minute='2-digit' />
</a>{edited}{visibilityLink}{searchabilityLink}{applicationLink}{reblogLink} · {favouriteLink} · {emojiReactionsLink}
</a>{edited}{visibilityLink}{searchabilityLink}{applicationLink}{reblogLink} · {favouriteLink} · {emojiReactionsLink} - {statusReferencesLink}
</div>
</div>
</div>

View file

@ -28,6 +28,7 @@ import {
replyCompose,
mentionCompose,
directCompose,
insertReferenceCompose,
} from '../../actions/compose';
import {
blockDomain,
@ -88,6 +89,12 @@ const makeMapStateToProps = () => {
const getStatus = makeGetStatus();
const getPictureInPicture = makeGetPictureInPicture();
const getReferenceIds = createSelector([
(state, { id }) => state.getIn(['contexts', 'references', id]),
], (references) => {
return references;
});
const getAncestorsIds = createSelector([
(_, { id }) => id,
state => state.getIn(['contexts', 'inReplyTos']),
@ -147,10 +154,12 @@ const makeMapStateToProps = () => {
let ancestorsIds = Immutable.List();
let descendantsIds = Immutable.List();
let referenceIds = Immutable.List();
if (status) {
ancestorsIds = getAncestorsIds(state, { id: status.get('in_reply_to_id') });
descendantsIds = getDescendantsIds(state, { id: status.get('id') });
referenceIds = getReferenceIds(state, { id: status.get('id') });
}
return {
@ -158,6 +167,7 @@ const makeMapStateToProps = () => {
status,
ancestorsIds,
descendantsIds,
referenceIds,
askReplyConfirmation: state.getIn(['compose', 'text']).trim().length !== 0,
domain: state.getIn(['meta', 'domain']),
pictureInPicture: getPictureInPicture(state, { id: props.params.statusId }),
@ -200,6 +210,7 @@ class Status extends ImmutablePureComponent {
isLoading: PropTypes.bool,
ancestorsIds: ImmutablePropTypes.list,
descendantsIds: ImmutablePropTypes.list,
referenceIds: ImmutablePropTypes.list,
intl: PropTypes.object.isRequired,
askReplyConfirmation: PropTypes.bool,
multiColumn: PropTypes.bool,
@ -356,6 +367,10 @@ class Status extends ImmutablePureComponent {
this.handleReblogClick(status, e, true);
};
handleReference = (status) => {
this.props.dispatch(insertReferenceCompose(0, status.get('url')));
};
handleBookmarkClick = (status) => {
if (status.get('bookmarked')) {
this.props.dispatch(unbookmark(status));
@ -442,8 +457,8 @@ class Status extends ImmutablePureComponent {
};
handleToggleAll = () => {
const { status, ancestorsIds, descendantsIds } = this.props;
const statusIds = [status.get('id')].concat(ancestorsIds.toJS(), descendantsIds.toJS());
const { status, ancestorsIds, descendantsIds, referenceIds } = this.props;
const statusIds = [status.get('id')].concat(ancestorsIds.toJS(), descendantsIds.toJS(), referenceIds.toJS());
if (status.get('hidden')) {
this.props.dispatch(revealStatus(statusIds));
@ -636,8 +651,8 @@ class Status extends ImmutablePureComponent {
};
render () {
let ancestors, descendants;
const { isLoading, status, ancestorsIds, descendantsIds, intl, domain, multiColumn, pictureInPicture } = this.props;
let ancestors, descendants, references;
const { isLoading, status, ancestorsIds, descendantsIds, referenceIds, intl, domain, multiColumn, pictureInPicture } = this.props;
const { fullscreen } = this.state;
if (isLoading) {
@ -654,6 +669,10 @@ class Status extends ImmutablePureComponent {
);
}
if (referenceIds && referenceIds.size > 0) {
references = <>{this.renderChildren(referenceIds, true)}</>;
}
if (ancestorsIds && ancestorsIds.size > 0) {
ancestors = <>{this.renderChildren(ancestorsIds, true)}</>;
}
@ -690,6 +709,7 @@ class Status extends ImmutablePureComponent {
<ScrollContainer scrollKey='thread'>
<div className={classNames('scrollable', { fullscreen })} ref={this.setRef}>
{references}
{ancestors}
<HotKeys handlers={handlers}>
@ -717,6 +737,7 @@ class Status extends ImmutablePureComponent {
onEmojiReact={this.handleEmojiReact}
onReblog={this.handleReblogClick}
onReblogForceModal={this.handleReblogForceModalClick}
onReference={this.handleReference}
onBookmark={this.handleBookmarkClick}
onDelete={this.handleDeleteClick}
onEdit={this.handleEditClick}