diff --git a/packages/pl-fe/src/actions/notifications.ts b/packages/pl-fe/src/actions/notifications.ts index c856e2d5d..5f93b8d98 100644 --- a/packages/pl-fe/src/actions/notifications.ts +++ b/packages/pl-fe/src/actions/notifications.ts @@ -286,7 +286,6 @@ type NotificationsAction = export { NOTIFICATIONS_UPDATE, - NOTIFICATIONS_UPDATE_NOOP, NOTIFICATIONS_EXPAND_REQUEST, NOTIFICATIONS_EXPAND_SUCCESS, NOTIFICATIONS_EXPAND_FAIL, diff --git a/packages/pl-fe/src/actions/pin-statuses.ts b/packages/pl-fe/src/actions/pin-statuses.ts index e9ddd0b92..4103689e0 100644 --- a/packages/pl-fe/src/actions/pin-statuses.ts +++ b/packages/pl-fe/src/actions/pin-statuses.ts @@ -7,49 +7,29 @@ import { importEntities } from './importer'; import type { PaginatedResponse, Status } from 'pl-api'; import type { AppDispatch, RootState } from 'pl-fe/store'; -const PINNED_STATUSES_FETCH_REQUEST = 'PINNED_STATUSES_FETCH_REQUEST' as const; const PINNED_STATUSES_FETCH_SUCCESS = 'PINNED_STATUSES_FETCH_SUCCESS' as const; -const PINNED_STATUSES_FETCH_FAIL = 'PINNED_STATUSES_FETCH_FAIL' as const; const fetchPinnedStatuses = () => (dispatch: AppDispatch, getState: () => RootState) => { if (!isLoggedIn(getState)) return; const me = getState().me; - dispatch(fetchPinnedStatusesRequest()); - return getClient(getState()).accounts.getAccountStatuses(me as string, { pinned: true }).then(response => { dispatch(importEntities({ statuses: response.items })); dispatch(fetchPinnedStatusesSuccess(response.items, response.next)); - }).catch(error => { - dispatch(fetchPinnedStatusesFail(error)); }); }; -const fetchPinnedStatusesRequest = () => ({ - type: PINNED_STATUSES_FETCH_REQUEST, -}); - const fetchPinnedStatusesSuccess = (statuses: Array, next: (() => Promise>) | null) => ({ type: PINNED_STATUSES_FETCH_SUCCESS, statuses, next, }); -const fetchPinnedStatusesFail = (error: unknown) => ({ - type: PINNED_STATUSES_FETCH_FAIL, - error, -}); - -type PinStatusesAction = - ReturnType - | ReturnType - | ReturnType; +type PinStatusesAction = ReturnType; export { - PINNED_STATUSES_FETCH_REQUEST, PINNED_STATUSES_FETCH_SUCCESS, - PINNED_STATUSES_FETCH_FAIL, fetchPinnedStatuses, type PinStatusesAction, }; diff --git a/packages/pl-fe/src/actions/pl-fe.ts b/packages/pl-fe/src/actions/pl-fe.ts index 7891da1a3..6df0cbea6 100644 --- a/packages/pl-fe/src/actions/pl-fe.ts +++ b/packages/pl-fe/src/actions/pl-fe.ts @@ -103,5 +103,4 @@ export { getPlFeConfig, fetchPlFeConfig, loadPlFeConfig, - importPlFeConfig, }; diff --git a/packages/pl-fe/src/actions/polls.ts b/packages/pl-fe/src/actions/polls.ts index 0f3780c03..43458d058 100644 --- a/packages/pl-fe/src/actions/polls.ts +++ b/packages/pl-fe/src/actions/polls.ts @@ -2,81 +2,21 @@ import { getClient } from '../api'; import { importEntities } from './importer'; -import type { Poll } from 'pl-api'; import type { AppDispatch, RootState } from 'pl-fe/store'; -const POLL_VOTE_REQUEST = 'POLL_VOTE_REQUEST' as const; -const POLL_VOTE_SUCCESS = 'POLL_VOTE_SUCCESS' as const; -const POLL_VOTE_FAIL = 'POLL_VOTE_FAIL' as const; - -const POLL_FETCH_REQUEST = 'POLL_FETCH_REQUEST' as const; -const POLL_FETCH_SUCCESS = 'POLL_FETCH_SUCCESS' as const; -const POLL_FETCH_FAIL = 'POLL_FETCH_FAIL' as const; - const vote = (pollId: string, choices: number[]) => - (dispatch: AppDispatch, getState: () => RootState) => { - dispatch(voteRequest()); - - return getClient(getState()).polls.vote(pollId, choices).then((data) => { + (dispatch: AppDispatch, getState: () => RootState) => + getClient(getState()).polls.vote(pollId, choices).then((data) => { dispatch(importEntities({ polls: [data] })); - dispatch(voteSuccess(data)); - }).catch(err => dispatch(voteFail(err))); - }; + }); const fetchPoll = (pollId: string) => - (dispatch: AppDispatch, getState: () => RootState) => { - dispatch(fetchPollRequest()); - - return getClient(getState()).polls.getPoll(pollId).then((data) => { + (dispatch: AppDispatch, getState: () => RootState) => + getClient(getState()).polls.getPoll(pollId).then((data) => { dispatch(importEntities({ polls: [data] })); - dispatch(fetchPollSuccess(data)); - }).catch(err => dispatch(fetchPollFail(err))); - }; - -const voteRequest = () => ({ - type: POLL_VOTE_REQUEST, -}); - -const voteSuccess = (poll: Poll) => ({ - type: POLL_VOTE_SUCCESS, - poll, -}); - -const voteFail = (error: unknown) => ({ - type: POLL_VOTE_FAIL, - error, -}); - -const fetchPollRequest = () => ({ - type: POLL_FETCH_REQUEST, -}); - -const fetchPollSuccess = (poll: Poll) => ({ - type: POLL_FETCH_SUCCESS, - poll, -}); - -const fetchPollFail = (error: unknown) => ({ - type: POLL_FETCH_FAIL, - error, -}); - -type PollsAction = - | ReturnType - | ReturnType - | ReturnType - | ReturnType - | ReturnType - | ReturnType; + }); export { - POLL_VOTE_REQUEST, - POLL_VOTE_SUCCESS, - POLL_VOTE_FAIL, - POLL_FETCH_REQUEST, - POLL_FETCH_SUCCESS, - POLL_FETCH_FAIL, vote, fetchPoll, - type PollsAction, };