diff --git a/app/soapbox/features/chats/components/chat_list.tsx b/app/soapbox/features/chats/components/chat_list.tsx index 2608a8f03..8347c0e89 100644 --- a/app/soapbox/features/chats/components/chat_list.tsx +++ b/app/soapbox/features/chats/components/chat_list.tsx @@ -78,9 +78,7 @@ const ChatList: React.FC = ({ onClickChat, useWindowScroll = false }) Footer: () => hasMore ? : null, EmptyPlaceholder: () => { if (isLoading) { - return ( - <>{Array(20).fill()} - ); + return ; } else { return {intl.formatMessage(messages.emptyMessage)}; } diff --git a/app/soapbox/features/notifications/index.js b/app/soapbox/features/notifications/index.js index fce474a96..5f739e913 100644 --- a/app/soapbox/features/notifications/index.js +++ b/app/soapbox/features/notifications/index.js @@ -1,4 +1,3 @@ -import classNames from 'classnames'; import { List as ImmutableList } from 'immutable'; import { debounce } from 'lodash'; import PropTypes from 'prop-types'; @@ -6,10 +5,12 @@ import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { connect } from 'react-redux'; +import { Virtuoso } from 'react-virtuoso'; import { createSelector } from 'reselect'; import { getSettings } from 'soapbox/actions/settings'; import BirthdayReminders from 'soapbox/components/birthday_reminders'; +import PullToRefresh from 'soapbox/components/pull-to-refresh'; import PlaceholderNotification from 'soapbox/features/placeholder/components/placeholder_notification'; import { getFeatures } from 'soapbox/utils/features'; @@ -18,10 +19,8 @@ import { scrollTopNotifications, dequeueNotifications, } from '../../actions/notifications'; -import LoadGap from '../../components/load_gap'; -import ScrollableList from '../../components/scrollable_list'; import TimelineQueueButtonHeader from '../../components/timeline_queue_button_header'; -import { Column } from '../../components/ui'; +import { Column, Text } from '../../components/ui'; import FilterBarContainer from './containers/filter_bar_container'; import NotificationContainer from './containers/notification_container'; @@ -31,6 +30,30 @@ const messages = defineMessages({ queue: { id: 'notifications.queue_label', defaultMessage: 'Click to see {count} new {count, plural, one {notification} other {notifications}}' }, }); +const Header = ({ context }) => ( + context.showBirthdayReminders ? ( + + ) : null +); + +const Footer = ({ context }) => ( + context.hasMore ? ( + + ) : null +); + +const EmptyPlaceholder = ({ context }) => { + if (context.isLoading) { + return ; + } else { + return {context.emptyMessage}; + } +}; + +const Item = ({ context, ...rest }) => ( +
+); + const getNotifications = createSelector([ state => getSettings(state).getIn(['notifications', 'quickFilter', 'show']), state => getSettings(state).getIn(['notifications', 'quickFilter', 'active']), @@ -163,63 +186,42 @@ class Notifications extends React.PureComponent { const { intl, notifications, isLoading, hasMore, showFilterBar, totalQueuedNotificationsCount, showBirthdayReminders } = this.props; const emptyMessage = ; - let scrollableContent = null; - const filterBarContainer = showFilterBar ? () : null; - if (isLoading && this.scrollableContent) { - scrollableContent = this.scrollableContent; - } else if (notifications.size > 0 || hasMore) { - scrollableContent = notifications.map((item, index) => item === null ? ( - 0 ? notifications.getIn([index - 1, 'id']) : null} - onClick={this.handleLoadGap} + const scrollContainer = ( + + isScrolling && this.handleScroll} + itemContent={(_index, notification) => ( + + )} + context={{ + hasMore, + showBirthdayReminders, + handleMoveBelowBirthdays: this.handleMoveBelowBirthdays, + isLoading, + emptyMessage, + }} + components={{ + Header, + ScrollSeekPlaceholder: PlaceholderNotification, + Footer, + EmptyPlaceholder, + Item, + }} /> - ) : ( - - )); - - if (showBirthdayReminders) scrollableContent = scrollableContent.unshift( - , - ); - } else { - scrollableContent = null; - } - - this.scrollableContent = scrollableContent; - - const scrollContainer = ( - 0, - 'space-y-2': notifications.size === 0, - })} - > - {scrollableContent} - + ); return (