refactor: remove UNBOOKMARK_SUCCESS fragments
This commit is contained in:
parent
40fbdd952c
commit
e56ffdae40
|
@ -1,6 +1,3 @@
|
|||
import { defineMessages } from 'react-intl';
|
||||
|
||||
import toast from 'soapbox/toast.tsx';
|
||||
import { isLoggedIn } from 'soapbox/utils/auth.ts';
|
||||
|
||||
import api from '../api/index.ts';
|
||||
|
@ -64,7 +61,6 @@ const BOOKMARK_REQUEST = 'BOOKMARK_REQUEST';
|
|||
const BOOKMARK_FAIL = 'BOOKMARKED_FAIL';
|
||||
|
||||
const UNBOOKMARK_REQUEST = 'UNBOOKMARKED_REQUEST';
|
||||
const UNBOOKMARK_SUCCESS = 'UNBOOKMARKED_SUCCESS';
|
||||
const UNBOOKMARK_FAIL = 'UNBOOKMARKED_FAIL';
|
||||
|
||||
const REMOTE_INTERACTION_REQUEST = 'REMOTE_INTERACTION_REQUEST';
|
||||
|
@ -88,12 +84,6 @@ const ZAPS_FETCH_FAIL = 'ZAPS_FETCH_FAIL';
|
|||
const ZAPS_EXPAND_SUCCESS = 'ZAPS_EXPAND_SUCCESS';
|
||||
const ZAPS_EXPAND_FAIL = 'ZAPS_EXPAND_FAIL';
|
||||
|
||||
const messages = defineMessages({
|
||||
bookmarkAdded: { id: 'status.bookmarked', defaultMessage: 'Bookmark added.' },
|
||||
bookmarkRemoved: { id: 'status.unbookmarked', defaultMessage: 'Bookmark removed.' },
|
||||
view: { id: 'toast.view', defaultMessage: 'View' },
|
||||
});
|
||||
|
||||
type ReblogEffects = {
|
||||
reblogEffect: (statusId: string) => void;
|
||||
unreblogEffect: (statusId: string) => void;
|
||||
|
@ -367,19 +357,6 @@ const zapFail = (status: StatusEntity, error: unknown) => ({
|
|||
skipLoading: true,
|
||||
});
|
||||
|
||||
const unbookmark = (status: StatusEntity) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch(unbookmarkRequest(status));
|
||||
|
||||
api(getState).post(`/api/v1/statuses/${status.id}/unbookmark`).then((response) => response.json()).then((data) => {
|
||||
dispatch(importFetchedStatus(data));
|
||||
dispatch(unbookmarkSuccess(status, data));
|
||||
toast.success(messages.bookmarkRemoved);
|
||||
}).catch(error => {
|
||||
dispatch(unbookmarkFail(status, error));
|
||||
});
|
||||
};
|
||||
|
||||
const bookmarkRequest = (status: StatusEntity) => ({
|
||||
type: BOOKMARK_REQUEST,
|
||||
status: status,
|
||||
|
@ -396,12 +373,6 @@ const unbookmarkRequest = (status: StatusEntity) => ({
|
|||
status: status,
|
||||
});
|
||||
|
||||
const unbookmarkSuccess = (status: StatusEntity, response: APIEntity) => ({
|
||||
type: UNBOOKMARK_SUCCESS,
|
||||
status: status,
|
||||
response: response,
|
||||
});
|
||||
|
||||
const unbookmarkFail = (status: StatusEntity, error: unknown) => ({
|
||||
type: UNBOOKMARK_FAIL,
|
||||
status: status,
|
||||
|
@ -814,7 +785,6 @@ export {
|
|||
BOOKMARK_REQUEST,
|
||||
BOOKMARK_FAIL,
|
||||
UNBOOKMARK_REQUEST,
|
||||
UNBOOKMARK_SUCCESS,
|
||||
UNBOOKMARK_FAIL,
|
||||
REMOTE_INTERACTION_REQUEST,
|
||||
REMOTE_INTERACTION_SUCCESS,
|
||||
|
@ -857,11 +827,9 @@ export {
|
|||
undislikeRequest,
|
||||
undislikeSuccess,
|
||||
undislikeFail,
|
||||
unbookmark,
|
||||
bookmarkRequest,
|
||||
bookmarkFail,
|
||||
unbookmarkRequest,
|
||||
unbookmarkSuccess,
|
||||
unbookmarkFail,
|
||||
fetchReblogs,
|
||||
fetchReblogsRequest,
|
||||
|
|
|
@ -39,7 +39,6 @@ import {
|
|||
import {
|
||||
FAVOURITE_SUCCESS,
|
||||
UNFAVOURITE_SUCCESS,
|
||||
UNBOOKMARK_SUCCESS,
|
||||
PIN_SUCCESS,
|
||||
UNPIN_SUCCESS,
|
||||
} from '../actions/interactions.ts';
|
||||
|
@ -151,8 +150,6 @@ export default function statusLists(state = initialState, action: AnyAction) {
|
|||
return prependOneToList(state, 'favourites', action.status);
|
||||
case UNFAVOURITE_SUCCESS:
|
||||
return removeOneFromList(state, 'favourites', action.status);
|
||||
case UNBOOKMARK_SUCCESS:
|
||||
return removeOneFromList(state, 'bookmarks', action.status);
|
||||
case PINNED_STATUSES_FETCH_SUCCESS:
|
||||
return normalizeList(state, 'pins', action.statuses, action.next);
|
||||
case PIN_SUCCESS:
|
||||
|
|
Loading…
Reference in New Issue