pl-fe: remove unused code
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
import { fetchRelationships } from 'pl-fe/actions/accounts';
|
||||
import { importEntities } from 'pl-fe/actions/importer';
|
||||
import { filterBadges, getTagDiff } from 'pl-fe/utils/badges';
|
||||
|
||||
@ -6,7 +5,7 @@ import { getClient } from '../api';
|
||||
|
||||
import { deleteFromTimelines } from './timelines';
|
||||
|
||||
import type { Account, AdminAccount, AdminGetAccountsParams, AdminGetReportsParams, AdminReport, PaginatedResponse, PleromaConfig, Status } from 'pl-api';
|
||||
import type { AdminGetReportsParams, AdminReport, PleromaConfig, Status } from 'pl-api';
|
||||
import type { AppDispatch, RootState } from 'pl-fe/store';
|
||||
|
||||
const ADMIN_CONFIG_FETCH_SUCCESS = 'ADMIN_CONFIG_FETCH_SUCCESS' as const;
|
||||
@ -18,8 +17,6 @@ const ADMIN_REPORTS_FETCH_SUCCESS = 'ADMIN_REPORTS_FETCH_SUCCESS' as const;
|
||||
|
||||
const ADMIN_REPORT_PATCH_SUCCESS = 'ADMIN_REPORT_PATCH_SUCCESS' as const;
|
||||
|
||||
const ADMIN_USERS_FETCH_SUCCESS = 'ADMIN_USERS_FETCH_SUCCESS' as const;
|
||||
|
||||
const ADMIN_USER_DELETE_SUCCESS = 'ADMIN_USER_DELETE_SUCCESS' as const;
|
||||
|
||||
const fetchConfig = () =>
|
||||
@ -68,18 +65,6 @@ const closeReport = (reportId: string) =>
|
||||
return report;
|
||||
});
|
||||
|
||||
const fetchUsers = (params?: AdminGetAccountsParams) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const state = getState();
|
||||
|
||||
return getClient(state).admin.accounts.getAccounts(params).then((res) => {
|
||||
dispatch(importEntities({ accounts: res.items.map(({ account }) => account).filter((account): account is Account => account !== null) }));
|
||||
dispatch(fetchRelationships(res.items.map((account) => account.id)));
|
||||
dispatch<AdminActions>({ type: ADMIN_USERS_FETCH_SUCCESS, users: res.items, params, next: res.next });
|
||||
return res;
|
||||
});
|
||||
};
|
||||
|
||||
const deactivateUser = (accountId: string, report_id?: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const state = getState();
|
||||
@ -162,7 +147,6 @@ type AdminActions =
|
||||
| { type: typeof ADMIN_CONFIG_UPDATE_SUCCESS; configs: PleromaConfig['configs']; needsReboot: boolean }
|
||||
| { type: typeof ADMIN_REPORTS_FETCH_SUCCESS; reports: Array<AdminReport>; params?: AdminGetReportsParams }
|
||||
| { type: typeof ADMIN_REPORT_PATCH_SUCCESS; report: AdminReport; reportId: string }
|
||||
| { type: typeof ADMIN_USERS_FETCH_SUCCESS; users: Array<AdminAccount>; params?: AdminGetAccountsParams; next: (() => Promise<PaginatedResponse<AdminAccount>>) | null }
|
||||
| { type: typeof ADMIN_USER_DELETE_SUCCESS; accountId: string };
|
||||
|
||||
export {
|
||||
@ -171,14 +155,12 @@ export {
|
||||
ADMIN_CONFIG_UPDATE_SUCCESS,
|
||||
ADMIN_REPORTS_FETCH_SUCCESS,
|
||||
ADMIN_REPORT_PATCH_SUCCESS,
|
||||
ADMIN_USERS_FETCH_SUCCESS,
|
||||
ADMIN_USER_DELETE_SUCCESS,
|
||||
fetchConfig,
|
||||
updateConfig,
|
||||
updatePlFeConfig,
|
||||
fetchReports,
|
||||
closeReport,
|
||||
fetchUsers,
|
||||
deactivateUser,
|
||||
deleteUser,
|
||||
deleteStatus,
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import omit from 'lodash/omit';
|
||||
import { create } from 'mutative';
|
||||
|
||||
import {
|
||||
@ -6,20 +5,17 @@ import {
|
||||
ADMIN_CONFIG_UPDATE_SUCCESS,
|
||||
ADMIN_REPORTS_FETCH_SUCCESS,
|
||||
ADMIN_REPORT_PATCH_SUCCESS,
|
||||
ADMIN_USERS_FETCH_SUCCESS,
|
||||
// ADMIN_USER_DELETE_SUCCESS,
|
||||
type AdminActions,
|
||||
} from 'pl-fe/actions/admin';
|
||||
import { normalizeAdminReport, type AdminReport as MinifiedReport } from 'pl-fe/normalizers/admin-report';
|
||||
|
||||
import type { AdminAccount, AdminGetAccountsParams, AdminReport } from 'pl-api';
|
||||
import type { AdminReport } from 'pl-api';
|
||||
import type { Config } from 'pl-fe/utils/config-db';
|
||||
|
||||
interface State {
|
||||
reports: Record<string, MinifiedReport>;
|
||||
openReports: Array<string>;
|
||||
users: Record<string, MinifiedUser>;
|
||||
latestUsers: Array<string>;
|
||||
configs: Array<Config>;
|
||||
needsReboot: boolean;
|
||||
}
|
||||
@ -27,35 +23,10 @@ interface State {
|
||||
const initialState: State = {
|
||||
reports: {},
|
||||
openReports: [],
|
||||
users: {},
|
||||
latestUsers: [],
|
||||
configs: [],
|
||||
needsReboot: false,
|
||||
};
|
||||
|
||||
const toIds = (items: any[]) => items.map(item => item.id);
|
||||
|
||||
const maybeImportLatest = (state: State, users: Array<AdminAccount>, params?: AdminGetAccountsParams) => {
|
||||
if (params?.origin === 'local' && params.status === 'active') {
|
||||
const newIds = toIds(users);
|
||||
state.latestUsers = newIds;
|
||||
}
|
||||
};
|
||||
|
||||
const minifyUser = (user: AdminAccount) => omit(user, ['account']);
|
||||
|
||||
type MinifiedUser = ReturnType<typeof minifyUser>;
|
||||
|
||||
const importUsers = (state: State, users: Array<AdminAccount>, params?: AdminGetAccountsParams) => {
|
||||
// maybeImportUnapproved(state, users, params);
|
||||
maybeImportLatest(state, users, params);
|
||||
|
||||
users.forEach(user => {
|
||||
const normalizedUser = minifyUser(user);
|
||||
state.users[user.id] = normalizedUser;
|
||||
});
|
||||
};
|
||||
|
||||
// const deleteUser = (state: State, accountId: string) => {
|
||||
// state.awaitingApproval = state.awaitingApproval.filter(id => id !== accountId);
|
||||
// delete state.users[accountId];
|
||||
@ -102,8 +73,6 @@ const admin = (state = initialState, action: AdminActions): State => {
|
||||
return create(state, (draft) => importReports(draft, action.reports));
|
||||
case ADMIN_REPORT_PATCH_SUCCESS:
|
||||
return create(state, (draft) => handleReportDiffs(draft, action.report));
|
||||
case ADMIN_USERS_FETCH_SUCCESS:
|
||||
return create(state, (draft) => importUsers(draft, action.users, action.params));
|
||||
// case ADMIN_USER_DELETE_SUCCESS:
|
||||
// return create(state, (draft) => deleteUser(draft, action.accountId));
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user