nicolium: remove test timeline
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -1,85 +0,0 @@
|
||||
import debounce from 'lodash/debounce';
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import { defineMessages } from 'react-intl';
|
||||
|
||||
import { dequeueTimeline, scrollTopTimeline } from '@/actions/timelines';
|
||||
import ScrollTopButton from '@/components/scroll-top-button';
|
||||
import StatusList, { type IStatusList } from '@/components/statuses/status-list';
|
||||
import Portal from '@/components/ui/portal';
|
||||
import { useAppDispatch } from '@/hooks/use-app-dispatch';
|
||||
import { useAppSelector } from '@/hooks/use-app-selector';
|
||||
import { makeGetStatusIds } from '@/selectors';
|
||||
|
||||
const messages = defineMessages({
|
||||
queue: {
|
||||
id: 'status_list.queue_label',
|
||||
defaultMessage: 'Click to see {count} new {count, plural, one {post} other {posts}}',
|
||||
},
|
||||
queueLiveRegion: {
|
||||
id: 'status_list.queue_label.live_region',
|
||||
defaultMessage: '{count} new {count, plural, one {post} other {posts}}.',
|
||||
},
|
||||
});
|
||||
|
||||
interface ITimeline extends Omit<IStatusList, 'statusIds' | 'isLoading' | 'hasMore'> {
|
||||
/** Unique key to preserve the scroll position when navigating back. */
|
||||
scrollKey: string;
|
||||
/** ID of the timeline in Redux. */
|
||||
timelineId: string;
|
||||
/** Settings path to use instead of the timelineId. */
|
||||
prefix?: string;
|
||||
}
|
||||
|
||||
/** Scrollable list of statuses from a timeline in the Redux store. */
|
||||
const Timeline: React.FC<ITimeline> = ({ timelineId, onLoadMore, prefix, ...rest }) => {
|
||||
const dispatch = useAppDispatch();
|
||||
const getStatusIds = useMemo(makeGetStatusIds, []);
|
||||
|
||||
const statusIds = useAppSelector((state) => getStatusIds(state, { type: timelineId, prefix }));
|
||||
const lastStatusId = statusIds.at(-1);
|
||||
const isLoading = useAppSelector((state) => state.timelines[timelineId]?.isLoading);
|
||||
const isPartial = useAppSelector((state) => state.timelines[timelineId]?.isPartial || false);
|
||||
const hasMore = useAppSelector((state) => state.timelines[timelineId]?.hasMore);
|
||||
const totalQueuedItemsCount = useAppSelector(
|
||||
(state) => state.timelines[timelineId]?.totalQueuedItemsCount || 0,
|
||||
);
|
||||
|
||||
const handleDequeueTimeline = useCallback(() => {
|
||||
dispatch(dequeueTimeline(timelineId, onLoadMore ? () => onLoadMore(lastStatusId!) : undefined));
|
||||
}, []);
|
||||
|
||||
const handleScroll = useCallback(
|
||||
debounce((startIndex?: number) => {
|
||||
dispatch(scrollTopTimeline(timelineId, startIndex === 0));
|
||||
}, 100),
|
||||
[timelineId],
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Portal>
|
||||
<ScrollTopButton
|
||||
key='timeline-queue-button-header'
|
||||
onClick={handleDequeueTimeline}
|
||||
count={totalQueuedItemsCount}
|
||||
message={messages.queue}
|
||||
liveRegionMessage={messages.queueLiveRegion}
|
||||
/>
|
||||
</Portal>
|
||||
|
||||
<StatusList
|
||||
timelineId={timelineId}
|
||||
onScroll={handleScroll}
|
||||
lastStatusId={lastStatusId}
|
||||
statusIds={statusIds}
|
||||
isLoading={isLoading}
|
||||
isPartial={isPartial}
|
||||
hasMore={hasMore}
|
||||
onLoadMore={onLoadMore}
|
||||
{...rest}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export { Timeline as default };
|
||||
@ -144,7 +144,6 @@ import {
|
||||
Share,
|
||||
Status,
|
||||
Subscribers,
|
||||
TestTimeline,
|
||||
ThemeEditor,
|
||||
Privacy,
|
||||
UserIndex,
|
||||
@ -1211,13 +1210,6 @@ export const developersSettingsStoreRoute = createRoute({
|
||||
beforeLoad: requireAuth,
|
||||
});
|
||||
|
||||
export const developersTimelineRoute = createRoute({
|
||||
getParentRoute: () => layouts.default,
|
||||
path: '/developers/timeline',
|
||||
component: TestTimeline,
|
||||
beforeLoad: requireAuth,
|
||||
});
|
||||
|
||||
export const developersSwRoute = createRoute({
|
||||
getParentRoute: () => layouts.default,
|
||||
path: '/developers/sw',
|
||||
@ -1519,7 +1511,6 @@ const routeTree = rootRoute.addChildren([
|
||||
developersRoute,
|
||||
developersAppsRoute,
|
||||
developersSettingsStoreRoute,
|
||||
developersTimelineRoute,
|
||||
developersSwRoute,
|
||||
cryptoDonateRoute,
|
||||
federationRestrictionsRoute,
|
||||
|
||||
@ -107,7 +107,6 @@ export const SettingsStore = lazy(() => import('@/pages/developers/settings-stor
|
||||
export const Share = lazy(() => import('@/pages/utils/share'));
|
||||
export const Status = lazy(() => import('@/pages/statuses/status'));
|
||||
export const Subscribers = lazy(() => import('@/pages/account-lists/subscribers'));
|
||||
export const TestTimeline = lazy(() => import('@/pages/timelines/test-timeline'));
|
||||
export const ThemeEditor = lazy(() => import('@/pages/dashboard/theme-editor'));
|
||||
export const Privacy = lazy(() => import('@/pages/settings/privacy'));
|
||||
export const UserIndex = lazy(() => import('@/pages/dashboard/user-index'));
|
||||
|
||||
@ -82,20 +82,6 @@ const DevelopersPage: React.FC = () => {
|
||||
</Text>
|
||||
</DashWidget>
|
||||
|
||||
<DashWidget to='/developers/timeline'>
|
||||
<SvgIcon
|
||||
src={require('@phosphor-icons/core/regular/list-bullets.svg')}
|
||||
className='text-gray-700 dark:text-gray-600'
|
||||
/>
|
||||
|
||||
<Text>
|
||||
<FormattedMessage
|
||||
id='developers.navigation.test_timeline_label'
|
||||
defaultMessage='Test timeline'
|
||||
/>
|
||||
</Text>
|
||||
</DashWidget>
|
||||
|
||||
<DashWidget to='/error'>
|
||||
<SvgIcon
|
||||
src={require('@phosphor-icons/core/regular/bug.svg')}
|
||||
|
||||
@ -1,52 +0,0 @@
|
||||
import React from 'react';
|
||||
import { defineMessages, useIntl, FormattedMessage } from 'react-intl';
|
||||
|
||||
import { importEntities } from '@/actions/importer';
|
||||
import { expandTimelineSuccess } from '@/actions/timelines';
|
||||
import Column from '@/components/ui/column';
|
||||
import Timeline from '@/features/ui/components/timeline';
|
||||
import { useAppDispatch } from '@/hooks/use-app-dispatch';
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'column.test', defaultMessage: 'Test timeline' },
|
||||
});
|
||||
|
||||
/**
|
||||
* List of mock statuses to display in the timeline.
|
||||
* These get embedded into the build, but only in this chunk, so it's okay.
|
||||
*/
|
||||
const MOCK_STATUSES: any[] = [
|
||||
require('@/__fixtures__/pleroma-status.json'),
|
||||
require('@/__fixtures__/pleroma-status-with-poll.json'),
|
||||
require('@/__fixtures__/pleroma-status-vertical-video-without-metadata.json'),
|
||||
require('@/__fixtures__/pleroma-status-with-poll-with-emojis.json'),
|
||||
require('@/__fixtures__/pleroma-quote-of-quote-post.json'),
|
||||
];
|
||||
|
||||
const timelineId = 'test';
|
||||
const onlyMedia = false;
|
||||
|
||||
const TestTimelinePage: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
React.useEffect(() => {
|
||||
importEntities({ statuses: MOCK_STATUSES });
|
||||
dispatch(expandTimelineSuccess(timelineId, MOCK_STATUSES, null, null, false));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Column label={intl.formatMessage(messages.title)}>
|
||||
<Timeline
|
||||
scrollKey={`${timelineId}_timeline`}
|
||||
timelineId={`${timelineId}${onlyMedia ? ':media' : ''}`}
|
||||
emptyMessageText={
|
||||
<FormattedMessage id='empty_column.test' defaultMessage='The test timeline is empty.' />
|
||||
}
|
||||
emptyMessageIcon={require('@phosphor-icons/core/regular/chat-centered-text.svg')}
|
||||
/>
|
||||
</Column>
|
||||
);
|
||||
};
|
||||
|
||||
export { TestTimelinePage as default };
|
||||
Reference in New Issue
Block a user