From ff89025979abf3dae40b8e0745b2584cc3feb744 Mon Sep 17 00:00:00 2001 From: ThibG Date: Sat, 26 Sep 2020 20:57:07 +0200 Subject: Add unread notification markers (#14818) * Add unread notification markers Fixes #14804 * Allow IntersectionObserverArticle's children to be updated --- .../mastodon/components/intersection_observer_article.js | 12 ++++++------ app/javascript/mastodon/components/status.js | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'app/javascript/mastodon/components') diff --git a/app/javascript/mastodon/components/intersection_observer_article.js b/app/javascript/mastodon/components/intersection_observer_article.js index 124b34b02..2d87f19b5 100644 --- a/app/javascript/mastodon/components/intersection_observer_article.js +++ b/app/javascript/mastodon/components/intersection_observer_article.js @@ -2,10 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import scheduleIdleTask from '../features/ui/util/schedule_idle_task'; import getRectFromEntry from '../features/ui/util/get_rect_from_entry'; -import { is } from 'immutable'; -// Diff these props in the "rendered" state -const updateOnPropsForRendered = ['id', 'index', 'listLength']; // Diff these props in the "unrendered" state const updateOnPropsForUnrendered = ['id', 'index', 'listLength', 'cachedHeight']; @@ -33,9 +30,12 @@ export default class IntersectionObserverArticle extends React.Component { // If we're going from rendered to unrendered (or vice versa) then update return true; } - // Otherwise, diff based on props - const propsToDiff = isUnrendered ? updateOnPropsForUnrendered : updateOnPropsForRendered; - return !propsToDiff.every(prop => is(nextProps[prop], this.props[prop])); + // If we are and remain hidden, diff based on props + if (isUnrendered) { + return !updateOnPropsForUnrendered.every(prop => nextProps[prop] === this.props[prop]); + } + // Else, assume the children have changed + return true; } componentDidMount () { diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index 174e401b7..a1d6f27a6 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -104,6 +104,7 @@ class Status extends ImmutablePureComponent { 'account', 'muted', 'hidden', + 'unread', ]; state = { @@ -438,10 +439,10 @@ class Status extends ImmutablePureComponent { return ( -
+
{prepend} -
+
-- cgit