mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
[Glitch] Highlight newly added replies in thread view
Port 059bf1e980 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -118,6 +118,7 @@ class Status extends ImmutablePureComponent {
|
||||
prepend: PropTypes.string,
|
||||
withDismiss: PropTypes.bool,
|
||||
isQuotedPost: PropTypes.bool,
|
||||
shouldHighlightOnMount: PropTypes.bool,
|
||||
getScrollPosition: PropTypes.func,
|
||||
updateScrollBottom: PropTypes.func,
|
||||
expanded: PropTypes.bool,
|
||||
@@ -705,6 +706,7 @@ class Status extends ImmutablePureComponent {
|
||||
muted: this.props.muted,
|
||||
'status--is-quote': isQuotedPost,
|
||||
'status--has-quote': !!status.get('quote'),
|
||||
'status--highlighted-entry': this.props.shouldHighlightOnMount,
|
||||
})
|
||||
}
|
||||
data-id={status.get('id')}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { defineMessages, injectIntl } from 'react-intl';
|
||||
import classNames from 'classnames';
|
||||
import { Helmet } from 'react-helmet';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { difference } from 'lodash';
|
||||
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
@@ -148,9 +149,14 @@ class Status extends ImmutablePureComponent {
|
||||
isExpanded: undefined,
|
||||
threadExpanded: undefined,
|
||||
statusId: undefined,
|
||||
loadedStatusId: undefined,
|
||||
showMedia: undefined,
|
||||
loadedStatusId: undefined,
|
||||
revealBehindCW: undefined,
|
||||
/**
|
||||
* Holds the ids of newly added replies, excluding the initial load.
|
||||
* Used to highlight newly added replies in the UI
|
||||
*/
|
||||
newRepliesIds: [],
|
||||
};
|
||||
|
||||
componentDidMount () {
|
||||
@@ -479,6 +485,7 @@ class Status extends ImmutablePureComponent {
|
||||
previousId={i > 0 ? list[i - 1] : undefined}
|
||||
nextId={list[i + 1] || (ancestors && statusId)}
|
||||
rootId={statusId}
|
||||
shouldHighlightOnMount={this.state.newRepliesIds.includes(id)}
|
||||
/>
|
||||
));
|
||||
}
|
||||
@@ -520,11 +527,20 @@ class Status extends ImmutablePureComponent {
|
||||
}
|
||||
|
||||
componentDidUpdate (prevProps) {
|
||||
const { status, ancestorsIds } = this.props;
|
||||
const { status, ancestorsIds, descendantsIds } = this.props;
|
||||
|
||||
if (status && (ancestorsIds.length > prevProps.ancestorsIds.length || prevProps.status?.get('id') !== status.get('id'))) {
|
||||
this._scrollStatusIntoView();
|
||||
}
|
||||
|
||||
// Only highlight replies after the initial load
|
||||
if (prevProps.descendantsIds.length) {
|
||||
const newRepliesIds = difference(descendantsIds, prevProps.descendantsIds);
|
||||
|
||||
if (newRepliesIds.length) {
|
||||
this.setState({newRepliesIds});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
|
||||
@@ -1657,6 +1657,15 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.no-reduce-motion &--highlighted-entry::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgb(from $ui-highlight-color r g b / 20%);
|
||||
opacity: 0;
|
||||
animation: fade 0.7s reverse both 0.3s;
|
||||
}
|
||||
}
|
||||
|
||||
.status__relative-time {
|
||||
|
||||
Reference in New Issue
Block a user