kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
ScrollTopButton: restore `count` prop so it works in Notifications again
rodzic
6da72d874e
commit
aad192d150
|
@ -5,12 +5,12 @@ import { useIntl, MessageDescriptor } from 'react-intl';
|
||||||
|
|
||||||
import Icon from 'soapbox/components/icon';
|
import Icon from 'soapbox/components/icon';
|
||||||
import { Text } from 'soapbox/components/ui';
|
import { Text } from 'soapbox/components/ui';
|
||||||
import { useAppSelector, useSettings } from 'soapbox/hooks';
|
import { useSettings } from 'soapbox/hooks';
|
||||||
import { shortNumberFormat } from 'soapbox/utils/numbers';
|
import { shortNumberFormat } from 'soapbox/utils/numbers';
|
||||||
|
|
||||||
interface IScrollTopButton {
|
interface IScrollTopButton {
|
||||||
onClick: () => void,
|
onClick: () => void,
|
||||||
timelineId: string,
|
count: number,
|
||||||
message: MessageDescriptor,
|
message: MessageDescriptor,
|
||||||
threshold?: number,
|
threshold?: number,
|
||||||
autoloadThreshold?: number,
|
autoloadThreshold?: number,
|
||||||
|
@ -18,14 +18,13 @@ interface IScrollTopButton {
|
||||||
|
|
||||||
const ScrollTopButton: React.FC<IScrollTopButton> = ({
|
const ScrollTopButton: React.FC<IScrollTopButton> = ({
|
||||||
onClick,
|
onClick,
|
||||||
timelineId,
|
count,
|
||||||
message,
|
message,
|
||||||
threshold = 400,
|
threshold = 400,
|
||||||
autoloadThreshold = 50,
|
autoloadThreshold = 50,
|
||||||
}) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const settings = useSettings();
|
const settings = useSettings();
|
||||||
const count = useAppSelector(state => state.timelines.getIn([timelineId, 'totalQueuedItemsCount']));
|
|
||||||
|
|
||||||
const [scrolled, setScrolled] = useState<boolean>(false);
|
const [scrolled, setScrolled] = useState<boolean>(false);
|
||||||
const autoload = settings.get('autoloadTimelines') === true;
|
const autoload = settings.get('autoloadTimelines') === true;
|
||||||
|
|
|
@ -31,6 +31,7 @@ const Timeline: React.FC<ITimeline> = ({
|
||||||
const isLoading = useAppSelector(state => state.timelines.getIn([timelineId, 'isLoading'], true) === true);
|
const isLoading = useAppSelector(state => state.timelines.getIn([timelineId, 'isLoading'], true) === true);
|
||||||
const isPartial = useAppSelector(state => state.timelines.getIn([timelineId, 'isPartial'], false) === true);
|
const isPartial = useAppSelector(state => state.timelines.getIn([timelineId, 'isPartial'], false) === true);
|
||||||
const hasMore = useAppSelector(state => state.timelines.getIn([timelineId, 'hasMore']) === true);
|
const hasMore = useAppSelector(state => state.timelines.getIn([timelineId, 'hasMore']) === true);
|
||||||
|
const totalQueuedItemsCount = useAppSelector(state => state.timelines.getIn([timelineId, 'totalQueuedItemsCount']));
|
||||||
|
|
||||||
const handleDequeueTimeline = () => {
|
const handleDequeueTimeline = () => {
|
||||||
dispatch(dequeueTimeline(timelineId, onLoadMore));
|
dispatch(dequeueTimeline(timelineId, onLoadMore));
|
||||||
|
@ -49,7 +50,7 @@ const Timeline: React.FC<ITimeline> = ({
|
||||||
<ScrollTopButton
|
<ScrollTopButton
|
||||||
key='timeline-queue-button-header'
|
key='timeline-queue-button-header'
|
||||||
onClick={handleDequeueTimeline}
|
onClick={handleDequeueTimeline}
|
||||||
timelineId={timelineId}
|
count={totalQueuedItemsCount}
|
||||||
message={messages.queue}
|
message={messages.queue}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue