kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
feat(interactions): create fetchZaps that fetches /api/v1/ditto/statuses/${id}/zapped_by
- fetchZapsRequest - create fetchZapsSuccess - create fetchZapsFailenvironments/review-render-zap-kv0kyl/deployments/4693
rodzic
dbcef52463
commit
d6f29983a1
|
@ -84,6 +84,10 @@ const ZAP_REQUEST = 'ZAP_REQUEST';
|
||||||
const ZAP_SUCCESS = 'ZAP_SUCCESS';
|
const ZAP_SUCCESS = 'ZAP_SUCCESS';
|
||||||
const ZAP_FAIL = 'ZAP_FAIL';
|
const ZAP_FAIL = 'ZAP_FAIL';
|
||||||
|
|
||||||
|
const ZAPS_FETCH_REQUEST = 'ZAPS_FETCH_REQUEST';
|
||||||
|
const ZAPS_FETCH_SUCCESS = 'ZAPS_FETCH_SUCCESS';
|
||||||
|
const ZAPS_FETCH_FAIL = 'ZAPS_FETCH_FAIL';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
bookmarkAdded: { id: 'status.bookmarked', defaultMessage: 'Bookmark added.' },
|
bookmarkAdded: { id: 'status.bookmarked', defaultMessage: 'Bookmark added.' },
|
||||||
bookmarkRemoved: { id: 'status.unbookmarked', defaultMessage: 'Bookmark removed.' },
|
bookmarkRemoved: { id: 'status.unbookmarked', defaultMessage: 'Bookmark removed.' },
|
||||||
|
@ -625,6 +629,35 @@ const fetchReactionsFail = (id: string, error: unknown) => ({
|
||||||
error,
|
error,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const fetchZaps = (id: string) =>
|
||||||
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
dispatch(fetchZapsRequest(id));
|
||||||
|
|
||||||
|
api(getState).get(`/api/v1/ditto/statuses/${id}/zapped_by`).then(response => {
|
||||||
|
dispatch(importFetchedAccounts((response.data as APIEntity[]).map(({ account }) => account).flat()));
|
||||||
|
dispatch(fetchZapsSuccess(id, response.data));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(fetchZapsFail(id, error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchZapsRequest = (id: string) => ({
|
||||||
|
type: ZAPS_FETCH_REQUEST,
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchZapsSuccess = (id: string, zaps: APIEntity[]) => ({
|
||||||
|
type: ZAPS_FETCH_SUCCESS,
|
||||||
|
id,
|
||||||
|
zaps,
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchZapsFail = (id: string, error: unknown) => ({
|
||||||
|
type: REACTIONS_FETCH_FAIL,
|
||||||
|
id,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
||||||
const pin = (status: StatusEntity) =>
|
const pin = (status: StatusEntity) =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
if (!isLoggedIn(getState)) return;
|
if (!isLoggedIn(getState)) return;
|
||||||
|
@ -802,6 +835,9 @@ export {
|
||||||
REBLOGS_EXPAND_FAIL,
|
REBLOGS_EXPAND_FAIL,
|
||||||
ZAP_REQUEST,
|
ZAP_REQUEST,
|
||||||
ZAP_FAIL,
|
ZAP_FAIL,
|
||||||
|
ZAPS_FETCH_REQUEST,
|
||||||
|
ZAPS_FETCH_SUCCESS,
|
||||||
|
ZAPS_FETCH_FAIL,
|
||||||
reblog,
|
reblog,
|
||||||
unreblog,
|
unreblog,
|
||||||
toggleReblog,
|
toggleReblog,
|
||||||
|
@ -872,4 +908,5 @@ export {
|
||||||
remoteInteractionSuccess,
|
remoteInteractionSuccess,
|
||||||
remoteInteractionFail,
|
remoteInteractionFail,
|
||||||
zap,
|
zap,
|
||||||
|
fetchZaps,
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue