diff --git a/packages/pl-fe/src/actions/bookmarks.ts b/packages/pl-fe/src/actions/bookmarks.ts deleted file mode 100644 index 54b56ef75..000000000 --- a/packages/pl-fe/src/actions/bookmarks.ts +++ /dev/null @@ -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, next: (() => Promise>) | 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, next: (() => Promise>) | 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 - | ReturnType - | ReturnType - | ReturnType - | ReturnType - | ReturnType; - -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, -}; diff --git a/packages/pl-fe/src/features/admin/components/report-status.tsx b/packages/pl-fe/src/features/admin/components/report-status.tsx deleted file mode 100644 index 39f45d93f..000000000 --- a/packages/pl-fe/src/features/admin/components/report-status.tsx +++ /dev/null @@ -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 = ({ 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 ( - - - - - - -
- -
-
- ); -}; - -export { ReportStatus as default }; diff --git a/packages/pl-fe/src/hooks/use-is-mobile.ts b/packages/pl-fe/src/hooks/use-is-mobile.ts deleted file mode 100644 index 3ff841371..000000000 --- a/packages/pl-fe/src/hooks/use-is-mobile.ts +++ /dev/null @@ -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; -} diff --git a/packages/pl-fe/src/hooks/use-screen-width.ts b/packages/pl-fe/src/hooks/use-screen-width.ts deleted file mode 100644 index d95eed644..000000000 --- a/packages/pl-fe/src/hooks/use-screen-width.ts +++ /dev/null @@ -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; -} diff --git a/packages/pl-fe/src/normalizers/admin-report.ts b/packages/pl-fe/src/normalizers/admin-report.ts deleted file mode 100644 index 9d40f560a..000000000 --- a/packages/pl-fe/src/normalizers/admin-report.ts +++ /dev/null @@ -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; - -export { normalizeAdminReport, type AdminReport };