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,
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,

View file

@ -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,
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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,
};

View file

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

View file

@ -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,

View file

@ -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,
};

View file

@ -77,6 +77,14 @@ const groupUnblockFail = (groupId: string, accountId: string, error: unknown) =>
error,
});
type GroupsAction =
| ReturnType<typeof fetchGroupBlocksRequest>
| ReturnType<typeof fetchGroupBlocksSuccess>
| ReturnType<typeof fetchGroupBlocksFail>
| ReturnType<typeof groupUnblockRequest>
| ReturnType<typeof groupUnblockSuccess>
| ReturnType<typeof groupUnblockFail>
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,
};

View file

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

View file

@ -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,
};

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) => {
dispatch({
const list = getState().lists[listId];
if (!list) return;
dispatch<ListEditorSetupAction>({
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<ListAdderSetupAction>({
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<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 {
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,
};

View file

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

View file

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

View file

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

View file

@ -61,6 +61,14 @@ const fetchPollFail = (error: unknown) => ({
error,
});
type PollsAction =
| ReturnType<typeof voteRequest>
| ReturnType<typeof voteSuccess>
| ReturnType<typeof voteFail>
| ReturnType<typeof fetchPollRequest>
| ReturnType<typeof fetchPollSuccess>
| ReturnType<typeof fetchPollFail>;
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,
};

View file

@ -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<Account, 'id'>
};
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,
};

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) =>
(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(() => {
dispatch({ type: SCHEDULED_STATUS_CANCEL_SUCCESS, statusId });
dispatch<ScheduledStatusCancelSuccessAction>({ type: SCHEDULED_STATUS_CANCEL_SUCCESS, statusId });
}).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,
});
type ScheduledStatusesAction =
| ScheduledStatusCancelRequestAction
| ScheduledStatusCancelSuccessAction
| ScheduledStatusCancelFailAction
| ReturnType<typeof fetchScheduledStatusesRequest>
| ReturnType<typeof fetchScheduledStatusesSuccess>
| ReturnType<typeof fetchScheduledStatusesFail>
| ReturnType<typeof expandScheduledStatusesRequest>
| ReturnType<typeof expandScheduledStatusesSuccess>
| ReturnType<typeof expandScheduledStatusesFail>
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,
};

View file

@ -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,
};

View file

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

View file

@ -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<BaseModalProps & ReportModalProps> = ({ onClose, acc
})
.catch((error) => {
setIsSubmitting(false);
dispatch(submitReportFail(error));
});
if (block && account) {
@ -171,7 +170,6 @@ const ReportModal: React.FC<BaseModalProps & ReportModalProps> = ({ onClose, acc
handleSubmit();
break;
case Steps.THREE:
dispatch(submitReportSuccess());
onClose('REPORT');
break;
default:

View file

@ -1,32 +1,9 @@
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 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,
};
};

View file

@ -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;

View file

@ -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;

View file

@ -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<string, List | false>;
@ -24,7 +24,7 @@ const importLists = (state: State, lists: Array<List>) => {
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:

View file

@ -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:

View file

@ -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);