diff --git a/packages/pl-fe/src/actions/accounts.ts b/packages/pl-fe/src/actions/accounts.ts index b11d75e25..d9de3e7f0 100644 --- a/packages/pl-fe/src/actions/accounts.ts +++ b/packages/pl-fe/src/actions/accounts.ts @@ -700,44 +700,20 @@ export { createAccount, fetchAccount, fetchAccountByUsername, - fetchAccountRequest, - fetchAccountSuccess, - fetchAccountFail, blockAccount, unblockAccount, - blockAccountRequest, - blockAccountSuccess, - blockAccountFail, muteAccount, unmuteAccount, - muteAccountRequest, - muteAccountSuccess, - muteAccountFail, removeFromFollowers, fetchRelationships, fetchFollowRequests, - fetchFollowRequestsRequest, - fetchFollowRequestsSuccess, - fetchFollowRequestsFail, expandFollowRequests, - expandFollowRequestsRequest, - expandFollowRequestsSuccess, - expandFollowRequestsFail, authorizeFollowRequest, - authorizeFollowRequestRequest, - authorizeFollowRequestSuccess, - authorizeFollowRequestFail, rejectFollowRequest, - rejectFollowRequestRequest, - rejectFollowRequestSuccess, - rejectFollowRequestFail, pinAccount, unpinAccount, updateNotificationSettings, fetchPinnedAccounts, - fetchPinnedAccountsRequest, - fetchPinnedAccountsSuccess, - fetchPinnedAccountsFail, accountSearch, accountLookup, fetchBirthdayReminders, diff --git a/packages/pl-fe/src/actions/aliases.ts b/packages/pl-fe/src/actions/aliases.ts index f516add23..764363007 100644 --- a/packages/pl-fe/src/actions/aliases.ts +++ b/packages/pl-fe/src/actions/aliases.ts @@ -93,7 +93,7 @@ const addToAliases = (account: Account) => dispatch(addToAliasesSuccess); dispatch(fetchAliases); }) - .catch(err => dispatch(fetchAliasesFail(err))); + .catch(err => dispatch(addToAliasesFail(err))); }; const addToAliasesRequest = () => ({ @@ -112,13 +112,13 @@ const addToAliasesFail = (error: unknown) => ({ const removeFromAliases = (account: string) => (dispatch: AppDispatch, getState: () => RootState) => { if (!isLoggedIn(getState)) return; - dispatch(addToAliasesRequest()); + dispatch(removeFromAliasesRequest()); return getClient(getState).settings.deleteAccountAlias(account).then(() => { toast.success(messages.removeSuccess); dispatch(removeFromAliasesSuccess); dispatch(fetchAliases); - }).catch(err => dispatch(fetchAliasesFail(err))); + }).catch(err => dispatch(removeFromAliasesFail(err))); }; const removeFromAliasesRequest = () => ({ @@ -162,20 +162,11 @@ export { ALIASES_REMOVE_SUCCESS, ALIASES_REMOVE_FAIL, fetchAliases, - fetchAliasesRequest, - fetchAliasesSuccess, - fetchAliasesFail, fetchAliasesSuggestions, fetchAliasesSuggestionsReady, clearAliasesSuggestions, changeAliasesSuggestions, addToAliases, - addToAliasesRequest, - addToAliasesSuccess, - addToAliasesFail, removeFromAliases, - removeFromAliasesRequest, - removeFromAliasesSuccess, - removeFromAliasesFail, type AliasesAction, }; diff --git a/packages/pl-fe/src/actions/bookmarks.ts b/packages/pl-fe/src/actions/bookmarks.ts index 2e1f66d37..54b56ef75 100644 --- a/packages/pl-fe/src/actions/bookmarks.ts +++ b/packages/pl-fe/src/actions/bookmarks.ts @@ -102,12 +102,6 @@ export { BOOKMARKED_STATUSES_EXPAND_SUCCESS, BOOKMARKED_STATUSES_EXPAND_FAIL, fetchBookmarkedStatuses, - fetchBookmarkedStatusesRequest, - fetchBookmarkedStatusesSuccess, - fetchBookmarkedStatusesFail, expandBookmarkedStatuses, - expandBookmarkedStatusesRequest, - expandBookmarkedStatusesSuccess, - expandBookmarkedStatusesFail, type BookmarksAction, }; diff --git a/packages/pl-fe/src/actions/compose.ts b/packages/pl-fe/src/actions/compose.ts index 0f0f8bd79..48faabe45 100644 --- a/packages/pl-fe/src/actions/compose.ts +++ b/packages/pl-fe/src/actions/compose.ts @@ -1058,19 +1058,10 @@ export { directComposeById, handleComposeSubmit, submitCompose, - submitComposeRequest, - submitComposeSuccess, - submitComposeFail, uploadFile, uploadCompose, changeUploadCompose, - changeUploadComposeRequest, - changeUploadComposeSuccess, - changeUploadComposeFail, - uploadComposeRequest, - uploadComposeProgress, uploadComposeSuccess, - uploadComposeFail, undoUploadCompose, groupCompose, groupComposeModal, diff --git a/packages/pl-fe/src/actions/conversations.ts b/packages/pl-fe/src/actions/conversations.ts index ae273676f..b7b1b7c9e 100644 --- a/packages/pl-fe/src/actions/conversations.ts +++ b/packages/pl-fe/src/actions/conversations.ts @@ -114,9 +114,6 @@ export { unmountConversations, markConversationRead, expandConversations, - expandConversationsRequest, - expandConversationsSuccess, - expandConversationsFail, updateConversations, type ConversationsAction, }; diff --git a/packages/pl-fe/src/actions/custom-emojis.ts b/packages/pl-fe/src/actions/custom-emojis.ts index f5733b8fc..ba1151a8c 100644 --- a/packages/pl-fe/src/actions/custom-emojis.ts +++ b/packages/pl-fe/src/actions/custom-emojis.ts @@ -45,8 +45,5 @@ export { CUSTOM_EMOJIS_FETCH_SUCCESS, CUSTOM_EMOJIS_FETCH_FAIL, fetchCustomEmojis, - fetchCustomEmojisRequest, - fetchCustomEmojisSuccess, - fetchCustomEmojisFail, type CustomEmojisAction, }; diff --git a/packages/pl-fe/src/actions/directory.ts b/packages/pl-fe/src/actions/directory.ts index 11acd887f..874b4590a 100644 --- a/packages/pl-fe/src/actions/directory.ts +++ b/packages/pl-fe/src/actions/directory.ts @@ -82,12 +82,6 @@ export { DIRECTORY_EXPAND_SUCCESS, DIRECTORY_EXPAND_FAIL, fetchDirectory, - fetchDirectoryRequest, - fetchDirectorySuccess, - fetchDirectoryFail, expandDirectory, - expandDirectoryRequest, - expandDirectorySuccess, - expandDirectoryFail, type DirectoryAction, }; diff --git a/packages/pl-fe/src/actions/domain-blocks.ts b/packages/pl-fe/src/actions/domain-blocks.ts index 80007cce7..439801b06 100644 --- a/packages/pl-fe/src/actions/domain-blocks.ts +++ b/packages/pl-fe/src/actions/domain-blocks.ts @@ -193,20 +193,8 @@ export { DOMAIN_BLOCKS_EXPAND_SUCCESS, DOMAIN_BLOCKS_EXPAND_FAIL, blockDomain, - blockDomainRequest, - blockDomainSuccess, - blockDomainFail, unblockDomain, - unblockDomainRequest, - unblockDomainSuccess, - unblockDomainFail, fetchDomainBlocks, - fetchDomainBlocksRequest, - fetchDomainBlocksSuccess, - fetchDomainBlocksFail, expandDomainBlocks, - expandDomainBlocksRequest, - expandDomainBlocksSuccess, - expandDomainBlocksFail, type DomainBlocksAction, }; diff --git a/packages/pl-fe/src/actions/emoji-reacts.ts b/packages/pl-fe/src/actions/emoji-reacts.ts index a98a021f1..5d5bb83c3 100644 --- a/packages/pl-fe/src/actions/emoji-reacts.ts +++ b/packages/pl-fe/src/actions/emoji-reacts.ts @@ -103,11 +103,5 @@ export { UNEMOJI_REACT_FAIL, emojiReact, unEmojiReact, - emojiReactRequest, - emojiReactSuccess, - emojiReactFail, - unEmojiReactRequest, - unEmojiReactSuccess, - unEmojiReactFail, type EmojiReactsAction, }; diff --git a/packages/pl-fe/src/actions/events.ts b/packages/pl-fe/src/actions/events.ts index 4fb518f12..ce98a8525 100644 --- a/packages/pl-fe/src/actions/events.ts +++ b/packages/pl-fe/src/actions/events.ts @@ -529,41 +529,14 @@ export { JOINED_EVENTS_FETCH_SUCCESS, JOINED_EVENTS_FETCH_FAIL, submitEvent, - submitEventRequest, - submitEventSuccess, - submitEventFail, joinEvent, - joinEventRequest, - joinEventSuccess, - joinEventFail, leaveEvent, - leaveEventRequest, - leaveEventSuccess, - leaveEventFail, fetchEventParticipations, - fetchEventParticipationsRequest, - fetchEventParticipationsSuccess, - fetchEventParticipationsFail, expandEventParticipations, - expandEventParticipationsRequest, - expandEventParticipationsSuccess, - expandEventParticipationsFail, fetchEventParticipationRequests, - fetchEventParticipationRequestsRequest, - fetchEventParticipationRequestsSuccess, - fetchEventParticipationRequestsFail, expandEventParticipationRequests, - expandEventParticipationRequestsRequest, - expandEventParticipationRequestsSuccess, - expandEventParticipationRequestsFail, authorizeEventParticipationRequest, - authorizeEventParticipationRequestRequest, - authorizeEventParticipationRequestSuccess, - authorizeEventParticipationRequestFail, rejectEventParticipationRequest, - rejectEventParticipationRequestRequest, - rejectEventParticipationRequestSuccess, - rejectEventParticipationRequestFail, fetchEventIcs, cancelEventCompose, initEventEdit, diff --git a/packages/pl-fe/src/actions/favourites.ts b/packages/pl-fe/src/actions/favourites.ts index 4cf82a1aa..81f9f9dd8 100644 --- a/packages/pl-fe/src/actions/favourites.ts +++ b/packages/pl-fe/src/actions/favourites.ts @@ -193,20 +193,8 @@ export { ACCOUNT_FAVOURITED_STATUSES_EXPAND_SUCCESS, ACCOUNT_FAVOURITED_STATUSES_EXPAND_FAIL, fetchFavouritedStatuses, - fetchFavouritedStatusesRequest, - fetchFavouritedStatusesSuccess, - fetchFavouritedStatusesFail, expandFavouritedStatuses, - expandFavouritedStatusesRequest, - expandFavouritedStatusesSuccess, - expandFavouritedStatusesFail, fetchAccountFavouritedStatuses, - fetchAccountFavouritedStatusesRequest, - fetchAccountFavouritedStatusesSuccess, - fetchAccountFavouritedStatusesFail, expandAccountFavouritedStatuses, - expandAccountFavouritedStatusesRequest, - expandAccountFavouritedStatusesSuccess, - expandAccountFavouritedStatusesFail, type FavouritesAction, }; diff --git a/packages/pl-fe/src/actions/groups.ts b/packages/pl-fe/src/actions/groups.ts index 23686e258..a1cbb49df 100644 --- a/packages/pl-fe/src/actions/groups.ts +++ b/packages/pl-fe/src/actions/groups.ts @@ -77,6 +77,14 @@ const groupUnblockFail = (groupId: string, accountId: string, error: unknown) => error, }); +type GroupsAction = + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + export { GROUP_BLOCKS_FETCH_REQUEST, GROUP_BLOCKS_FETCH_SUCCESS, @@ -86,11 +94,6 @@ export { GROUP_UNBLOCK_FAIL, groupKick, fetchGroupBlocks, - fetchGroupBlocksRequest, - fetchGroupBlocksSuccess, - fetchGroupBlocksFail, groupUnblock, - groupUnblockRequest, - groupUnblockSuccess, - groupUnblockFail, + type GroupsAction, }; diff --git a/packages/pl-fe/src/actions/history.ts b/packages/pl-fe/src/actions/history.ts index 5bb0bec59..25190ef49 100644 --- a/packages/pl-fe/src/actions/history.ts +++ b/packages/pl-fe/src/actions/history.ts @@ -47,8 +47,5 @@ export { HISTORY_FETCH_SUCCESS, HISTORY_FETCH_FAIL, fetchHistory, - fetchHistoryRequest, - fetchHistorySuccess, - fetchHistoryFail, type HistoryAction, }; diff --git a/packages/pl-fe/src/actions/interactions.ts b/packages/pl-fe/src/actions/interactions.ts index d3fc89b83..cf45cfa33 100644 --- a/packages/pl-fe/src/actions/interactions.ts +++ b/packages/pl-fe/src/actions/interactions.ts @@ -770,69 +770,24 @@ export { reblog, unreblog, toggleReblog, - reblogRequest, - reblogSuccess, - reblogFail, - unreblogRequest, - unreblogSuccess, - unreblogFail, favourite, unfavourite, toggleFavourite, - favouriteRequest, - favouriteSuccess, - favouriteFail, - unfavouriteRequest, - unfavouriteSuccess, - unfavouriteFail, dislike, undislike, toggleDislike, - dislikeRequest, - dislikeSuccess, - dislikeFail, - undislikeRequest, - undislikeSuccess, - undislikeFail, bookmark, unbookmark, toggleBookmark, - bookmarkRequest, - bookmarkSuccess, - bookmarkFail, - unbookmarkRequest, - unbookmarkSuccess, - unbookmarkFail, fetchReblogs, - fetchReblogsRequest, - fetchReblogsSuccess, - fetchReblogsFail, expandReblogs, fetchFavourites, - fetchFavouritesRequest, - fetchFavouritesSuccess, - fetchFavouritesFail, expandFavourites, fetchDislikes, - fetchDislikesRequest, - fetchDislikesSuccess, - fetchDislikesFail, fetchReactions, - fetchReactionsRequest, - fetchReactionsSuccess, - fetchReactionsFail, pin, - pinRequest, - pinSuccess, - pinFail, unpin, - unpinRequest, - unpinSuccess, - unpinFail, togglePin, remoteInteraction, - remoteInteractionRequest, - remoteInteractionSuccess, - remoteInteractionFail, type InteractionsAction, }; diff --git a/packages/pl-fe/src/actions/lists.ts b/packages/pl-fe/src/actions/lists.ts index 40c2e19a0..e1de73e33 100644 --- a/packages/pl-fe/src/actions/lists.ts +++ b/packages/pl-fe/src/actions/lists.ts @@ -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) => { - dispatch({ + const list = getState().lists[listId]; + if (!list) return; + + dispatch({ type: LIST_EDITOR_SETUP, - list: getState().lists[listId], + list, }); dispatch(fetchListAccounts(listId)); @@ -346,10 +354,18 @@ const resetListAdder = () => ({ type: LIST_ADDER_RESET, }); +interface ListAdderSetupAction { + type: typeof LIST_ADDER_SETUP; + account: Account; +} + const setupListAdder = (accountId: string) => (dispatch: AppDispatch, getState: () => RootState) => { - dispatch({ + const account = selectAccount(getState(), accountId); + if (!account) return; + + dispatch({ type: LIST_ADDER_SETUP, - account: selectAccount(getState(), accountId), + account, }); dispatch(fetchLists()); dispatch(fetchAccountLists(accountId)); @@ -390,6 +406,43 @@ const removeFromListAdder = (listId: string) => (dispatch: AppDispatch, getState dispatch(removeFromList(listId, getState().listAdder.accountId!)); }; +type ListsAction = + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ListEditorSetupAction + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ListAdderSetupAction + | ReturnType + | ReturnType + | ReturnType; + export { LIST_FETCH_REQUEST, LIST_FETCH_SUCCESS, @@ -427,53 +480,27 @@ export { LIST_ADDER_LISTS_FETCH_SUCCESS, LIST_ADDER_LISTS_FETCH_FAIL, fetchList, - fetchListRequest, - fetchListSuccess, - fetchListFail, fetchLists, - fetchListsRequest, - fetchListsSuccess, - fetchListsFail, submitListEditor, setupListEditor, changeListEditorTitle, createList, - createListRequest, - createListSuccess, - createListFail, updateList, - updateListRequest, - updateListSuccess, - updateListFail, resetListEditor, deleteList, - deleteListRequest, - deleteListSuccess, - deleteListFail, fetchListAccounts, - fetchListAccountsRequest, - fetchListAccountsSuccess, - fetchListAccountsFail, fetchListSuggestions, fetchListSuggestionsReady, clearListSuggestions, changeListSuggestions, addToListEditor, addToList, - addToListRequest, - addToListSuccess, - addToListFail, removeFromListEditor, removeFromList, - removeFromListRequest, - removeFromListSuccess, - removeFromListFail, resetListAdder, setupListAdder, fetchAccountLists, - fetchAccountListsRequest, - fetchAccountListsSuccess, - fetchAccountListsFail, addToListAdder, removeFromListAdder, + type ListsAction, }; diff --git a/packages/pl-fe/src/actions/me.ts b/packages/pl-fe/src/actions/me.ts index 15d3dbe44..e33e44955 100644 --- a/packages/pl-fe/src/actions/me.ts +++ b/packages/pl-fe/src/actions/me.ts @@ -158,11 +158,8 @@ export { ME_PATCH_FAIL, fetchMe, patchMe, - fetchMeRequest, fetchMeSuccess, fetchMeFail, - patchMeRequest, patchMeSuccess, - patchMeFail, type MeAction, }; diff --git a/packages/pl-fe/src/actions/notifications.ts b/packages/pl-fe/src/actions/notifications.ts index 75332b199..30dfdebd0 100644 --- a/packages/pl-fe/src/actions/notifications.ts +++ b/packages/pl-fe/src/actions/notifications.ts @@ -293,9 +293,6 @@ export { updateNotifications, updateNotificationsQueue, expandNotifications, - expandNotificationsRequest, - expandNotificationsSuccess, - expandNotificationsFail, scrollTopNotifications, setFilter, markReadNotifications, diff --git a/packages/pl-fe/src/actions/pin-statuses.ts b/packages/pl-fe/src/actions/pin-statuses.ts index f1e61bfc0..37a27b648 100644 --- a/packages/pl-fe/src/actions/pin-statuses.ts +++ b/packages/pl-fe/src/actions/pin-statuses.ts @@ -51,8 +51,5 @@ export { PINNED_STATUSES_FETCH_SUCCESS, PINNED_STATUSES_FETCH_FAIL, fetchPinnedStatuses, - fetchPinnedStatusesRequest, - fetchPinnedStatusesSuccess, - fetchPinnedStatusesFail, type PinStatusesAction, }; diff --git a/packages/pl-fe/src/actions/polls.ts b/packages/pl-fe/src/actions/polls.ts index e7311edc7..0f3780c03 100644 --- a/packages/pl-fe/src/actions/polls.ts +++ b/packages/pl-fe/src/actions/polls.ts @@ -61,6 +61,14 @@ const fetchPollFail = (error: unknown) => ({ error, }); +type PollsAction = + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType; + export { POLL_VOTE_REQUEST, POLL_VOTE_SUCCESS, @@ -70,10 +78,5 @@ export { POLL_FETCH_FAIL, vote, fetchPoll, - voteRequest, - voteSuccess, - voteFail, - fetchPollRequest, - fetchPollSuccess, - fetchPollFail, + type PollsAction, }; diff --git a/packages/pl-fe/src/actions/reports.ts b/packages/pl-fe/src/actions/reports.ts index fa59e0833..acc9be787 100644 --- a/packages/pl-fe/src/actions/reports.ts +++ b/packages/pl-fe/src/actions/reports.ts @@ -6,10 +6,6 @@ import type { Account } from 'pl-fe/normalizers/account'; import type { Status } from 'pl-fe/normalizers/status'; 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 { ACCOUNT = 'ACCOUNT', STATUS = 'STATUS' @@ -30,38 +26,15 @@ const initReport = (entityType: ReportableEntities, account: Pick }; const submitReport = (accountId: string, statusIds: string[], ruleIds?: string[], comment?: string, forward?: boolean) => - (dispatch: AppDispatch, getState: () => RootState) => { - dispatch(submitReportRequest()); - - return getClient(getState()).accounts.reportAccount(accountId, { - status_ids: statusIds, - 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, -}); + (dispatch: AppDispatch, getState: () => RootState) => getClient(getState()).accounts.reportAccount(accountId, { + status_ids: statusIds, + rule_ids: ruleIds, + comment: comment, + forward: forward, + }); export { ReportableEntities, - REPORT_SUBMIT_REQUEST, - REPORT_SUBMIT_SUCCESS, - REPORT_SUBMIT_FAIL, initReport, submitReport, - submitReportRequest, - submitReportSuccess, - submitReportFail, }; diff --git a/packages/pl-fe/src/actions/scheduled-statuses.ts b/packages/pl-fe/src/actions/scheduled-statuses.ts index 0df595913..c0d27fe3a 100644 --- a/packages/pl-fe/src/actions/scheduled-statuses.ts +++ b/packages/pl-fe/src/actions/scheduled-statuses.ts @@ -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) => (dispatch: AppDispatch, getState: () => RootState) => { - dispatch({ type: SCHEDULED_STATUS_CANCEL_REQUEST, statusId }); + dispatch({ type: SCHEDULED_STATUS_CANCEL_REQUEST, statusId }); return getClient(getState()).scheduledStatuses.cancelScheduledStatus(statusId).then(() => { - dispatch({ type: SCHEDULED_STATUS_CANCEL_SUCCESS, statusId }); + dispatch({ type: SCHEDULED_STATUS_CANCEL_SUCCESS, statusId }); }).catch(error => { - dispatch({ type: SCHEDULED_STATUS_CANCEL_FAIL, statusId, error }); + dispatch({ type: SCHEDULED_STATUS_CANCEL_FAIL, statusId, error }); }); }; @@ -93,6 +109,17 @@ const expandScheduledStatusesFail = (error: unknown) => ({ error, }); +type ScheduledStatusesAction = + | ScheduledStatusCancelRequestAction + | ScheduledStatusCancelSuccessAction + | ScheduledStatusCancelFailAction + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + | ReturnType + export { SCHEDULED_STATUSES_FETCH_REQUEST, SCHEDULED_STATUSES_FETCH_SUCCESS, @@ -105,11 +132,6 @@ export { SCHEDULED_STATUS_CANCEL_FAIL, fetchScheduledStatuses, cancelScheduledStatus, - fetchScheduledStatusesRequest, - fetchScheduledStatusesSuccess, - fetchScheduledStatusesFail, expandScheduledStatuses, - expandScheduledStatusesRequest, - expandScheduledStatusesSuccess, - expandScheduledStatusesFail, + type ScheduledStatusesAction, }; diff --git a/packages/pl-fe/src/actions/tags.ts b/packages/pl-fe/src/actions/tags.ts index f3add63e7..f642f5d05 100644 --- a/packages/pl-fe/src/actions/tags.ts +++ b/packages/pl-fe/src/actions/tags.ts @@ -190,24 +190,9 @@ export { FOLLOWED_HASHTAGS_EXPAND_SUCCESS, FOLLOWED_HASHTAGS_EXPAND_FAIL, fetchHashtag, - fetchHashtagRequest, - fetchHashtagSuccess, - fetchHashtagFail, followHashtag, - followHashtagRequest, - followHashtagSuccess, - followHashtagFail, unfollowHashtag, - unfollowHashtagRequest, - unfollowHashtagSuccess, - unfollowHashtagFail, fetchFollowedHashtags, - fetchFollowedHashtagsRequest, - fetchFollowedHashtagsSuccess, - fetchFollowedHashtagsFail, expandFollowedHashtags, - expandFollowedHashtagsRequest, - expandFollowedHashtagsSuccess, - expandFollowedHashtagsFail, type TagsAction, }; diff --git a/packages/pl-fe/src/actions/timelines.ts b/packages/pl-fe/src/actions/timelines.ts index 4409eff02..287c3425f 100644 --- a/packages/pl-fe/src/actions/timelines.ts +++ b/packages/pl-fe/src/actions/timelines.ts @@ -363,9 +363,7 @@ export { fetchListTimeline, fetchGroupTimeline, fetchHashtagTimeline, - expandTimelineRequest, expandTimelineSuccess, - expandTimelineFail, scrollTopTimeline, insertSuggestionsIntoTimeline, type TimelineAction, diff --git a/packages/pl-fe/src/features/ui/components/modals/report-modal/index.tsx b/packages/pl-fe/src/features/ui/components/modals/report-modal/index.tsx index f0d22645e..e949a7b9f 100644 --- a/packages/pl-fe/src/features/ui/components/modals/report-modal/index.tsx +++ b/packages/pl-fe/src/features/ui/components/modals/report-modal/index.tsx @@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; 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 { useAccount } from 'pl-fe/api/hooks/accounts/use-account'; import AttachmentThumbs from 'pl-fe/components/attachment-thumbs'; @@ -106,7 +106,6 @@ const ReportModal: React.FC = ({ onClose, acc }) .catch((error) => { setIsSubmitting(false); - dispatch(submitReportFail(error)); }); if (block && account) { @@ -171,7 +170,6 @@ const ReportModal: React.FC = ({ onClose, acc handleSubmit(); break; case Steps.THREE: - dispatch(submitReportSuccess()); onClose('REPORT'); break; default: diff --git a/packages/pl-fe/src/normalizers/account.ts b/packages/pl-fe/src/normalizers/account.ts index e7661285f..85149a07e 100644 --- a/packages/pl-fe/src/normalizers/account.ts +++ b/packages/pl-fe/src/normalizers/account.ts @@ -1,32 +1,9 @@ import type { Account as BaseAccount } from 'pl-api'; -const getDomainFromURL = (account: Pick): string => { - try { - const url = account.url; - return new URL(url).host; - } catch { - return ''; - } -}; - -const guessFqn = (account: Pick): 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 missingAvatar = require('pl-fe/assets/images/avatar-missing.png'); const missingHeader = require('pl-fe/assets/images/header-missing.png'); - const fqn = account.fqn || guessFqn(account); - const domain = fqn.split('@')[1] || ''; - return { mute_expires_at: null, ...account, @@ -34,8 +11,6 @@ const normalizeAccount = (account: BaseAccount) => { avatar_static: account.avatar_static || account.avatar || missingAvatar, header: account.header || account.header_static || missingHeader, header_static: account.header_static || account.header || missingHeader, - fqn, - domain, }; }; diff --git a/packages/pl-fe/src/reducers/list-adder.ts b/packages/pl-fe/src/reducers/list-adder.ts index e69b87baf..4bf55e1a1 100644 --- a/packages/pl-fe/src/reducers/list-adder.ts +++ b/packages/pl-fe/src/reducers/list-adder.ts @@ -8,10 +8,9 @@ import { LIST_ADDER_LISTS_FETCH_FAIL, LIST_EDITOR_ADD_SUCCESS, LIST_EDITOR_REMOVE_SUCCESS, + type ListsAction, } from '../actions/lists'; -import type { AnyAction } from 'redux'; - interface State { accountId: string | null; 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) { case LIST_ADDER_RESET: return initialState; diff --git a/packages/pl-fe/src/reducers/list-editor.ts b/packages/pl-fe/src/reducers/list-editor.ts index 8a9a21997..635c55e98 100644 --- a/packages/pl-fe/src/reducers/list-editor.ts +++ b/packages/pl-fe/src/reducers/list-editor.ts @@ -18,10 +18,9 @@ import { LIST_EDITOR_SUGGESTIONS_CHANGE, LIST_EDITOR_ADD_SUCCESS, LIST_EDITOR_REMOVE_SUCCESS, + type ListsAction, } from '../actions/lists'; -import type { AnyAction } from 'redux'; - interface State { listId: string | null; 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) { case LIST_EDITOR_RESET: return initialState; @@ -123,7 +122,7 @@ const listEditorReducer = (state: State = initialState, action: AnyAction): Stat }); case LIST_EDITOR_REMOVE_SUCCESS: 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: return state; diff --git a/packages/pl-fe/src/reducers/lists.ts b/packages/pl-fe/src/reducers/lists.ts index 87c89646f..895d8903c 100644 --- a/packages/pl-fe/src/reducers/lists.ts +++ b/packages/pl-fe/src/reducers/lists.ts @@ -7,10 +7,10 @@ import { LIST_CREATE_SUCCESS, LIST_UPDATE_SUCCESS, LIST_DELETE_SUCCESS, + type ListsAction, } from 'pl-fe/actions/lists'; import type { List } from 'pl-api'; -import type { AnyAction } from 'redux'; type State = Record; @@ -24,7 +24,7 @@ const importLists = (state: State, lists: Array) => { lists.forEach(list => importList(state, list)); }; -const lists = (state: State = initialState, action: AnyAction) => { +const lists = (state: State = initialState, action: ListsAction) => { switch (action.type) { case LIST_FETCH_SUCCESS: case LIST_CREATE_SUCCESS: diff --git a/packages/pl-fe/src/reducers/scheduled-statuses.ts b/packages/pl-fe/src/reducers/scheduled-statuses.ts index 0d7424bab..8bc7d3ccb 100644 --- a/packages/pl-fe/src/reducers/scheduled-statuses.ts +++ b/packages/pl-fe/src/reducers/scheduled-statuses.ts @@ -5,6 +5,7 @@ import { SCHEDULED_STATUSES_FETCH_SUCCESS, SCHEDULED_STATUS_CANCEL_REQUEST, SCHEDULED_STATUS_CANCEL_SUCCESS, + type ScheduledStatusesAction, } from 'pl-fe/actions/scheduled-statuses'; import { STATUS_CREATE_SUCCESS } from 'pl-fe/actions/statuses'; @@ -28,7 +29,7 @@ const deleteStatus = (state: State, statusId: string) => { 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) { case STATUS_IMPORT: case STATUS_CREATE_SUCCESS: diff --git a/packages/pl-fe/src/reducers/user-lists.ts b/packages/pl-fe/src/reducers/user-lists.ts index 712d96f4a..cafdf8ddc 100644 --- a/packages/pl-fe/src/reducers/user-lists.ts +++ b/packages/pl-fe/src/reducers/user-lists.ts @@ -17,7 +17,7 @@ import { DIRECTORY_EXPAND_REQUEST, DIRECTORY_EXPAND_SUCCESS, DIRECTORY_EXPAND_FAIL, - DirectoryAction, + type DirectoryAction, } from 'pl-fe/actions/directory'; import { EVENT_PARTICIPATIONS_EXPAND_SUCCESS, @@ -33,6 +33,7 @@ import { GROUP_BLOCKS_FETCH_SUCCESS, GROUP_BLOCKS_FETCH_FAIL, GROUP_UNBLOCK_SUCCESS, + type GroupsAction, } from 'pl-fe/actions/groups'; import { REBLOGS_FETCH_SUCCESS, @@ -41,7 +42,7 @@ import { FAVOURITES_EXPAND_SUCCESS, DISLIKES_FETCH_SUCCESS, REACTIONS_FETCH_SUCCESS, - InteractionsAction, + type InteractionsAction, } from 'pl-fe/actions/interactions'; 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])]; }); -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) { case REBLOGS_FETCH_SUCCESS: return normalizeList(state, ['reblogged_by', action.statusId], action.accounts, action.next);