Browse Source

修改闭社树上内容转嘟的引用显示

pull/4/head
欧醚 4 years ago
parent
commit
dbd802d13b
4 changed files with 79 additions and 16 deletions
  1. +10
    -3
      app/javascript/mastodon/components/status.js
  2. +62
    -12
      app/javascript/mastodon/containers/status_container.js
  3. +6
    -0
      app/javascript/styles/closed-social/global.scss
  4. +1
    -1
      app/javascript/styles/closed-social/timeline_comments.scss

+ 10
- 3
app/javascript/mastodon/components/status.js View File

@ -101,7 +101,8 @@ class Status extends ImmutablePureComponent {
'account',
'muted',
'hidden',
'sonsIds'
'sonsIds',
'ancestorsText',
];
state = {
@ -329,7 +330,7 @@ class Status extends ImmutablePureComponent {
let statusAvatar, prepend, rebloggedByText;
let sons, quote;
const { intl, hidden, featured, otherAccounts, unread, showThread, deep, tree_type, sonsIds } = this.props;
const { intl, hidden, featured, otherAccounts, unread, showThread, deep, tree_type, ancestorsText, sonsIds } = this.props;
let { status, account, ...other } = this.props;
@ -489,7 +490,13 @@ class Status extends ImmutablePureComponent {
}
if (rebloggedByText && status.get('in_reply_to_id')) {
quote = <div className='status__quote__wrapper'>
quote = ancestorsText ?
<div className='status__tree__quote__wrapper'>
<Icon id="tree" />
{ancestorsText}
</div>
:
<div className='status__quote__wrapper'>
<StatusContainer
key={status.get('in_reply_to_id')}
id={status.get('in_reply_to_id')}

+ 62
- 12
app/javascript/mastodon/containers/status_container.js View File

@ -1,4 +1,6 @@
import { connect } from 'react-redux';
import Immutable from 'immutable';
import { createSelector } from 'reselect';
import Status from '../components/status';
import { makeGetStatus } from '../selectors';
import {
@ -27,7 +29,7 @@ import { initBlockModal } from '../actions/blocks';
import { initReport } from '../actions/reports';
import { openModal } from '../actions/modal';
import { defineMessages, injectIntl } from 'react-intl';
import { boostModal, deleteModal } from '../initial_state';
import { boostModal, deleteModal, treeRoot } from '../initial_state';
import { showAlertForError } from '../actions/alerts';
const messages = defineMessages({
@ -41,20 +43,68 @@ const messages = defineMessages({
const makeMapStateToProps = () => {
const getStatus = makeGetStatus();
const getAncestorsIds = createSelector([
(_, { id }) => id,
state => state.getIn(['contexts', 'inReplyTos']),
], (statusId, inReplyTos) => {
let ancestorsIds = Immutable.List();
ancestorsIds = ancestorsIds.withMutations(mutable => {
let id = statusId;
while (id) {
mutable.unshift(id);
id = inReplyTos.get(id);
}
});
return ancestorsIds;
});
const getAncestorsText = createSelector([
(_, {ids}) => ids,
state => state.get('statuses'),
], (ids, statuses) => ids.map(i => {
let text = statuses.get(i) ? statuses.get(i).get('search_index') : i;
if(text.length > 16)
text = text.slice(0,13) + "...";
return text;
}).join(' >> ')
);
const getSonsIds = createSelector([
(_, {id}) => id,
state => state.getIn(['contexts', 'replies']),
], (statusId, contextReplies) => {
const sons = contextReplies.get(statusId);
return sons ? sons.map(id => ({
'id': id,
'sonsIds' : contextReplies.get(id),
}))
: null;
});
const mapStateToProps = (state, props) => {
const status = getStatus(state, props);
const sons = (props.showThread && status!==null) ? state.getIn(['contexts', 'replies', status.getIn(['reblog', 'id'], props.id)]) : null;
return ({
'status': status,
'sonsIds': (props.showThread && sons) ? sons.map(id => ({
'id': id,
'sonsIds' : state.getIn(['contexts', 'replies', id])
}))
:
null,
})
}
let ancestorsIds = Immutable.List();
let ancestorsText;
let sonsIds;
if (props.showThread && status) {
sonsIds = getSonsIds(state, { id : status.getIn(['reblog', 'id'], props.id)});
if(status.get('reblog')) {
ancestorsIds = getAncestorsIds(state, { id: status.getIn(['reblog', 'in_reply_to_id']) });
if(ancestorsIds && ancestorsIds.first() == treeRoot.split('/').pop()) {
ancestorsText = getAncestorsText(state, { ids: ancestorsIds.shift() });
}
}
}
return {
status,
ancestorsText,
sonsIds,
};
};
return mapStateToProps;
};

+ 6
- 0
app/javascript/styles/closed-social/global.scss View File

@ -65,6 +65,12 @@ div {
}
}
.status__tree__quote__wrapper {
margin-top:16px;
padding: 10px 5px;
background: #dbdbdb40;
}
@keyframes like {
0% {
transform: scale(1);

+ 1
- 1
app/javascript/styles/closed-social/timeline_comments.scss View File

@ -26,7 +26,7 @@
box-shadow: $primary-text-color 3.2px 3.2px 8px;
}
& .comments-timeline-2 {
margin-left:40px;
margin-left:42px;
}
}

Loading…
Cancel
Save