pl-fe: remove some unused actions
Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
parent
771cb6b6b8
commit
ea8c07676e
4 changed files with 7 additions and 89 deletions
|
@ -286,7 +286,6 @@ type NotificationsAction =
|
||||||
|
|
||||||
export {
|
export {
|
||||||
NOTIFICATIONS_UPDATE,
|
NOTIFICATIONS_UPDATE,
|
||||||
NOTIFICATIONS_UPDATE_NOOP,
|
|
||||||
NOTIFICATIONS_EXPAND_REQUEST,
|
NOTIFICATIONS_EXPAND_REQUEST,
|
||||||
NOTIFICATIONS_EXPAND_SUCCESS,
|
NOTIFICATIONS_EXPAND_SUCCESS,
|
||||||
NOTIFICATIONS_EXPAND_FAIL,
|
NOTIFICATIONS_EXPAND_FAIL,
|
||||||
|
|
|
@ -7,49 +7,29 @@ import { importEntities } from './importer';
|
||||||
import type { PaginatedResponse, Status } from 'pl-api';
|
import type { PaginatedResponse, Status } from 'pl-api';
|
||||||
import type { AppDispatch, RootState } from 'pl-fe/store';
|
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_SUCCESS = 'PINNED_STATUSES_FETCH_SUCCESS' as const;
|
||||||
const PINNED_STATUSES_FETCH_FAIL = 'PINNED_STATUSES_FETCH_FAIL' as const;
|
|
||||||
|
|
||||||
const fetchPinnedStatuses = () =>
|
const fetchPinnedStatuses = () =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
if (!isLoggedIn(getState)) return;
|
if (!isLoggedIn(getState)) return;
|
||||||
const me = getState().me;
|
const me = getState().me;
|
||||||
|
|
||||||
dispatch(fetchPinnedStatusesRequest());
|
|
||||||
|
|
||||||
return getClient(getState()).accounts.getAccountStatuses(me as string, { pinned: true }).then(response => {
|
return getClient(getState()).accounts.getAccountStatuses(me as string, { pinned: true }).then(response => {
|
||||||
dispatch(importEntities({ statuses: response.items }));
|
dispatch(importEntities({ statuses: response.items }));
|
||||||
dispatch(fetchPinnedStatusesSuccess(response.items, response.next));
|
dispatch(fetchPinnedStatusesSuccess(response.items, response.next));
|
||||||
}).catch(error => {
|
|
||||||
dispatch(fetchPinnedStatusesFail(error));
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchPinnedStatusesRequest = () => ({
|
|
||||||
type: PINNED_STATUSES_FETCH_REQUEST,
|
|
||||||
});
|
|
||||||
|
|
||||||
const fetchPinnedStatusesSuccess = (statuses: Array<Status>, next: (() => Promise<PaginatedResponse<Status>>) | null) => ({
|
const fetchPinnedStatusesSuccess = (statuses: Array<Status>, next: (() => Promise<PaginatedResponse<Status>>) | null) => ({
|
||||||
type: PINNED_STATUSES_FETCH_SUCCESS,
|
type: PINNED_STATUSES_FETCH_SUCCESS,
|
||||||
statuses,
|
statuses,
|
||||||
next,
|
next,
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchPinnedStatusesFail = (error: unknown) => ({
|
type PinStatusesAction = ReturnType<typeof fetchPinnedStatusesSuccess>;
|
||||||
type: PINNED_STATUSES_FETCH_FAIL,
|
|
||||||
error,
|
|
||||||
});
|
|
||||||
|
|
||||||
type PinStatusesAction =
|
|
||||||
ReturnType<typeof fetchPinnedStatusesRequest>
|
|
||||||
| ReturnType<typeof fetchPinnedStatusesSuccess>
|
|
||||||
| ReturnType<typeof fetchPinnedStatusesFail>;
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
PINNED_STATUSES_FETCH_REQUEST,
|
|
||||||
PINNED_STATUSES_FETCH_SUCCESS,
|
PINNED_STATUSES_FETCH_SUCCESS,
|
||||||
PINNED_STATUSES_FETCH_FAIL,
|
|
||||||
fetchPinnedStatuses,
|
fetchPinnedStatuses,
|
||||||
type PinStatusesAction,
|
type PinStatusesAction,
|
||||||
};
|
};
|
||||||
|
|
|
@ -103,5 +103,4 @@ export {
|
||||||
getPlFeConfig,
|
getPlFeConfig,
|
||||||
fetchPlFeConfig,
|
fetchPlFeConfig,
|
||||||
loadPlFeConfig,
|
loadPlFeConfig,
|
||||||
importPlFeConfig,
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,81 +2,21 @@ import { getClient } from '../api';
|
||||||
|
|
||||||
import { importEntities } from './importer';
|
import { importEntities } from './importer';
|
||||||
|
|
||||||
import type { Poll } from 'pl-api';
|
|
||||||
import type { AppDispatch, RootState } from 'pl-fe/store';
|
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[]) =>
|
const vote = (pollId: string, choices: number[]) =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||||
dispatch(voteRequest());
|
getClient(getState()).polls.vote(pollId, choices).then((data) => {
|
||||||
|
|
||||||
return getClient(getState()).polls.vote(pollId, choices).then((data) => {
|
|
||||||
dispatch(importEntities({ polls: [data] }));
|
dispatch(importEntities({ polls: [data] }));
|
||||||
dispatch(voteSuccess(data));
|
});
|
||||||
}).catch(err => dispatch(voteFail(err)));
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchPoll = (pollId: string) =>
|
const fetchPoll = (pollId: string) =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||||
dispatch(fetchPollRequest());
|
getClient(getState()).polls.getPoll(pollId).then((data) => {
|
||||||
|
|
||||||
return getClient(getState()).polls.getPoll(pollId).then((data) => {
|
|
||||||
dispatch(importEntities({ polls: [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<typeof voteRequest>
|
|
||||||
| ReturnType<typeof voteSuccess>
|
|
||||||
| ReturnType<typeof voteFail>
|
|
||||||
| ReturnType<typeof fetchPollRequest>
|
|
||||||
| ReturnType<typeof fetchPollSuccess>
|
|
||||||
| ReturnType<typeof fetchPollFail>;
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
POLL_VOTE_REQUEST,
|
|
||||||
POLL_VOTE_SUCCESS,
|
|
||||||
POLL_VOTE_FAIL,
|
|
||||||
POLL_FETCH_REQUEST,
|
|
||||||
POLL_FETCH_SUCCESS,
|
|
||||||
POLL_FETCH_FAIL,
|
|
||||||
vote,
|
vote,
|
||||||
fetchPoll,
|
fetchPoll,
|
||||||
type PollsAction,
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue