pl-fe: types, remove unnecessary exports

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-11-12 22:38:16 +01:00
parent 32d25d9f54
commit 9f383a47ca
30 changed files with 130 additions and 320 deletions

View file

@ -700,44 +700,20 @@ export {
createAccount, createAccount,
fetchAccount, fetchAccount,
fetchAccountByUsername, fetchAccountByUsername,
fetchAccountRequest,
fetchAccountSuccess,
fetchAccountFail,
blockAccount, blockAccount,
unblockAccount, unblockAccount,
blockAccountRequest,
blockAccountSuccess,
blockAccountFail,
muteAccount, muteAccount,
unmuteAccount, unmuteAccount,
muteAccountRequest,
muteAccountSuccess,
muteAccountFail,
removeFromFollowers, removeFromFollowers,
fetchRelationships, fetchRelationships,
fetchFollowRequests, fetchFollowRequests,
fetchFollowRequestsRequest,
fetchFollowRequestsSuccess,
fetchFollowRequestsFail,
expandFollowRequests, expandFollowRequests,
expandFollowRequestsRequest,
expandFollowRequestsSuccess,
expandFollowRequestsFail,
authorizeFollowRequest, authorizeFollowRequest,
authorizeFollowRequestRequest,
authorizeFollowRequestSuccess,
authorizeFollowRequestFail,
rejectFollowRequest, rejectFollowRequest,
rejectFollowRequestRequest,
rejectFollowRequestSuccess,
rejectFollowRequestFail,
pinAccount, pinAccount,
unpinAccount, unpinAccount,
updateNotificationSettings, updateNotificationSettings,
fetchPinnedAccounts, fetchPinnedAccounts,
fetchPinnedAccountsRequest,
fetchPinnedAccountsSuccess,
fetchPinnedAccountsFail,
accountSearch, accountSearch,
accountLookup, accountLookup,
fetchBirthdayReminders, fetchBirthdayReminders,

View file

@ -93,7 +93,7 @@ const addToAliases = (account: Account) =>
dispatch(addToAliasesSuccess); dispatch(addToAliasesSuccess);
dispatch(fetchAliases); dispatch(fetchAliases);
}) })
.catch(err => dispatch(fetchAliasesFail(err))); .catch(err => dispatch(addToAliasesFail(err)));
}; };
const addToAliasesRequest = () => ({ const addToAliasesRequest = () => ({
@ -112,13 +112,13 @@ const addToAliasesFail = (error: unknown) => ({
const removeFromAliases = (account: string) => const removeFromAliases = (account: string) =>
(dispatch: AppDispatch, getState: () => RootState) => { (dispatch: AppDispatch, getState: () => RootState) => {
if (!isLoggedIn(getState)) return; if (!isLoggedIn(getState)) return;
dispatch(addToAliasesRequest()); dispatch(removeFromAliasesRequest());
return getClient(getState).settings.deleteAccountAlias(account).then(() => { return getClient(getState).settings.deleteAccountAlias(account).then(() => {
toast.success(messages.removeSuccess); toast.success(messages.removeSuccess);
dispatch(removeFromAliasesSuccess); dispatch(removeFromAliasesSuccess);
dispatch(fetchAliases); dispatch(fetchAliases);
}).catch(err => dispatch(fetchAliasesFail(err))); }).catch(err => dispatch(removeFromAliasesFail(err)));
}; };
const removeFromAliasesRequest = () => ({ const removeFromAliasesRequest = () => ({
@ -162,20 +162,11 @@ export {
ALIASES_REMOVE_SUCCESS, ALIASES_REMOVE_SUCCESS,
ALIASES_REMOVE_FAIL, ALIASES_REMOVE_FAIL,
fetchAliases, fetchAliases,
fetchAliasesRequest,
fetchAliasesSuccess,
fetchAliasesFail,
fetchAliasesSuggestions, fetchAliasesSuggestions,
fetchAliasesSuggestionsReady, fetchAliasesSuggestionsReady,
clearAliasesSuggestions, clearAliasesSuggestions,
changeAliasesSuggestions, changeAliasesSuggestions,
addToAliases, addToAliases,
addToAliasesRequest,
addToAliasesSuccess,
addToAliasesFail,
removeFromAliases, removeFromAliases,
removeFromAliasesRequest,
removeFromAliasesSuccess,
removeFromAliasesFail,
type AliasesAction, type AliasesAction,
}; };

View file

@ -102,12 +102,6 @@ export {
BOOKMARKED_STATUSES_EXPAND_SUCCESS, BOOKMARKED_STATUSES_EXPAND_SUCCESS,
BOOKMARKED_STATUSES_EXPAND_FAIL, BOOKMARKED_STATUSES_EXPAND_FAIL,
fetchBookmarkedStatuses, fetchBookmarkedStatuses,
fetchBookmarkedStatusesRequest,
fetchBookmarkedStatusesSuccess,
fetchBookmarkedStatusesFail,
expandBookmarkedStatuses, expandBookmarkedStatuses,
expandBookmarkedStatusesRequest,
expandBookmarkedStatusesSuccess,
expandBookmarkedStatusesFail,
type BookmarksAction, type BookmarksAction,
}; };

View file

@ -1058,19 +1058,10 @@ export {
directComposeById, directComposeById,
handleComposeSubmit, handleComposeSubmit,
submitCompose, submitCompose,
submitComposeRequest,
submitComposeSuccess,
submitComposeFail,
uploadFile, uploadFile,
uploadCompose, uploadCompose,
changeUploadCompose, changeUploadCompose,
changeUploadComposeRequest,
changeUploadComposeSuccess,
changeUploadComposeFail,
uploadComposeRequest,
uploadComposeProgress,
uploadComposeSuccess, uploadComposeSuccess,
uploadComposeFail,
undoUploadCompose, undoUploadCompose,
groupCompose, groupCompose,
groupComposeModal, groupComposeModal,

View file

@ -114,9 +114,6 @@ export {
unmountConversations, unmountConversations,
markConversationRead, markConversationRead,
expandConversations, expandConversations,
expandConversationsRequest,
expandConversationsSuccess,
expandConversationsFail,
updateConversations, updateConversations,
type ConversationsAction, type ConversationsAction,
}; };

View file

@ -45,8 +45,5 @@ export {
CUSTOM_EMOJIS_FETCH_SUCCESS, CUSTOM_EMOJIS_FETCH_SUCCESS,
CUSTOM_EMOJIS_FETCH_FAIL, CUSTOM_EMOJIS_FETCH_FAIL,
fetchCustomEmojis, fetchCustomEmojis,
fetchCustomEmojisRequest,
fetchCustomEmojisSuccess,
fetchCustomEmojisFail,
type CustomEmojisAction, type CustomEmojisAction,
}; };

View file

@ -82,12 +82,6 @@ export {
DIRECTORY_EXPAND_SUCCESS, DIRECTORY_EXPAND_SUCCESS,
DIRECTORY_EXPAND_FAIL, DIRECTORY_EXPAND_FAIL,
fetchDirectory, fetchDirectory,
fetchDirectoryRequest,
fetchDirectorySuccess,
fetchDirectoryFail,
expandDirectory, expandDirectory,
expandDirectoryRequest,
expandDirectorySuccess,
expandDirectoryFail,
type DirectoryAction, type DirectoryAction,
}; };

View file

@ -193,20 +193,8 @@ export {
DOMAIN_BLOCKS_EXPAND_SUCCESS, DOMAIN_BLOCKS_EXPAND_SUCCESS,
DOMAIN_BLOCKS_EXPAND_FAIL, DOMAIN_BLOCKS_EXPAND_FAIL,
blockDomain, blockDomain,
blockDomainRequest,
blockDomainSuccess,
blockDomainFail,
unblockDomain, unblockDomain,
unblockDomainRequest,
unblockDomainSuccess,
unblockDomainFail,
fetchDomainBlocks, fetchDomainBlocks,
fetchDomainBlocksRequest,
fetchDomainBlocksSuccess,
fetchDomainBlocksFail,
expandDomainBlocks, expandDomainBlocks,
expandDomainBlocksRequest,
expandDomainBlocksSuccess,
expandDomainBlocksFail,
type DomainBlocksAction, type DomainBlocksAction,
}; };

View file

@ -103,11 +103,5 @@ export {
UNEMOJI_REACT_FAIL, UNEMOJI_REACT_FAIL,
emojiReact, emojiReact,
unEmojiReact, unEmojiReact,
emojiReactRequest,
emojiReactSuccess,
emojiReactFail,
unEmojiReactRequest,
unEmojiReactSuccess,
unEmojiReactFail,
type EmojiReactsAction, type EmojiReactsAction,
}; };

View file

@ -529,41 +529,14 @@ export {
JOINED_EVENTS_FETCH_SUCCESS, JOINED_EVENTS_FETCH_SUCCESS,
JOINED_EVENTS_FETCH_FAIL, JOINED_EVENTS_FETCH_FAIL,
submitEvent, submitEvent,
submitEventRequest,
submitEventSuccess,
submitEventFail,
joinEvent, joinEvent,
joinEventRequest,
joinEventSuccess,
joinEventFail,
leaveEvent, leaveEvent,
leaveEventRequest,
leaveEventSuccess,
leaveEventFail,
fetchEventParticipations, fetchEventParticipations,
fetchEventParticipationsRequest,
fetchEventParticipationsSuccess,
fetchEventParticipationsFail,
expandEventParticipations, expandEventParticipations,
expandEventParticipationsRequest,
expandEventParticipationsSuccess,
expandEventParticipationsFail,
fetchEventParticipationRequests, fetchEventParticipationRequests,
fetchEventParticipationRequestsRequest,
fetchEventParticipationRequestsSuccess,
fetchEventParticipationRequestsFail,
expandEventParticipationRequests, expandEventParticipationRequests,
expandEventParticipationRequestsRequest,
expandEventParticipationRequestsSuccess,
expandEventParticipationRequestsFail,
authorizeEventParticipationRequest, authorizeEventParticipationRequest,
authorizeEventParticipationRequestRequest,
authorizeEventParticipationRequestSuccess,
authorizeEventParticipationRequestFail,
rejectEventParticipationRequest, rejectEventParticipationRequest,
rejectEventParticipationRequestRequest,
rejectEventParticipationRequestSuccess,
rejectEventParticipationRequestFail,
fetchEventIcs, fetchEventIcs,
cancelEventCompose, cancelEventCompose,
initEventEdit, initEventEdit,

View file

@ -193,20 +193,8 @@ export {
ACCOUNT_FAVOURITED_STATUSES_EXPAND_SUCCESS, ACCOUNT_FAVOURITED_STATUSES_EXPAND_SUCCESS,
ACCOUNT_FAVOURITED_STATUSES_EXPAND_FAIL, ACCOUNT_FAVOURITED_STATUSES_EXPAND_FAIL,
fetchFavouritedStatuses, fetchFavouritedStatuses,
fetchFavouritedStatusesRequest,
fetchFavouritedStatusesSuccess,
fetchFavouritedStatusesFail,
expandFavouritedStatuses, expandFavouritedStatuses,
expandFavouritedStatusesRequest,
expandFavouritedStatusesSuccess,
expandFavouritedStatusesFail,
fetchAccountFavouritedStatuses, fetchAccountFavouritedStatuses,
fetchAccountFavouritedStatusesRequest,
fetchAccountFavouritedStatusesSuccess,
fetchAccountFavouritedStatusesFail,
expandAccountFavouritedStatuses, expandAccountFavouritedStatuses,
expandAccountFavouritedStatusesRequest,
expandAccountFavouritedStatusesSuccess,
expandAccountFavouritedStatusesFail,
type FavouritesAction, type FavouritesAction,
}; };

View file

@ -77,6 +77,14 @@ const groupUnblockFail = (groupId: string, accountId: string, error: unknown) =>
error, error,
}); });
type GroupsAction =
| ReturnType<typeof fetchGroupBlocksRequest>
| ReturnType<typeof fetchGroupBlocksSuccess>
| ReturnType<typeof fetchGroupBlocksFail>
| ReturnType<typeof groupUnblockRequest>
| ReturnType<typeof groupUnblockSuccess>
| ReturnType<typeof groupUnblockFail>
export { export {
GROUP_BLOCKS_FETCH_REQUEST, GROUP_BLOCKS_FETCH_REQUEST,
GROUP_BLOCKS_FETCH_SUCCESS, GROUP_BLOCKS_FETCH_SUCCESS,
@ -86,11 +94,6 @@ export {
GROUP_UNBLOCK_FAIL, GROUP_UNBLOCK_FAIL,
groupKick, groupKick,
fetchGroupBlocks, fetchGroupBlocks,
fetchGroupBlocksRequest,
fetchGroupBlocksSuccess,
fetchGroupBlocksFail,
groupUnblock, groupUnblock,
groupUnblockRequest, type GroupsAction,
groupUnblockSuccess,
groupUnblockFail,
}; };

View file

@ -47,8 +47,5 @@ export {
HISTORY_FETCH_SUCCESS, HISTORY_FETCH_SUCCESS,
HISTORY_FETCH_FAIL, HISTORY_FETCH_FAIL,
fetchHistory, fetchHistory,
fetchHistoryRequest,
fetchHistorySuccess,
fetchHistoryFail,
type HistoryAction, type HistoryAction,
}; };

View file

@ -770,69 +770,24 @@ export {
reblog, reblog,
unreblog, unreblog,
toggleReblog, toggleReblog,
reblogRequest,
reblogSuccess,
reblogFail,
unreblogRequest,
unreblogSuccess,
unreblogFail,
favourite, favourite,
unfavourite, unfavourite,
toggleFavourite, toggleFavourite,
favouriteRequest,
favouriteSuccess,
favouriteFail,
unfavouriteRequest,
unfavouriteSuccess,
unfavouriteFail,
dislike, dislike,
undislike, undislike,
toggleDislike, toggleDislike,
dislikeRequest,
dislikeSuccess,
dislikeFail,
undislikeRequest,
undislikeSuccess,
undislikeFail,
bookmark, bookmark,
unbookmark, unbookmark,
toggleBookmark, toggleBookmark,
bookmarkRequest,
bookmarkSuccess,
bookmarkFail,
unbookmarkRequest,
unbookmarkSuccess,
unbookmarkFail,
fetchReblogs, fetchReblogs,
fetchReblogsRequest,
fetchReblogsSuccess,
fetchReblogsFail,
expandReblogs, expandReblogs,
fetchFavourites, fetchFavourites,
fetchFavouritesRequest,
fetchFavouritesSuccess,
fetchFavouritesFail,
expandFavourites, expandFavourites,
fetchDislikes, fetchDislikes,
fetchDislikesRequest,
fetchDislikesSuccess,
fetchDislikesFail,
fetchReactions, fetchReactions,
fetchReactionsRequest,
fetchReactionsSuccess,
fetchReactionsFail,
pin, pin,
pinRequest,
pinSuccess,
pinFail,
unpin, unpin,
unpinRequest,
unpinSuccess,
unpinFail,
togglePin, togglePin,
remoteInteraction, remoteInteraction,
remoteInteractionRequest,
remoteInteractionSuccess,
remoteInteractionFail,
type InteractionsAction, type InteractionsAction,
}; };

View file

@ -121,10 +121,18 @@ const submitListEditor = (shouldReset?: boolean) => (dispatch: AppDispatch, getS
} }
}; };
interface ListEditorSetupAction {
type: typeof LIST_EDITOR_SETUP;
list: List;
}
const setupListEditor = (listId: string) => (dispatch: AppDispatch, getState: () => RootState) => { const setupListEditor = (listId: string) => (dispatch: AppDispatch, getState: () => RootState) => {
dispatch({ const list = getState().lists[listId];
if (!list) return;
dispatch<ListEditorSetupAction>({
type: LIST_EDITOR_SETUP, type: LIST_EDITOR_SETUP,
list: getState().lists[listId], list,
}); });
dispatch(fetchListAccounts(listId)); dispatch(fetchListAccounts(listId));
@ -346,10 +354,18 @@ const resetListAdder = () => ({
type: LIST_ADDER_RESET, type: LIST_ADDER_RESET,
}); });
interface ListAdderSetupAction {
type: typeof LIST_ADDER_SETUP;
account: Account;
}
const setupListAdder = (accountId: string) => (dispatch: AppDispatch, getState: () => RootState) => { const setupListAdder = (accountId: string) => (dispatch: AppDispatch, getState: () => RootState) => {
dispatch({ const account = selectAccount(getState(), accountId);
if (!account) return;
dispatch<ListAdderSetupAction>({
type: LIST_ADDER_SETUP, type: LIST_ADDER_SETUP,
account: selectAccount(getState(), accountId), account,
}); });
dispatch(fetchLists()); dispatch(fetchLists());
dispatch(fetchAccountLists(accountId)); dispatch(fetchAccountLists(accountId));
@ -390,6 +406,43 @@ const removeFromListAdder = (listId: string) => (dispatch: AppDispatch, getState
dispatch(removeFromList(listId, getState().listAdder.accountId!)); dispatch(removeFromList(listId, getState().listAdder.accountId!));
}; };
type ListsAction =
| ReturnType<typeof fetchListRequest>
| ReturnType<typeof fetchListSuccess>
| ReturnType<typeof fetchListFail>
| ReturnType<typeof fetchListsRequest>
| ReturnType<typeof fetchListsSuccess>
| ReturnType<typeof fetchListsFail>
| ListEditorSetupAction
| ReturnType<typeof changeListEditorTitle>
| ReturnType<typeof createListRequest>
| ReturnType<typeof createListSuccess>
| ReturnType<typeof createListFail>
| ReturnType<typeof updateListRequest>
| ReturnType<typeof updateListSuccess>
| ReturnType<typeof updateListFail>
| ReturnType<typeof resetListEditor>
| ReturnType<typeof deleteListRequest>
| ReturnType<typeof deleteListSuccess>
| ReturnType<typeof deleteListFail>
| ReturnType<typeof fetchListAccountsRequest>
| ReturnType<typeof fetchListAccountsSuccess>
| ReturnType<typeof fetchListAccountsFail>
| ReturnType<typeof fetchListSuggestionsReady>
| ReturnType<typeof clearListSuggestions>
| ReturnType<typeof changeListSuggestions>
| ReturnType<typeof addToListRequest>
| ReturnType<typeof addToListSuccess>
| ReturnType<typeof addToListFail>
| ReturnType<typeof removeFromListRequest>
| ReturnType<typeof removeFromListSuccess>
| ReturnType<typeof removeFromListFail>
| ReturnType<typeof resetListAdder>
| ListAdderSetupAction
| ReturnType<typeof fetchAccountListsRequest>
| ReturnType<typeof fetchAccountListsSuccess>
| ReturnType<typeof fetchAccountListsFail>;
export { export {
LIST_FETCH_REQUEST, LIST_FETCH_REQUEST,
LIST_FETCH_SUCCESS, LIST_FETCH_SUCCESS,
@ -427,53 +480,27 @@ export {
LIST_ADDER_LISTS_FETCH_SUCCESS, LIST_ADDER_LISTS_FETCH_SUCCESS,
LIST_ADDER_LISTS_FETCH_FAIL, LIST_ADDER_LISTS_FETCH_FAIL,
fetchList, fetchList,
fetchListRequest,
fetchListSuccess,
fetchListFail,
fetchLists, fetchLists,
fetchListsRequest,
fetchListsSuccess,
fetchListsFail,
submitListEditor, submitListEditor,
setupListEditor, setupListEditor,
changeListEditorTitle, changeListEditorTitle,
createList, createList,
createListRequest,
createListSuccess,
createListFail,
updateList, updateList,
updateListRequest,
updateListSuccess,
updateListFail,
resetListEditor, resetListEditor,
deleteList, deleteList,
deleteListRequest,
deleteListSuccess,
deleteListFail,
fetchListAccounts, fetchListAccounts,
fetchListAccountsRequest,
fetchListAccountsSuccess,
fetchListAccountsFail,
fetchListSuggestions, fetchListSuggestions,
fetchListSuggestionsReady, fetchListSuggestionsReady,
clearListSuggestions, clearListSuggestions,
changeListSuggestions, changeListSuggestions,
addToListEditor, addToListEditor,
addToList, addToList,
addToListRequest,
addToListSuccess,
addToListFail,
removeFromListEditor, removeFromListEditor,
removeFromList, removeFromList,
removeFromListRequest,
removeFromListSuccess,
removeFromListFail,
resetListAdder, resetListAdder,
setupListAdder, setupListAdder,
fetchAccountLists, fetchAccountLists,
fetchAccountListsRequest,
fetchAccountListsSuccess,
fetchAccountListsFail,
addToListAdder, addToListAdder,
removeFromListAdder, removeFromListAdder,
type ListsAction,
}; };

View file

@ -158,11 +158,8 @@ export {
ME_PATCH_FAIL, ME_PATCH_FAIL,
fetchMe, fetchMe,
patchMe, patchMe,
fetchMeRequest,
fetchMeSuccess, fetchMeSuccess,
fetchMeFail, fetchMeFail,
patchMeRequest,
patchMeSuccess, patchMeSuccess,
patchMeFail,
type MeAction, type MeAction,
}; };

View file

@ -293,9 +293,6 @@ export {
updateNotifications, updateNotifications,
updateNotificationsQueue, updateNotificationsQueue,
expandNotifications, expandNotifications,
expandNotificationsRequest,
expandNotificationsSuccess,
expandNotificationsFail,
scrollTopNotifications, scrollTopNotifications,
setFilter, setFilter,
markReadNotifications, markReadNotifications,

View file

@ -51,8 +51,5 @@ export {
PINNED_STATUSES_FETCH_SUCCESS, PINNED_STATUSES_FETCH_SUCCESS,
PINNED_STATUSES_FETCH_FAIL, PINNED_STATUSES_FETCH_FAIL,
fetchPinnedStatuses, fetchPinnedStatuses,
fetchPinnedStatusesRequest,
fetchPinnedStatusesSuccess,
fetchPinnedStatusesFail,
type PinStatusesAction, type PinStatusesAction,
}; };

View file

@ -61,6 +61,14 @@ const fetchPollFail = (error: unknown) => ({
error, 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_REQUEST,
POLL_VOTE_SUCCESS, POLL_VOTE_SUCCESS,
@ -70,10 +78,5 @@ export {
POLL_FETCH_FAIL, POLL_FETCH_FAIL,
vote, vote,
fetchPoll, fetchPoll,
voteRequest, type PollsAction,
voteSuccess,
voteFail,
fetchPollRequest,
fetchPollSuccess,
fetchPollFail,
}; };

View file

@ -6,10 +6,6 @@ import type { Account } from 'pl-fe/normalizers/account';
import type { Status } from 'pl-fe/normalizers/status'; import type { Status } from 'pl-fe/normalizers/status';
import type { AppDispatch, RootState } from 'pl-fe/store'; import type { AppDispatch, RootState } from 'pl-fe/store';
const REPORT_SUBMIT_REQUEST = 'REPORT_SUBMIT_REQUEST' as const;
const REPORT_SUBMIT_SUCCESS = 'REPORT_SUBMIT_SUCCESS' as const;
const REPORT_SUBMIT_FAIL = 'REPORT_SUBMIT_FAIL' as const;
enum ReportableEntities { enum ReportableEntities {
ACCOUNT = 'ACCOUNT', ACCOUNT = 'ACCOUNT',
STATUS = 'STATUS' STATUS = 'STATUS'
@ -30,38 +26,15 @@ const initReport = (entityType: ReportableEntities, account: Pick<Account, 'id'>
}; };
const submitReport = (accountId: string, statusIds: string[], ruleIds?: string[], comment?: string, forward?: boolean) => const submitReport = (accountId: string, statusIds: string[], ruleIds?: string[], comment?: string, forward?: boolean) =>
(dispatch: AppDispatch, getState: () => RootState) => { (dispatch: AppDispatch, getState: () => RootState) => getClient(getState()).accounts.reportAccount(accountId, {
dispatch(submitReportRequest()); status_ids: statusIds,
rule_ids: ruleIds,
return getClient(getState()).accounts.reportAccount(accountId, { comment: comment,
status_ids: statusIds, forward: forward,
rule_ids: ruleIds, });
comment: comment,
forward: forward,
});
};
const submitReportRequest = () => ({
type: REPORT_SUBMIT_REQUEST,
});
const submitReportSuccess = () => ({
type: REPORT_SUBMIT_SUCCESS,
});
const submitReportFail = (error: unknown) => ({
type: REPORT_SUBMIT_FAIL,
error,
});
export { export {
ReportableEntities, ReportableEntities,
REPORT_SUBMIT_REQUEST,
REPORT_SUBMIT_SUCCESS,
REPORT_SUBMIT_FAIL,
initReport, initReport,
submitReport, submitReport,
submitReportRequest,
submitReportSuccess,
submitReportFail,
}; };

View file

@ -36,13 +36,29 @@ const fetchScheduledStatuses = () =>
}); });
}; };
interface ScheduledStatusCancelRequestAction {
type: typeof SCHEDULED_STATUS_CANCEL_REQUEST;
statusId: string;
}
interface ScheduledStatusCancelSuccessAction {
type: typeof SCHEDULED_STATUS_CANCEL_SUCCESS;
statusId: string;
}
interface ScheduledStatusCancelFailAction {
type: typeof SCHEDULED_STATUS_CANCEL_FAIL;
statusId: string;
error: unknown;
}
const cancelScheduledStatus = (statusId: string) => const cancelScheduledStatus = (statusId: string) =>
(dispatch: AppDispatch, getState: () => RootState) => { (dispatch: AppDispatch, getState: () => RootState) => {
dispatch({ type: SCHEDULED_STATUS_CANCEL_REQUEST, statusId }); dispatch<ScheduledStatusCancelRequestAction>({ type: SCHEDULED_STATUS_CANCEL_REQUEST, statusId });
return getClient(getState()).scheduledStatuses.cancelScheduledStatus(statusId).then(() => { return getClient(getState()).scheduledStatuses.cancelScheduledStatus(statusId).then(() => {
dispatch({ type: SCHEDULED_STATUS_CANCEL_SUCCESS, statusId }); dispatch<ScheduledStatusCancelSuccessAction>({ type: SCHEDULED_STATUS_CANCEL_SUCCESS, statusId });
}).catch(error => { }).catch(error => {
dispatch({ type: SCHEDULED_STATUS_CANCEL_FAIL, statusId, error }); dispatch<ScheduledStatusCancelFailAction>({ type: SCHEDULED_STATUS_CANCEL_FAIL, statusId, error });
}); });
}; };
@ -93,6 +109,17 @@ const expandScheduledStatusesFail = (error: unknown) => ({
error, error,
}); });
type ScheduledStatusesAction =
| ScheduledStatusCancelRequestAction
| ScheduledStatusCancelSuccessAction
| ScheduledStatusCancelFailAction
| ReturnType<typeof fetchScheduledStatusesRequest>
| ReturnType<typeof fetchScheduledStatusesSuccess>
| ReturnType<typeof fetchScheduledStatusesFail>
| ReturnType<typeof expandScheduledStatusesRequest>
| ReturnType<typeof expandScheduledStatusesSuccess>
| ReturnType<typeof expandScheduledStatusesFail>
export { export {
SCHEDULED_STATUSES_FETCH_REQUEST, SCHEDULED_STATUSES_FETCH_REQUEST,
SCHEDULED_STATUSES_FETCH_SUCCESS, SCHEDULED_STATUSES_FETCH_SUCCESS,
@ -105,11 +132,6 @@ export {
SCHEDULED_STATUS_CANCEL_FAIL, SCHEDULED_STATUS_CANCEL_FAIL,
fetchScheduledStatuses, fetchScheduledStatuses,
cancelScheduledStatus, cancelScheduledStatus,
fetchScheduledStatusesRequest,
fetchScheduledStatusesSuccess,
fetchScheduledStatusesFail,
expandScheduledStatuses, expandScheduledStatuses,
expandScheduledStatusesRequest, type ScheduledStatusesAction,
expandScheduledStatusesSuccess,
expandScheduledStatusesFail,
}; };

View file

@ -190,24 +190,9 @@ export {
FOLLOWED_HASHTAGS_EXPAND_SUCCESS, FOLLOWED_HASHTAGS_EXPAND_SUCCESS,
FOLLOWED_HASHTAGS_EXPAND_FAIL, FOLLOWED_HASHTAGS_EXPAND_FAIL,
fetchHashtag, fetchHashtag,
fetchHashtagRequest,
fetchHashtagSuccess,
fetchHashtagFail,
followHashtag, followHashtag,
followHashtagRequest,
followHashtagSuccess,
followHashtagFail,
unfollowHashtag, unfollowHashtag,
unfollowHashtagRequest,
unfollowHashtagSuccess,
unfollowHashtagFail,
fetchFollowedHashtags, fetchFollowedHashtags,
fetchFollowedHashtagsRequest,
fetchFollowedHashtagsSuccess,
fetchFollowedHashtagsFail,
expandFollowedHashtags, expandFollowedHashtags,
expandFollowedHashtagsRequest,
expandFollowedHashtagsSuccess,
expandFollowedHashtagsFail,
type TagsAction, type TagsAction,
}; };

View file

@ -363,9 +363,7 @@ export {
fetchListTimeline, fetchListTimeline,
fetchGroupTimeline, fetchGroupTimeline,
fetchHashtagTimeline, fetchHashtagTimeline,
expandTimelineRequest,
expandTimelineSuccess, expandTimelineSuccess,
expandTimelineFail,
scrollTopTimeline, scrollTopTimeline,
insertSuggestionsIntoTimeline, insertSuggestionsIntoTimeline,
type TimelineAction, type TimelineAction,

View file

@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
import { blockAccount } from 'pl-fe/actions/accounts'; import { blockAccount } from 'pl-fe/actions/accounts';
import { submitReport, submitReportSuccess, submitReportFail, ReportableEntities } from 'pl-fe/actions/reports'; import { submitReport, ReportableEntities } from 'pl-fe/actions/reports';
import { fetchAccountTimeline } from 'pl-fe/actions/timelines'; import { fetchAccountTimeline } from 'pl-fe/actions/timelines';
import { useAccount } from 'pl-fe/api/hooks/accounts/use-account'; import { useAccount } from 'pl-fe/api/hooks/accounts/use-account';
import AttachmentThumbs from 'pl-fe/components/attachment-thumbs'; import AttachmentThumbs from 'pl-fe/components/attachment-thumbs';
@ -106,7 +106,6 @@ const ReportModal: React.FC<BaseModalProps & ReportModalProps> = ({ onClose, acc
}) })
.catch((error) => { .catch((error) => {
setIsSubmitting(false); setIsSubmitting(false);
dispatch(submitReportFail(error));
}); });
if (block && account) { if (block && account) {
@ -171,7 +170,6 @@ const ReportModal: React.FC<BaseModalProps & ReportModalProps> = ({ onClose, acc
handleSubmit(); handleSubmit();
break; break;
case Steps.THREE: case Steps.THREE:
dispatch(submitReportSuccess());
onClose('REPORT'); onClose('REPORT');
break; break;
default: default:

View file

@ -1,32 +1,9 @@
import type { Account as BaseAccount } from 'pl-api'; import type { Account as BaseAccount } from 'pl-api';
const getDomainFromURL = (account: Pick<BaseAccount, 'url'>): string => {
try {
const url = account.url;
return new URL(url).host;
} catch {
return '';
}
};
const guessFqn = (account: Pick<BaseAccount, 'acct' | 'url'>): string => {
const acct = account.acct;
const [user, domain] = acct.split('@');
if (domain) {
return acct;
} else {
return [user, getDomainFromURL(account)].join('@');
}
};
const normalizeAccount = (account: BaseAccount) => { const normalizeAccount = (account: BaseAccount) => {
const missingAvatar = require('pl-fe/assets/images/avatar-missing.png'); const missingAvatar = require('pl-fe/assets/images/avatar-missing.png');
const missingHeader = require('pl-fe/assets/images/header-missing.png'); const missingHeader = require('pl-fe/assets/images/header-missing.png');
const fqn = account.fqn || guessFqn(account);
const domain = fqn.split('@')[1] || '';
return { return {
mute_expires_at: null, mute_expires_at: null,
...account, ...account,
@ -34,8 +11,6 @@ const normalizeAccount = (account: BaseAccount) => {
avatar_static: account.avatar_static || account.avatar || missingAvatar, avatar_static: account.avatar_static || account.avatar || missingAvatar,
header: account.header || account.header_static || missingHeader, header: account.header || account.header_static || missingHeader,
header_static: account.header_static || account.header || missingHeader, header_static: account.header_static || account.header || missingHeader,
fqn,
domain,
}; };
}; };

View file

@ -8,10 +8,9 @@ import {
LIST_ADDER_LISTS_FETCH_FAIL, LIST_ADDER_LISTS_FETCH_FAIL,
LIST_EDITOR_ADD_SUCCESS, LIST_EDITOR_ADD_SUCCESS,
LIST_EDITOR_REMOVE_SUCCESS, LIST_EDITOR_REMOVE_SUCCESS,
type ListsAction,
} from '../actions/lists'; } from '../actions/lists';
import type { AnyAction } from 'redux';
interface State { interface State {
accountId: string | null; accountId: string | null;
lists: { lists: {
@ -30,7 +29,7 @@ const initialState: State = {
}, },
}; };
const listAdderReducer = (state: State = initialState, action: AnyAction): State => { const listAdderReducer = (state: State = initialState, action: ListsAction): State => {
switch (action.type) { switch (action.type) {
case LIST_ADDER_RESET: case LIST_ADDER_RESET:
return initialState; return initialState;

View file

@ -18,10 +18,9 @@ import {
LIST_EDITOR_SUGGESTIONS_CHANGE, LIST_EDITOR_SUGGESTIONS_CHANGE,
LIST_EDITOR_ADD_SUCCESS, LIST_EDITOR_ADD_SUCCESS,
LIST_EDITOR_REMOVE_SUCCESS, LIST_EDITOR_REMOVE_SUCCESS,
type ListsAction,
} from '../actions/lists'; } from '../actions/lists';
import type { AnyAction } from 'redux';
interface State { interface State {
listId: string | null; listId: string | null;
isSubmitting: boolean; isSubmitting: boolean;
@ -58,7 +57,7 @@ const initialState: State = {
}, },
}; };
const listEditorReducer = (state: State = initialState, action: AnyAction): State => { const listEditorReducer = (state: State = initialState, action: ListsAction): State => {
switch (action.type) { switch (action.type) {
case LIST_EDITOR_RESET: case LIST_EDITOR_RESET:
return initialState; return initialState;
@ -123,7 +122,7 @@ const listEditorReducer = (state: State = initialState, action: AnyAction): Stat
}); });
case LIST_EDITOR_REMOVE_SUCCESS: case LIST_EDITOR_REMOVE_SUCCESS:
return create(state, (draft) => { return create(state, (draft) => {
draft.accounts.items = draft.accounts.items.filter(id => id !== action.accoundId); draft.accounts.items = draft.accounts.items.filter(id => id !== action.accountId);
}); });
default: default:
return state; return state;

View file

@ -7,10 +7,10 @@ import {
LIST_CREATE_SUCCESS, LIST_CREATE_SUCCESS,
LIST_UPDATE_SUCCESS, LIST_UPDATE_SUCCESS,
LIST_DELETE_SUCCESS, LIST_DELETE_SUCCESS,
type ListsAction,
} from 'pl-fe/actions/lists'; } from 'pl-fe/actions/lists';
import type { List } from 'pl-api'; import type { List } from 'pl-api';
import type { AnyAction } from 'redux';
type State = Record<string, List | false>; type State = Record<string, List | false>;
@ -24,7 +24,7 @@ const importLists = (state: State, lists: Array<List>) => {
lists.forEach(list => importList(state, list)); lists.forEach(list => importList(state, list));
}; };
const lists = (state: State = initialState, action: AnyAction) => { const lists = (state: State = initialState, action: ListsAction) => {
switch (action.type) { switch (action.type) {
case LIST_FETCH_SUCCESS: case LIST_FETCH_SUCCESS:
case LIST_CREATE_SUCCESS: case LIST_CREATE_SUCCESS:

View file

@ -5,6 +5,7 @@ import {
SCHEDULED_STATUSES_FETCH_SUCCESS, SCHEDULED_STATUSES_FETCH_SUCCESS,
SCHEDULED_STATUS_CANCEL_REQUEST, SCHEDULED_STATUS_CANCEL_REQUEST,
SCHEDULED_STATUS_CANCEL_SUCCESS, SCHEDULED_STATUS_CANCEL_SUCCESS,
type ScheduledStatusesAction,
} from 'pl-fe/actions/scheduled-statuses'; } from 'pl-fe/actions/scheduled-statuses';
import { STATUS_CREATE_SUCCESS } from 'pl-fe/actions/statuses'; import { STATUS_CREATE_SUCCESS } from 'pl-fe/actions/statuses';
@ -28,7 +29,7 @@ const deleteStatus = (state: State, statusId: string) => {
delete state[statusId]; delete state[statusId];
}; };
const scheduled_statuses = (state: State = initialState, action: AnyAction | ImporterAction) => { const scheduled_statuses = (state: State = initialState, action: AnyAction | ImporterAction | ScheduledStatusesAction) => {
switch (action.type) { switch (action.type) {
case STATUS_IMPORT: case STATUS_IMPORT:
case STATUS_CREATE_SUCCESS: case STATUS_CREATE_SUCCESS:

View file

@ -17,7 +17,7 @@ import {
DIRECTORY_EXPAND_REQUEST, DIRECTORY_EXPAND_REQUEST,
DIRECTORY_EXPAND_SUCCESS, DIRECTORY_EXPAND_SUCCESS,
DIRECTORY_EXPAND_FAIL, DIRECTORY_EXPAND_FAIL,
DirectoryAction, type DirectoryAction,
} from 'pl-fe/actions/directory'; } from 'pl-fe/actions/directory';
import { import {
EVENT_PARTICIPATIONS_EXPAND_SUCCESS, EVENT_PARTICIPATIONS_EXPAND_SUCCESS,
@ -33,6 +33,7 @@ import {
GROUP_BLOCKS_FETCH_SUCCESS, GROUP_BLOCKS_FETCH_SUCCESS,
GROUP_BLOCKS_FETCH_FAIL, GROUP_BLOCKS_FETCH_FAIL,
GROUP_UNBLOCK_SUCCESS, GROUP_UNBLOCK_SUCCESS,
type GroupsAction,
} from 'pl-fe/actions/groups'; } from 'pl-fe/actions/groups';
import { import {
REBLOGS_FETCH_SUCCESS, REBLOGS_FETCH_SUCCESS,
@ -41,7 +42,7 @@ import {
FAVOURITES_EXPAND_SUCCESS, FAVOURITES_EXPAND_SUCCESS,
DISLIKES_FETCH_SUCCESS, DISLIKES_FETCH_SUCCESS,
REACTIONS_FETCH_SUCCESS, REACTIONS_FETCH_SUCCESS,
InteractionsAction, type InteractionsAction,
} from 'pl-fe/actions/interactions'; } from 'pl-fe/actions/interactions';
import { NOTIFICATIONS_UPDATE, type NotificationsAction } from 'pl-fe/actions/notifications'; import { NOTIFICATIONS_UPDATE, type NotificationsAction } from 'pl-fe/actions/notifications';
@ -157,7 +158,7 @@ const normalizeFollowRequest = (state: State, notification: Notification) =>
draft.follow_requests.items = [...new Set([notification.account.id, ...draft.follow_requests.items])]; draft.follow_requests.items = [...new Set([notification.account.id, ...draft.follow_requests.items])];
}); });
const userLists = (state = initialState, action: AccountsAction | DirectoryAction | InteractionsAction | NotificationsAction | AnyAction): State => { const userLists = (state = initialState, action: AccountsAction | DirectoryAction | GroupsAction | InteractionsAction | NotificationsAction | AnyAction): State => {
switch (action.type) { switch (action.type) {
case REBLOGS_FETCH_SUCCESS: case REBLOGS_FETCH_SUCCESS:
return normalizeList(state, ['reblogged_by', action.statusId], action.accounts, action.next); return normalizeList(state, ['reblogged_by', action.statusId], action.accounts, action.next);