pl-fe: remove unused
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -1,107 +0,0 @@
|
||||
import { getClient } from '../api';
|
||||
|
||||
import { importEntities } from './importer';
|
||||
|
||||
import type { PaginatedResponse, Status } from 'pl-api';
|
||||
import type { AppDispatch, RootState } from 'pl-fe/store';
|
||||
|
||||
const BOOKMARKED_STATUSES_FETCH_REQUEST = 'BOOKMARKED_STATUSES_FETCH_REQUEST' as const;
|
||||
const BOOKMARKED_STATUSES_FETCH_SUCCESS = 'BOOKMARKED_STATUSES_FETCH_SUCCESS' as const;
|
||||
const BOOKMARKED_STATUSES_FETCH_FAIL = 'BOOKMARKED_STATUSES_FETCH_FAIL' as const;
|
||||
|
||||
const BOOKMARKED_STATUSES_EXPAND_REQUEST = 'BOOKMARKED_STATUSES_EXPAND_REQUEST' as const;
|
||||
const BOOKMARKED_STATUSES_EXPAND_SUCCESS = 'BOOKMARKED_STATUSES_EXPAND_SUCCESS' as const;
|
||||
const BOOKMARKED_STATUSES_EXPAND_FAIL = 'BOOKMARKED_STATUSES_EXPAND_FAIL' as const;
|
||||
|
||||
const noOp = () => new Promise(f => f(undefined));
|
||||
|
||||
const fetchBookmarkedStatuses = (folderId?: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (getState().status_lists[folderId ? `bookmarks:${folderId}` : 'bookmarks']?.isLoading) {
|
||||
return dispatch(noOp);
|
||||
}
|
||||
|
||||
dispatch(fetchBookmarkedStatusesRequest(folderId));
|
||||
|
||||
return getClient(getState()).myAccount.getBookmarks({ folder_id: folderId }).then(response => {
|
||||
dispatch(importEntities({ statuses: response.items }));
|
||||
return dispatch(fetchBookmarkedStatusesSuccess(response.items, response.next, folderId));
|
||||
}).catch(error => {
|
||||
dispatch(fetchBookmarkedStatusesFail(error, folderId));
|
||||
});
|
||||
};
|
||||
|
||||
const fetchBookmarkedStatusesRequest = (folderId?: string) => ({
|
||||
type: BOOKMARKED_STATUSES_FETCH_REQUEST,
|
||||
folderId,
|
||||
});
|
||||
|
||||
const fetchBookmarkedStatusesSuccess = (statuses: Array<Status>, next: (() => Promise<PaginatedResponse<Status>>) | null, folderId?: string) => ({
|
||||
type: BOOKMARKED_STATUSES_FETCH_SUCCESS,
|
||||
statuses,
|
||||
next,
|
||||
folderId,
|
||||
});
|
||||
|
||||
const fetchBookmarkedStatusesFail = (error: unknown, folderId?: string) => ({
|
||||
type: BOOKMARKED_STATUSES_FETCH_FAIL,
|
||||
error,
|
||||
folderId,
|
||||
});
|
||||
|
||||
const expandBookmarkedStatuses = (folderId?: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const list = folderId ? `bookmarks:${folderId}` : 'bookmarks';
|
||||
const next = getState().status_lists[list]?.next || null;
|
||||
|
||||
if (next === null || getState().status_lists[list]?.isLoading) {
|
||||
return dispatch(noOp);
|
||||
}
|
||||
|
||||
dispatch(expandBookmarkedStatusesRequest(folderId));
|
||||
|
||||
return next().then(response => {
|
||||
dispatch(importEntities({ statuses: response.items }));
|
||||
return dispatch(expandBookmarkedStatusesSuccess(response.items, response.next, folderId));
|
||||
}).catch(error => {
|
||||
dispatch(expandBookmarkedStatusesFail(error, folderId));
|
||||
});
|
||||
};
|
||||
|
||||
const expandBookmarkedStatusesRequest = (folderId?: string) => ({
|
||||
type: BOOKMARKED_STATUSES_EXPAND_REQUEST,
|
||||
folderId,
|
||||
});
|
||||
|
||||
const expandBookmarkedStatusesSuccess = (statuses: Array<Status>, next: (() => Promise<PaginatedResponse<Status>>) | null, folderId?: string) => ({
|
||||
type: BOOKMARKED_STATUSES_EXPAND_SUCCESS,
|
||||
statuses,
|
||||
next,
|
||||
folderId,
|
||||
});
|
||||
|
||||
const expandBookmarkedStatusesFail = (error: unknown, folderId?: string) => ({
|
||||
type: BOOKMARKED_STATUSES_EXPAND_FAIL,
|
||||
error,
|
||||
folderId,
|
||||
});
|
||||
|
||||
type BookmarksAction =
|
||||
ReturnType<typeof fetchBookmarkedStatusesRequest>
|
||||
| ReturnType<typeof fetchBookmarkedStatusesSuccess>
|
||||
| ReturnType<typeof fetchBookmarkedStatusesFail>
|
||||
| ReturnType<typeof expandBookmarkedStatusesRequest>
|
||||
| ReturnType<typeof expandBookmarkedStatusesSuccess>
|
||||
| ReturnType<typeof expandBookmarkedStatusesFail>;
|
||||
|
||||
export {
|
||||
BOOKMARKED_STATUSES_FETCH_REQUEST,
|
||||
BOOKMARKED_STATUSES_FETCH_SUCCESS,
|
||||
BOOKMARKED_STATUSES_FETCH_FAIL,
|
||||
BOOKMARKED_STATUSES_EXPAND_REQUEST,
|
||||
BOOKMARKED_STATUSES_EXPAND_SUCCESS,
|
||||
BOOKMARKED_STATUSES_EXPAND_FAIL,
|
||||
fetchBookmarkedStatuses,
|
||||
expandBookmarkedStatuses,
|
||||
type BookmarksAction,
|
||||
};
|
||||
@ -1,65 +0,0 @@
|
||||
import React from 'react';
|
||||
import { useIntl, defineMessages } from 'react-intl';
|
||||
|
||||
import { deleteStatusModal } from 'pl-fe/actions/moderation';
|
||||
import DropdownMenu from 'pl-fe/components/dropdown-menu';
|
||||
import StatusContent from 'pl-fe/components/status-content';
|
||||
import StatusMedia from 'pl-fe/components/status-media';
|
||||
import HStack from 'pl-fe/components/ui/hstack';
|
||||
import Stack from 'pl-fe/components/ui/stack';
|
||||
import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch';
|
||||
|
||||
import type { SelectedStatus } from 'pl-fe/selectors';
|
||||
|
||||
const messages = defineMessages({
|
||||
viewStatus: { id: 'admin.reports.actions.view_status', defaultMessage: 'View post' },
|
||||
deleteStatus: { id: 'admin.statuses.actions.delete_status', defaultMessage: 'Delete post' },
|
||||
});
|
||||
|
||||
interface IReportStatus {
|
||||
status: SelectedStatus;
|
||||
}
|
||||
|
||||
const ReportStatus: React.FC<IReportStatus> = ({ status }) => {
|
||||
const intl = useIntl();
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const handleDeleteStatus = () => {
|
||||
dispatch(deleteStatusModal(intl, status.id));
|
||||
};
|
||||
|
||||
const makeMenu = () => {
|
||||
const acct = status.account.acct;
|
||||
|
||||
return [{
|
||||
text: intl.formatMessage(messages.viewStatus, { acct: `@${acct}` }),
|
||||
to: `/@${acct}/posts/${status.id}`,
|
||||
icon: require('@tabler/icons/outline/arrows-vertical.svg'),
|
||||
}, {
|
||||
text: intl.formatMessage(messages.deleteStatus, { acct: `@${acct}` }),
|
||||
action: handleDeleteStatus,
|
||||
icon: require('@tabler/icons/outline/trash.svg'),
|
||||
destructive: true,
|
||||
}];
|
||||
};
|
||||
|
||||
const menu = makeMenu();
|
||||
|
||||
return (
|
||||
<HStack space={2} alignItems='start'>
|
||||
<Stack space={2} className='overflow-hidden' grow>
|
||||
<StatusContent status={status} />
|
||||
<StatusMedia status={status} />
|
||||
</Stack>
|
||||
|
||||
<div className='flex-none'>
|
||||
<DropdownMenu
|
||||
items={menu}
|
||||
src={require('@tabler/icons/outline/dots-vertical.svg')}
|
||||
/>
|
||||
</div>
|
||||
</HStack>
|
||||
);
|
||||
};
|
||||
|
||||
export { ReportStatus as default };
|
||||
@ -1,8 +0,0 @@
|
||||
import { LAYOUT_BREAKPOINT } from 'pl-fe/is-mobile';
|
||||
|
||||
import { useScreenWidth } from './use-screen-width';
|
||||
|
||||
export function useIsMobile() {
|
||||
const screenWidth = useScreenWidth();
|
||||
return screenWidth <= LAYOUT_BREAKPOINT;
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
export function useScreenWidth() {
|
||||
const [screenWidth, setScreenWidth] = useState(window.innerWidth);
|
||||
|
||||
useEffect(() => {
|
||||
const checkWindowSize = () => {
|
||||
setScreenWidth(window.innerWidth);
|
||||
};
|
||||
|
||||
window.addEventListener('resize', checkWindowSize);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('resize', checkWindowSize);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return screenWidth;
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
import type { AdminReport as BaseAdminReport } from 'pl-api';
|
||||
|
||||
const normalizeAdminReport = ({
|
||||
account, target_account, action_taken_by_account, assigned_account, statuses, ...report
|
||||
}: BaseAdminReport) => ({
|
||||
...report,
|
||||
account_id: account?.id || null,
|
||||
target_account_id: target_account?.id || null,
|
||||
action_taken_by_account_id: action_taken_by_account?.id || null,
|
||||
assigned_account_id: assigned_account?.id || null,
|
||||
status_ids: statuses.map(status => status.id),
|
||||
});
|
||||
|
||||
type AdminReport = ReturnType<typeof normalizeAdminReport>;
|
||||
|
||||
export { normalizeAdminReport, type AdminReport };
|
||||
Reference in New Issue
Block a user