frontend-rw #1
10 changed files with 45 additions and 647 deletions
|
@ -1,11 +1,8 @@
|
|||
import {
|
||||
PLEROMA,
|
||||
type UpdateNotificationSettingsParams,
|
||||
type Account,
|
||||
type CreateAccountParams,
|
||||
type PlApiClient,
|
||||
type Relationship,
|
||||
type Token,
|
||||
} from 'pl-api';
|
||||
|
||||
import { Entities } from 'pl-fe/entity-store/entities';
|
||||
|
@ -22,33 +19,9 @@ import type { MinifiedStatus } from 'pl-fe/reducers/statuses';
|
|||
import type { AppDispatch, RootState } from 'pl-fe/store';
|
||||
import type { History } from 'pl-fe/types/history';
|
||||
|
||||
const ACCOUNT_CREATE_REQUEST = 'ACCOUNT_CREATE_REQUEST' as const;
|
||||
const ACCOUNT_CREATE_SUCCESS = 'ACCOUNT_CREATE_SUCCESS' as const;
|
||||
const ACCOUNT_CREATE_FAIL = 'ACCOUNT_CREATE_FAIL' as const;
|
||||
|
||||
const ACCOUNT_FETCH_REQUEST = 'ACCOUNT_FETCH_REQUEST' as const;
|
||||
const ACCOUNT_FETCH_SUCCESS = 'ACCOUNT_FETCH_SUCCESS' as const;
|
||||
const ACCOUNT_FETCH_FAIL = 'ACCOUNT_FETCH_FAIL' as const;
|
||||
|
||||
const ACCOUNT_BLOCK_REQUEST = 'ACCOUNT_BLOCK_REQUEST' as const;
|
||||
const ACCOUNT_BLOCK_SUCCESS = 'ACCOUNT_BLOCK_SUCCESS' as const;
|
||||
const ACCOUNT_BLOCK_FAIL = 'ACCOUNT_BLOCK_FAIL' as const;
|
||||
|
||||
const ACCOUNT_MUTE_REQUEST = 'ACCOUNT_MUTE_REQUEST' as const;
|
||||
const ACCOUNT_MUTE_SUCCESS = 'ACCOUNT_MUTE_SUCCESS' as const;
|
||||
const ACCOUNT_MUTE_FAIL = 'ACCOUNT_MUTE_FAIL' as const;
|
||||
|
||||
const ACCOUNT_SEARCH_REQUEST = 'ACCOUNT_SEARCH_REQUEST' as const;
|
||||
const ACCOUNT_SEARCH_SUCCESS = 'ACCOUNT_SEARCH_SUCCESS' as const;
|
||||
const ACCOUNT_SEARCH_FAIL = 'ACCOUNT_SEARCH_FAIL' as const;
|
||||
|
||||
const ACCOUNT_LOOKUP_REQUEST = 'ACCOUNT_LOOKUP_REQUEST' as const;
|
||||
const ACCOUNT_LOOKUP_SUCCESS = 'ACCOUNT_LOOKUP_SUCCESS' as const;
|
||||
const ACCOUNT_LOOKUP_FAIL = 'ACCOUNT_LOOKUP_FAIL' as const;
|
||||
|
||||
const NOTIFICATION_SETTINGS_REQUEST = 'NOTIFICATION_SETTINGS_REQUEST' as const;
|
||||
const NOTIFICATION_SETTINGS_SUCCESS = 'NOTIFICATION_SETTINGS_SUCCESS' as const;
|
||||
const NOTIFICATION_SETTINGS_FAIL = 'NOTIFICATION_SETTINGS_FAIL' as const;
|
||||
|
||||
const maybeRedirectLogin = (error: { response: PlfeResponse }, history?: History) => {
|
||||
// The client is unauthorized - redirect to login.
|
||||
|
@ -59,33 +32,11 @@ const maybeRedirectLogin = (error: { response: PlfeResponse }, history?: History
|
|||
|
||||
const noOp = () => new Promise(f => f(undefined));
|
||||
|
||||
interface AccountCreateRequestAction {
|
||||
type: typeof ACCOUNT_CREATE_REQUEST;
|
||||
params: CreateAccountParams;
|
||||
}
|
||||
|
||||
interface AccountCreateSuccessAction {
|
||||
type: typeof ACCOUNT_CREATE_SUCCESS;
|
||||
params: CreateAccountParams;
|
||||
token: Token;
|
||||
}
|
||||
|
||||
interface AccountCreateFailAction {
|
||||
type: typeof ACCOUNT_CREATE_FAIL;
|
||||
params: CreateAccountParams;
|
||||
error: unknown;
|
||||
}
|
||||
|
||||
const createAccount = (params: CreateAccountParams) =>
|
||||
async (dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch<AccountCreateRequestAction>({ type: ACCOUNT_CREATE_REQUEST, params });
|
||||
return getClient(getState()).settings.createAccount(params).then((token) =>
|
||||
dispatch<AccountCreateSuccessAction>({ type: ACCOUNT_CREATE_SUCCESS, params, token }),
|
||||
).catch(error => {
|
||||
dispatch<AccountCreateFailAction>({ type: ACCOUNT_CREATE_FAIL, error, params });
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
async (dispatch: AppDispatch, getState: () => RootState) =>
|
||||
getClient(getState()).settings.createAccount(params).then((token) =>
|
||||
({ params, token }),
|
||||
);
|
||||
|
||||
const fetchAccount = (accountId: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
|
@ -97,15 +48,11 @@ const fetchAccount = (accountId: string) =>
|
|||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
dispatch(fetchAccountRequest(accountId));
|
||||
|
||||
return getClient(getState()).accounts.getAccount(accountId)
|
||||
.then(response => {
|
||||
dispatch(importEntities({ accounts: [response] }));
|
||||
dispatch(fetchAccountSuccess(response));
|
||||
})
|
||||
.catch(error => {
|
||||
dispatch(fetchAccountFail(accountId, error));
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -118,16 +65,11 @@ const fetchAccountByUsername = (username: string, history?: History) =>
|
|||
return getClient(getState()).accounts.getAccount(username).then(response => {
|
||||
dispatch(fetchRelationships([response.id]));
|
||||
dispatch(importEntities({ accounts: [response] }));
|
||||
dispatch(fetchAccountSuccess(response));
|
||||
}).catch(error => {
|
||||
dispatch(fetchAccountFail(null, error));
|
||||
});
|
||||
} else if (features.accountLookup) {
|
||||
return dispatch(accountLookup(username)).then(account => {
|
||||
dispatch(fetchRelationships([account.id]));
|
||||
dispatch(fetchAccountSuccess(account));
|
||||
}).catch(error => {
|
||||
dispatch(fetchAccountFail(null, error));
|
||||
maybeRedirectLogin(error, history);
|
||||
});
|
||||
} else {
|
||||
|
@ -136,39 +78,17 @@ const fetchAccountByUsername = (username: string, history?: History) =>
|
|||
|
||||
if (found) {
|
||||
dispatch(fetchRelationships([found.id]));
|
||||
dispatch(fetchAccountSuccess(found));
|
||||
} else {
|
||||
throw accounts;
|
||||
}
|
||||
}).catch(error => {
|
||||
dispatch(fetchAccountFail(null, error));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const fetchAccountRequest = (accountId: string) => ({
|
||||
type: ACCOUNT_FETCH_REQUEST,
|
||||
accountId,
|
||||
});
|
||||
|
||||
const fetchAccountSuccess = (account: Account) => ({
|
||||
type: ACCOUNT_FETCH_SUCCESS,
|
||||
account,
|
||||
});
|
||||
|
||||
const fetchAccountFail = (accountId: string | null, error: unknown) => ({
|
||||
type: ACCOUNT_FETCH_FAIL,
|
||||
accountId,
|
||||
error,
|
||||
skipAlert: true,
|
||||
});
|
||||
|
||||
const blockAccount = (accountId: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!isLoggedIn(getState)) return null;
|
||||
|
||||
dispatch(blockAccountRequest(accountId));
|
||||
|
||||
return getClient(getState).filtering.blockAccount(accountId)
|
||||
.then(response => {
|
||||
dispatch(importEntities({ relationships: [response] }));
|
||||
|
@ -179,7 +99,7 @@ const blockAccount = (accountId: string) =>
|
|||
|
||||
// Pass in entire statuses map so we can use it to filter stuff in different parts of the reducers
|
||||
return dispatch(blockAccountSuccess(response, getState().statuses));
|
||||
}).catch(error => dispatch(blockAccountFail(error)));
|
||||
});
|
||||
};
|
||||
|
||||
const unblockAccount = (accountId: string) =>
|
||||
|
@ -192,21 +112,12 @@ const unblockAccount = (accountId: string) =>
|
|||
});
|
||||
};
|
||||
|
||||
const blockAccountRequest = (accountId: string) => ({
|
||||
type: ACCOUNT_BLOCK_REQUEST,
|
||||
accountId,
|
||||
});
|
||||
|
||||
const blockAccountSuccess = (relationship: Relationship, statuses: Record<string, MinifiedStatus>) => ({
|
||||
type: ACCOUNT_BLOCK_SUCCESS,
|
||||
relationship,
|
||||
statuses,
|
||||
});
|
||||
|
||||
const blockAccountFail = (error: unknown) => ({
|
||||
type: ACCOUNT_BLOCK_FAIL,
|
||||
error,
|
||||
});
|
||||
|
||||
const muteAccount = (accountId: string, notifications?: boolean, duration = 0) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
|
@ -214,8 +125,6 @@ const muteAccount = (accountId: string, notifications?: boolean, duration = 0) =
|
|||
|
||||
const client = getClient(getState);
|
||||
|
||||
dispatch(muteAccountRequest(accountId));
|
||||
|
||||
const params: Record<string, any> = {
|
||||
notifications,
|
||||
};
|
||||
|
@ -240,8 +149,7 @@ const muteAccount = (accountId: string, notifications?: boolean, duration = 0) =
|
|||
|
||||
// Pass in entire statuses map so we can use it to filter stuff in different parts of the reducers
|
||||
return dispatch(muteAccountSuccess(response, getState().statuses));
|
||||
})
|
||||
.catch(error => dispatch(muteAccountFail(accountId, error)));
|
||||
});
|
||||
};
|
||||
|
||||
const unmuteAccount = (accountId: string) =>
|
||||
|
@ -252,23 +160,12 @@ const unmuteAccount = (accountId: string) =>
|
|||
.then(response => dispatch(importEntities({ relationships: [response] })));
|
||||
};
|
||||
|
||||
const muteAccountRequest = (accountId: string) => ({
|
||||
type: ACCOUNT_MUTE_REQUEST,
|
||||
accountId,
|
||||
});
|
||||
|
||||
const muteAccountSuccess = (relationship: Relationship, statuses: Record<string, MinifiedStatus>) => ({
|
||||
type: ACCOUNT_MUTE_SUCCESS,
|
||||
relationship,
|
||||
statuses,
|
||||
});
|
||||
|
||||
const muteAccountFail = (accountId: string, error: unknown) => ({
|
||||
type: ACCOUNT_MUTE_FAIL,
|
||||
accountId,
|
||||
error,
|
||||
});
|
||||
|
||||
const removeFromFollowers = (accountId: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!isLoggedIn(getState)) return null;
|
||||
|
@ -310,143 +207,35 @@ const unpinAccount = (accountId: string) =>
|
|||
);
|
||||
};
|
||||
|
||||
interface NotificationSettingsRequestAction {
|
||||
type: typeof NOTIFICATION_SETTINGS_REQUEST;
|
||||
params: UpdateNotificationSettingsParams;
|
||||
}
|
||||
|
||||
interface NotificationSettingsSuccessAction {
|
||||
type: typeof NOTIFICATION_SETTINGS_SUCCESS;
|
||||
params: UpdateNotificationSettingsParams;
|
||||
data: Awaited<ReturnType<(InstanceType<typeof PlApiClient>)['settings']['updateNotificationSettings']>>;
|
||||
}
|
||||
|
||||
interface NotificationSettingsFailAction {
|
||||
type: typeof NOTIFICATION_SETTINGS_FAIL;
|
||||
params: UpdateNotificationSettingsParams;
|
||||
error: unknown;
|
||||
}
|
||||
|
||||
const updateNotificationSettings = (params: UpdateNotificationSettingsParams) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch<NotificationSettingsRequestAction>({ type: NOTIFICATION_SETTINGS_REQUEST, params });
|
||||
return getClient(getState).settings.updateNotificationSettings(params).then((data) => {
|
||||
dispatch<NotificationSettingsSuccessAction>({ type: NOTIFICATION_SETTINGS_SUCCESS, params, data });
|
||||
}).catch(error => {
|
||||
dispatch<NotificationSettingsFailAction>({ type: NOTIFICATION_SETTINGS_FAIL, params, error });
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
|
||||
interface AccountSearchRequestAction {
|
||||
type: typeof ACCOUNT_SEARCH_REQUEST;
|
||||
params: {
|
||||
q: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface AccountSearchSuccessAction {
|
||||
type: typeof ACCOUNT_SEARCH_SUCCESS;
|
||||
accounts: Array<Account>;
|
||||
}
|
||||
|
||||
interface AccountSearchFailAction {
|
||||
type: typeof ACCOUNT_SEARCH_FAIL;
|
||||
skipAlert: true;
|
||||
}
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
getClient(getState).settings.updateNotificationSettings(params).then((data) => ({ params, data }));
|
||||
|
||||
const accountSearch = (q: string, signal?: AbortSignal) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch<AccountSearchRequestAction>({ type: ACCOUNT_SEARCH_REQUEST, params: { q } });
|
||||
return getClient(getState()).accounts.searchAccounts(q, { resolve: false, limit: 4, following: true }, { signal }).then((accounts) => {
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
getClient(getState()).accounts.searchAccounts(q, { resolve: false, limit: 4, following: true }, { signal }).then((accounts) => {
|
||||
dispatch(importEntities({ accounts }));
|
||||
dispatch<AccountSearchSuccessAction>({ type: ACCOUNT_SEARCH_SUCCESS, accounts });
|
||||
return accounts;
|
||||
}).catch(error => {
|
||||
dispatch<AccountSearchFailAction>({ type: ACCOUNT_SEARCH_FAIL, skipAlert: true });
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
|
||||
interface AccountLookupRequestAction {
|
||||
type: typeof ACCOUNT_LOOKUP_REQUEST;
|
||||
acct: string;
|
||||
}
|
||||
|
||||
interface AccountLookupSuccessAction {
|
||||
type: typeof ACCOUNT_LOOKUP_SUCCESS;
|
||||
account: Account;
|
||||
}
|
||||
|
||||
interface AccountLookupFailAction {
|
||||
type: typeof ACCOUNT_LOOKUP_FAIL;
|
||||
}
|
||||
|
||||
const accountLookup = (acct: string, signal?: AbortSignal) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch<AccountLookupRequestAction>({ type: ACCOUNT_LOOKUP_REQUEST, acct });
|
||||
return getClient(getState()).accounts.lookupAccount(acct, { signal }).then((account) => {
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
getClient(getState()).accounts.lookupAccount(acct, { signal }).then((account) => {
|
||||
if (account && account.id) dispatch(importEntities({ accounts: [account] }));
|
||||
dispatch<AccountLookupSuccessAction>({ type: ACCOUNT_LOOKUP_SUCCESS, account });
|
||||
return account;
|
||||
}).catch(error => {
|
||||
dispatch<AccountLookupFailAction>({ type: ACCOUNT_LOOKUP_FAIL });
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
|
||||
const biteAccount = (accountId: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const client = getClient(getState);
|
||||
|
||||
return client.accounts.biteAccount(accountId);
|
||||
};
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
getClient(getState).accounts.biteAccount(accountId);
|
||||
|
||||
type AccountsAction =
|
||||
| AccountCreateRequestAction
|
||||
| AccountCreateSuccessAction
|
||||
| AccountCreateFailAction
|
||||
| ReturnType<typeof fetchAccountRequest>
|
||||
| ReturnType<typeof fetchAccountSuccess>
|
||||
| ReturnType<typeof fetchAccountFail>
|
||||
| ReturnType<typeof blockAccountRequest>
|
||||
| ReturnType<typeof blockAccountSuccess>
|
||||
| ReturnType<typeof blockAccountFail>
|
||||
| ReturnType<typeof muteAccountRequest>
|
||||
| ReturnType<typeof muteAccountSuccess>
|
||||
| ReturnType<typeof muteAccountFail>
|
||||
| NotificationSettingsRequestAction
|
||||
| NotificationSettingsSuccessAction
|
||||
| NotificationSettingsFailAction
|
||||
| AccountSearchRequestAction
|
||||
| AccountSearchSuccessAction
|
||||
| AccountSearchFailAction
|
||||
| AccountLookupRequestAction
|
||||
| AccountLookupSuccessAction
|
||||
| AccountLookupFailAction;
|
||||
| ReturnType<typeof muteAccountSuccess>;
|
||||
|
||||
export {
|
||||
ACCOUNT_CREATE_REQUEST,
|
||||
ACCOUNT_CREATE_SUCCESS,
|
||||
ACCOUNT_CREATE_FAIL,
|
||||
ACCOUNT_FETCH_REQUEST,
|
||||
ACCOUNT_FETCH_SUCCESS,
|
||||
ACCOUNT_FETCH_FAIL,
|
||||
ACCOUNT_BLOCK_REQUEST,
|
||||
ACCOUNT_BLOCK_SUCCESS,
|
||||
ACCOUNT_BLOCK_FAIL,
|
||||
ACCOUNT_MUTE_REQUEST,
|
||||
ACCOUNT_MUTE_SUCCESS,
|
||||
ACCOUNT_MUTE_FAIL,
|
||||
ACCOUNT_SEARCH_REQUEST,
|
||||
ACCOUNT_SEARCH_SUCCESS,
|
||||
ACCOUNT_SEARCH_FAIL,
|
||||
ACCOUNT_LOOKUP_REQUEST,
|
||||
ACCOUNT_LOOKUP_SUCCESS,
|
||||
ACCOUNT_LOOKUP_FAIL,
|
||||
NOTIFICATION_SETTINGS_REQUEST,
|
||||
NOTIFICATION_SETTINGS_SUCCESS,
|
||||
NOTIFICATION_SETTINGS_FAIL,
|
||||
createAccount,
|
||||
fetchAccount,
|
||||
fetchAccountByUsername,
|
||||
|
|
|
@ -9,53 +9,21 @@ import { deleteFromTimelines } from './timelines';
|
|||
import type { Account, AdminAccount, AdminGetAccountsParams, AdminGetReportsParams, AdminReport, PaginatedResponse, PleromaConfig, Status } from 'pl-api';
|
||||
import type { AppDispatch, RootState } from 'pl-fe/store';
|
||||
|
||||
const ADMIN_CONFIG_FETCH_REQUEST = 'ADMIN_CONFIG_FETCH_REQUEST' as const;
|
||||
const ADMIN_CONFIG_FETCH_SUCCESS = 'ADMIN_CONFIG_FETCH_SUCCESS' as const;
|
||||
const ADMIN_CONFIG_FETCH_FAIL = 'ADMIN_CONFIG_FETCH_FAIL' as const;
|
||||
|
||||
const ADMIN_CONFIG_UPDATE_REQUEST = 'ADMIN_CONFIG_UPDATE_REQUEST' as const;
|
||||
const ADMIN_CONFIG_UPDATE_SUCCESS = 'ADMIN_CONFIG_UPDATE_SUCCESS' as const;
|
||||
const ADMIN_CONFIG_UPDATE_FAIL = 'ADMIN_CONFIG_UPDATE_FAIL' as const;
|
||||
|
||||
const ADMIN_REPORTS_FETCH_REQUEST = 'ADMIN_REPORTS_FETCH_REQUEST' as const;
|
||||
const ADMIN_REPORTS_FETCH_SUCCESS = 'ADMIN_REPORTS_FETCH_SUCCESS' as const;
|
||||
const ADMIN_REPORTS_FETCH_FAIL = 'ADMIN_REPORTS_FETCH_FAIL' as const;
|
||||
|
||||
const ADMIN_REPORT_PATCH_REQUEST = 'ADMIN_REPORT_PATCH_REQUEST' as const;
|
||||
const ADMIN_REPORT_PATCH_SUCCESS = 'ADMIN_REPORT_PATCH_SUCCESS' as const;
|
||||
const ADMIN_REPORT_PATCH_FAIL = 'ADMIN_REPORT_PATCH_FAIL' as const;
|
||||
|
||||
const ADMIN_USERS_FETCH_REQUEST = 'ADMIN_USERS_FETCH_REQUEST' as const;
|
||||
const ADMIN_USERS_FETCH_SUCCESS = 'ADMIN_USERS_FETCH_SUCCESS' as const;
|
||||
const ADMIN_USERS_FETCH_FAIL = 'ADMIN_USERS_FETCH_FAIL' as const;
|
||||
|
||||
const ADMIN_USER_DELETE_REQUEST = 'ADMIN_USER_DELETE_REQUEST' as const;
|
||||
const ADMIN_USER_DELETE_SUCCESS = 'ADMIN_USER_DELETE_SUCCESS' as const;
|
||||
const ADMIN_USER_DELETE_FAIL = 'ADMIN_USER_DELETE_FAIL' as const;
|
||||
|
||||
const ADMIN_USER_APPROVE_REQUEST = 'ADMIN_USER_APPROVE_REQUEST' as const;
|
||||
const ADMIN_USER_APPROVE_SUCCESS = 'ADMIN_USER_APPROVE_SUCCESS' as const;
|
||||
const ADMIN_USER_APPROVE_FAIL = 'ADMIN_USER_APPROVE_FAIL' as const;
|
||||
|
||||
const ADMIN_USER_DEACTIVATE_REQUEST = 'ADMIN_USER_DEACTIVATE_REQUEST' as const;
|
||||
const ADMIN_USER_DEACTIVATE_SUCCESS = 'ADMIN_USER_DEACTIVATE_SUCCESS' as const;
|
||||
const ADMIN_USER_DEACTIVATE_FAIL = 'ADMIN_USER_DEACTIVATE_FAIL' as const;
|
||||
|
||||
const ADMIN_STATUS_DELETE_REQUEST = 'ADMIN_STATUS_DELETE_REQUEST' as const;
|
||||
const ADMIN_STATUS_DELETE_SUCCESS = 'ADMIN_STATUS_DELETE_SUCCESS' as const;
|
||||
const ADMIN_STATUS_DELETE_FAIL = 'ADMIN_STATUS_DELETE_FAIL' as const;
|
||||
|
||||
const ADMIN_STATUS_TOGGLE_SENSITIVITY_REQUEST = 'ADMIN_STATUS_TOGGLE_SENSITIVITY_REQUEST' as const;
|
||||
const ADMIN_STATUS_TOGGLE_SENSITIVITY_SUCCESS = 'ADMIN_STATUS_TOGGLE_SENSITIVITY_SUCCESS' as const;
|
||||
const ADMIN_STATUS_TOGGLE_SENSITIVITY_FAIL = 'ADMIN_STATUS_TOGGLE_SENSITIVITY_FAIL' as const;
|
||||
|
||||
const ADMIN_USER_TAG_REQUEST = 'ADMIN_USERS_TAG_REQUEST' as const;
|
||||
const ADMIN_USER_TAG_SUCCESS = 'ADMIN_USERS_TAG_SUCCESS' as const;
|
||||
const ADMIN_USER_TAG_FAIL = 'ADMIN_USERS_TAG_FAIL' as const;
|
||||
|
||||
const ADMIN_USER_UNTAG_REQUEST = 'ADMIN_USERS_UNTAG_REQUEST' as const;
|
||||
const ADMIN_USER_UNTAG_SUCCESS = 'ADMIN_USERS_UNTAG_SUCCESS' as const;
|
||||
const ADMIN_USER_UNTAG_FAIL = 'ADMIN_USERS_UNTAG_FAIL' as const;
|
||||
|
||||
const ADMIN_USER_INDEX_EXPAND_FAIL = 'ADMIN_USER_INDEX_EXPAND_FAIL' as const;
|
||||
const ADMIN_USER_INDEX_EXPAND_REQUEST = 'ADMIN_USER_INDEX_EXPAND_REQUEST' as const;
|
||||
|
@ -68,15 +36,11 @@ const ADMIN_USER_INDEX_FETCH_SUCCESS = 'ADMIN_USER_INDEX_FETCH_SUCCESS' as const
|
|||
const ADMIN_USER_INDEX_QUERY_SET = 'ADMIN_USER_INDEX_QUERY_SET' as const;
|
||||
|
||||
const fetchConfig = () =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch<AdminActions>({ type: ADMIN_CONFIG_FETCH_REQUEST });
|
||||
return getClient(getState).admin.config.getPleromaConfig()
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
getClient(getState).admin.config.getPleromaConfig()
|
||||
.then((data) => {
|
||||
dispatch<AdminActions>({ type: ADMIN_CONFIG_FETCH_SUCCESS, configs: data.configs, needsReboot: data.need_reboot });
|
||||
}).catch(error => {
|
||||
dispatch<AdminActions>({ type: ADMIN_CONFIG_FETCH_FAIL, error });
|
||||
});
|
||||
};
|
||||
|
||||
const updateConfig = (configs: PleromaConfig['configs']) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
|
@ -84,8 +48,6 @@ const updateConfig = (configs: PleromaConfig['configs']) =>
|
|||
return getClient(getState).admin.config.updatePleromaConfig(configs)
|
||||
.then((data) => {
|
||||
dispatch<AdminActions>({ type: ADMIN_CONFIG_UPDATE_SUCCESS, configs: data.configs, needsReboot: data.need_reboot });
|
||||
}).catch(error => {
|
||||
dispatch<AdminActions>({ type: ADMIN_CONFIG_UPDATE_FAIL, error, configs });
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -103,49 +65,28 @@ const updatePlFeConfig = (data: Record<string, any>) =>
|
|||
};
|
||||
|
||||
const fetchReports = (params?: AdminGetReportsParams) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const state = getState();
|
||||
|
||||
dispatch<AdminActions>({ type: ADMIN_REPORTS_FETCH_REQUEST, params });
|
||||
|
||||
return getClient(state).admin.reports.getReports(params)
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
getClient(getState).admin.reports.getReports(params)
|
||||
.then(({ items }) => {
|
||||
items.forEach((report) => {
|
||||
dispatch(importEntities({ statuses: report.statuses as Array<Status>, accounts: [report.account?.account, report.target_account?.account] }));
|
||||
dispatch<AdminActions>({ type: ADMIN_REPORTS_FETCH_SUCCESS, reports: items, params });
|
||||
});
|
||||
}).catch(error => {
|
||||
dispatch<AdminActions>({ type: ADMIN_REPORTS_FETCH_FAIL, error, params });
|
||||
});
|
||||
};
|
||||
|
||||
const closeReport = (reportId: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const state = getState();
|
||||
|
||||
dispatch<AdminActions>({ type: ADMIN_REPORT_PATCH_REQUEST, reportId });
|
||||
|
||||
return getClient(state).admin.reports.resolveReport(reportId).then((report) => {
|
||||
dispatch<AdminActions>({ type: ADMIN_REPORT_PATCH_SUCCESS, report, reportId });
|
||||
}).catch(error => {
|
||||
dispatch<AdminActions>({ type: ADMIN_REPORT_PATCH_FAIL, error, reportId });
|
||||
});
|
||||
};
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
getClient(getState).admin.reports.resolveReport(reportId);
|
||||
|
||||
const fetchUsers = (params?: AdminGetAccountsParams) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const state = getState();
|
||||
|
||||
dispatch<AdminActions>({ type: ADMIN_USERS_FETCH_REQUEST, params });
|
||||
|
||||
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;
|
||||
}).catch(error => {
|
||||
dispatch<AdminActions>({ type: ADMIN_USERS_FETCH_FAIL, error, params });
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -153,22 +94,12 @@ const deactivateUser = (accountId: string, report_id?: string) =>
|
|||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const state = getState();
|
||||
|
||||
dispatch<AdminActions>({ type: ADMIN_USER_DEACTIVATE_REQUEST, accountId });
|
||||
|
||||
return getClient(state).admin.accounts.performAccountAction(accountId, 'suspend', { report_id });
|
||||
};
|
||||
|
||||
const deleteUser = (accountId: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch<AdminActions>({ type: ADMIN_USER_DELETE_REQUEST, accountId });
|
||||
|
||||
return getClient(getState).admin.accounts.deleteAccount(accountId)
|
||||
.then(() => {
|
||||
dispatch<AdminActions>({ type: ADMIN_USER_DELETE_SUCCESS, accountId });
|
||||
}).catch(error => {
|
||||
dispatch<AdminActions>({ type: ADMIN_USER_DELETE_FAIL, error, accountId });
|
||||
});
|
||||
};
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
getClient(getState).admin.accounts.deleteAccount(accountId);
|
||||
|
||||
const approveUser = (accountId: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
|
@ -176,57 +107,33 @@ const approveUser = (accountId: string) =>
|
|||
|
||||
dispatch<AdminActions>({ type: ADMIN_USER_APPROVE_REQUEST, accountId });
|
||||
|
||||
return getClient(state).admin.accounts.approveAccount(accountId)
|
||||
.then((user) => {
|
||||
dispatch<AdminActions>({ type: ADMIN_USER_APPROVE_SUCCESS, user, accountId });
|
||||
}).catch(error => {
|
||||
dispatch<AdminActions>({ type: ADMIN_USER_APPROVE_FAIL, error, accountId });
|
||||
});
|
||||
return getClient(state).admin.accounts.approveAccount(accountId);
|
||||
};
|
||||
|
||||
const deleteStatus = (statusId: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch<AdminActions>({ type: ADMIN_STATUS_DELETE_REQUEST, statusId });
|
||||
return getClient(getState).admin.statuses.deleteStatus(statusId)
|
||||
.then(() => {
|
||||
dispatch(deleteFromTimelines(statusId));
|
||||
return dispatch<AdminActions>({ type: ADMIN_STATUS_DELETE_SUCCESS, statusId });
|
||||
}).catch(error => {
|
||||
return dispatch<AdminActions>({ type: ADMIN_STATUS_DELETE_FAIL, error, statusId });
|
||||
return ({ statusId });
|
||||
});
|
||||
};
|
||||
|
||||
const toggleStatusSensitivity = (statusId: string, sensitive: boolean) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch<AdminActions>({ type: ADMIN_STATUS_TOGGLE_SENSITIVITY_REQUEST, statusId });
|
||||
return getClient(getState).admin.statuses.updateStatus(statusId, { sensitive: !sensitive })
|
||||
.then((status) => {
|
||||
dispatch(importEntities({ statuses: [status] }));
|
||||
dispatch<AdminActions>({ type: ADMIN_STATUS_TOGGLE_SENSITIVITY_SUCCESS, statusId, status });
|
||||
}).catch(error => {
|
||||
dispatch<AdminActions>({ type: ADMIN_STATUS_TOGGLE_SENSITIVITY_FAIL, error, statusId });
|
||||
});
|
||||
};
|
||||
|
||||
const tagUser = (accountId: string, tags: string[]) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch<AdminActions>({ type: ADMIN_USER_TAG_REQUEST, accountId, tags });
|
||||
return getClient(getState).admin.accounts.tagUser(accountId, tags).then(() => {
|
||||
dispatch<AdminActions>({ type: ADMIN_USER_TAG_SUCCESS, accountId, tags });
|
||||
}).catch(error => {
|
||||
dispatch<AdminActions>({ type: ADMIN_USER_TAG_FAIL, error, accountId, tags });
|
||||
});
|
||||
};
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
getClient(getState).admin.accounts.tagUser(accountId, tags);
|
||||
|
||||
const untagUser = (accountId: string, tags: string[]) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch<AdminActions>({ type: ADMIN_USER_UNTAG_REQUEST, accountId, tags });
|
||||
return getClient(getState).admin.accounts.untagUser(accountId, tags).then(() => {
|
||||
dispatch<AdminActions>({ type: ADMIN_USER_UNTAG_SUCCESS, accountId, tags });
|
||||
}).catch(error => {
|
||||
dispatch<AdminActions>({ type: ADMIN_USER_UNTAG_FAIL, error, accountId, tags });
|
||||
});
|
||||
};
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
getClient(getState).admin.accounts.untagUser(accountId, tags);
|
||||
|
||||
/** Synchronizes user tags to the backend. */
|
||||
const setTags = (accountId: string, oldTags: string[], newTags: string[]) =>
|
||||
|
@ -313,40 +220,15 @@ const expandUserIndex = () =>
|
|||
};
|
||||
|
||||
type AdminActions =
|
||||
| { type: typeof ADMIN_CONFIG_FETCH_REQUEST }
|
||||
| { type: typeof ADMIN_CONFIG_FETCH_SUCCESS; configs: PleromaConfig['configs']; needsReboot: boolean }
|
||||
| { type: typeof ADMIN_CONFIG_FETCH_FAIL; error: unknown }
|
||||
| { type: typeof ADMIN_CONFIG_UPDATE_REQUEST; configs: PleromaConfig['configs'] }
|
||||
| { type: typeof ADMIN_CONFIG_UPDATE_SUCCESS; configs: PleromaConfig['configs']; needsReboot: boolean }
|
||||
| { type: typeof ADMIN_CONFIG_UPDATE_FAIL; error: unknown; configs: PleromaConfig['configs'] }
|
||||
| { type: typeof ADMIN_REPORTS_FETCH_REQUEST; params?: AdminGetReportsParams }
|
||||
| { type: typeof ADMIN_REPORTS_FETCH_SUCCESS; reports: Array<AdminReport>; params?: AdminGetReportsParams }
|
||||
| { type: typeof ADMIN_REPORTS_FETCH_FAIL; error: unknown; params?: AdminGetReportsParams }
|
||||
| { type: typeof ADMIN_REPORT_PATCH_REQUEST; reportId: string }
|
||||
| { type: typeof ADMIN_REPORT_PATCH_SUCCESS; report: AdminReport; reportId: string }
|
||||
| { type: typeof ADMIN_REPORT_PATCH_FAIL; error: unknown; reportId: string }
|
||||
| { type: typeof ADMIN_USERS_FETCH_REQUEST; params?: AdminGetAccountsParams }
|
||||
| { type: typeof ADMIN_USERS_FETCH_SUCCESS; users: Array<AdminAccount>; params?: AdminGetAccountsParams; next: (() => Promise<PaginatedResponse<AdminAccount>>) | null }
|
||||
| { type: typeof ADMIN_USERS_FETCH_FAIL; error: unknown; params?: AdminGetAccountsParams }
|
||||
| { type: typeof ADMIN_USER_DEACTIVATE_REQUEST; accountId: string }
|
||||
| { type: typeof ADMIN_USER_DELETE_REQUEST; accountId: string }
|
||||
| { type: typeof ADMIN_USER_DELETE_SUCCESS; accountId: string }
|
||||
| { type: typeof ADMIN_USER_DELETE_FAIL; error: unknown; accountId: string }
|
||||
| { type: typeof ADMIN_USER_APPROVE_REQUEST; accountId: string }
|
||||
| { type: typeof ADMIN_USER_APPROVE_SUCCESS; user: AdminAccount; accountId: string }
|
||||
| { type: typeof ADMIN_USER_APPROVE_FAIL; error: unknown; accountId: string }
|
||||
| { type: typeof ADMIN_STATUS_DELETE_REQUEST; statusId: string }
|
||||
| { type: typeof ADMIN_STATUS_DELETE_SUCCESS; statusId: string }
|
||||
| { type: typeof ADMIN_STATUS_DELETE_FAIL; error: unknown; statusId: string }
|
||||
| { type: typeof ADMIN_STATUS_TOGGLE_SENSITIVITY_REQUEST; statusId: string }
|
||||
| { type: typeof ADMIN_STATUS_TOGGLE_SENSITIVITY_SUCCESS; statusId: string; status: Status }
|
||||
| { type: typeof ADMIN_STATUS_TOGGLE_SENSITIVITY_FAIL; error: unknown; statusId: string }
|
||||
| { type: typeof ADMIN_USER_TAG_REQUEST; accountId: string; tags: Array<string> }
|
||||
| { type: typeof ADMIN_USER_TAG_SUCCESS; accountId: string; tags: Array<string> }
|
||||
| { type: typeof ADMIN_USER_TAG_FAIL; error: unknown; accountId: string; tags: Array<string> }
|
||||
| { type: typeof ADMIN_USER_UNTAG_REQUEST; accountId: string; tags: Array<string> }
|
||||
| { type: typeof ADMIN_USER_UNTAG_SUCCESS; accountId: string; tags: Array<string> }
|
||||
| { type: typeof ADMIN_USER_UNTAG_FAIL; error: unknown; accountId: string; tags: Array<string> }
|
||||
| ReturnType<typeof setUserIndexQuery>
|
||||
| { type: typeof ADMIN_USER_INDEX_FETCH_REQUEST }
|
||||
| { type: typeof ADMIN_USER_INDEX_FETCH_SUCCESS; users: Array<AdminAccount>; total?: number; next: (() => Promise<PaginatedResponse<AdminAccount>>) | null; params?: AdminGetAccountsParams }
|
||||
|
@ -356,42 +238,15 @@ type AdminActions =
|
|||
| { type: typeof ADMIN_USER_INDEX_EXPAND_FAIL };
|
||||
|
||||
export {
|
||||
ADMIN_CONFIG_FETCH_REQUEST,
|
||||
ADMIN_CONFIG_FETCH_SUCCESS,
|
||||
ADMIN_CONFIG_FETCH_FAIL,
|
||||
ADMIN_CONFIG_UPDATE_REQUEST,
|
||||
ADMIN_CONFIG_UPDATE_SUCCESS,
|
||||
ADMIN_CONFIG_UPDATE_FAIL,
|
||||
ADMIN_REPORTS_FETCH_REQUEST,
|
||||
ADMIN_REPORTS_FETCH_SUCCESS,
|
||||
ADMIN_REPORTS_FETCH_FAIL,
|
||||
ADMIN_REPORT_PATCH_REQUEST,
|
||||
ADMIN_REPORT_PATCH_SUCCESS,
|
||||
ADMIN_REPORT_PATCH_FAIL,
|
||||
ADMIN_USERS_FETCH_REQUEST,
|
||||
ADMIN_USERS_FETCH_SUCCESS,
|
||||
ADMIN_USERS_FETCH_FAIL,
|
||||
ADMIN_USER_DELETE_REQUEST,
|
||||
ADMIN_USER_DELETE_SUCCESS,
|
||||
ADMIN_USER_DELETE_FAIL,
|
||||
ADMIN_USER_APPROVE_REQUEST,
|
||||
ADMIN_USER_APPROVE_SUCCESS,
|
||||
ADMIN_USER_APPROVE_FAIL,
|
||||
ADMIN_USER_DEACTIVATE_REQUEST,
|
||||
ADMIN_USER_DEACTIVATE_SUCCESS,
|
||||
ADMIN_USER_DEACTIVATE_FAIL,
|
||||
ADMIN_STATUS_DELETE_REQUEST,
|
||||
ADMIN_STATUS_DELETE_SUCCESS,
|
||||
ADMIN_STATUS_DELETE_FAIL,
|
||||
ADMIN_STATUS_TOGGLE_SENSITIVITY_REQUEST,
|
||||
ADMIN_STATUS_TOGGLE_SENSITIVITY_SUCCESS,
|
||||
ADMIN_STATUS_TOGGLE_SENSITIVITY_FAIL,
|
||||
ADMIN_USER_TAG_REQUEST,
|
||||
ADMIN_USER_TAG_SUCCESS,
|
||||
ADMIN_USER_TAG_FAIL,
|
||||
ADMIN_USER_UNTAG_REQUEST,
|
||||
ADMIN_USER_UNTAG_SUCCESS,
|
||||
ADMIN_USER_UNTAG_FAIL,
|
||||
ADMIN_USER_INDEX_EXPAND_FAIL,
|
||||
ADMIN_USER_INDEX_EXPAND_REQUEST,
|
||||
ADMIN_USER_INDEX_EXPAND_SUCCESS,
|
||||
|
|
|
@ -11,22 +11,12 @@ import type { Account as BaseAccount } from 'pl-api';
|
|||
import type { Account } from 'pl-fe/normalizers/account';
|
||||
import type { AppDispatch, RootState } from 'pl-fe/store';
|
||||
|
||||
const ALIASES_FETCH_REQUEST = 'ALIASES_FETCH_REQUEST' as const;
|
||||
const ALIASES_FETCH_SUCCESS = 'ALIASES_FETCH_SUCCESS' as const;
|
||||
const ALIASES_FETCH_FAIL = 'ALIASES_FETCH_FAIL' as const;
|
||||
|
||||
const ALIASES_SUGGESTIONS_CHANGE = 'ALIASES_SUGGESTIONS_CHANGE' as const;
|
||||
const ALIASES_SUGGESTIONS_READY = 'ALIASES_SUGGESTIONS_READY' as const;
|
||||
const ALIASES_SUGGESTIONS_CLEAR = 'ALIASES_SUGGESTIONS_CLEAR' as const;
|
||||
|
||||
const ALIASES_ADD_REQUEST = 'ALIASES_ADD_REQUEST' as const;
|
||||
const ALIASES_ADD_SUCCESS = 'ALIASES_ADD_SUCCESS' as const;
|
||||
const ALIASES_ADD_FAIL = 'ALIASES_ADD_FAIL' as const;
|
||||
|
||||
const ALIASES_REMOVE_REQUEST = 'ALIASES_REMOVE_REQUEST' as const;
|
||||
const ALIASES_REMOVE_SUCCESS = 'ALIASES_REMOVE_SUCCESS' as const;
|
||||
const ALIASES_REMOVE_FAIL = 'ALIASES_REMOVE_FAIL' as const;
|
||||
|
||||
const messages = defineMessages({
|
||||
createSuccess: { id: 'aliases.success.add', defaultMessage: 'Account alias created successfully' },
|
||||
removeSuccess: { id: 'aliases.success.remove', defaultMessage: 'Account alias removed successfully' },
|
||||
|
@ -34,29 +24,18 @@ const messages = defineMessages({
|
|||
|
||||
const fetchAliases = (dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!isLoggedIn(getState)) return;
|
||||
dispatch(fetchAliasesRequest());
|
||||
|
||||
return getClient(getState).settings.getAccountAliases()
|
||||
.then(response => {
|
||||
dispatch(fetchAliasesSuccess(response.aliases));
|
||||
})
|
||||
.catch(err => dispatch(fetchAliasesFail(err)));
|
||||
});
|
||||
};
|
||||
|
||||
const fetchAliasesRequest = () => ({
|
||||
type: ALIASES_FETCH_REQUEST,
|
||||
});
|
||||
|
||||
const fetchAliasesSuccess = (aliases: Array<string>) => ({
|
||||
type: ALIASES_FETCH_SUCCESS,
|
||||
value: aliases,
|
||||
});
|
||||
|
||||
const fetchAliasesFail = (error: unknown) => ({
|
||||
type: ALIASES_FETCH_FAIL,
|
||||
error,
|
||||
});
|
||||
|
||||
const fetchAliasesSuggestions = (q: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!isLoggedIn(getState)) return;
|
||||
|
@ -86,81 +65,33 @@ const changeAliasesSuggestions = (value: string) => ({
|
|||
const addToAliases = (account: Account) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!isLoggedIn(getState)) return;
|
||||
dispatch(addToAliasesRequest());
|
||||
|
||||
return getClient(getState).settings.addAccountAlias(account.acct).then(() => {
|
||||
toast.success(messages.createSuccess);
|
||||
dispatch(addToAliasesSuccess);
|
||||
dispatch(fetchAliases);
|
||||
})
|
||||
.catch(err => dispatch(addToAliasesFail(err)));
|
||||
});
|
||||
};
|
||||
|
||||
const addToAliasesRequest = () => ({
|
||||
type: ALIASES_ADD_REQUEST,
|
||||
});
|
||||
|
||||
const addToAliasesSuccess = () => ({
|
||||
type: ALIASES_ADD_SUCCESS,
|
||||
});
|
||||
|
||||
const addToAliasesFail = (error: unknown) => ({
|
||||
type: ALIASES_ADD_FAIL,
|
||||
error,
|
||||
});
|
||||
|
||||
const removeFromAliases = (account: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!isLoggedIn(getState)) return;
|
||||
dispatch(removeFromAliasesRequest());
|
||||
|
||||
return getClient(getState).settings.deleteAccountAlias(account).then(() => {
|
||||
toast.success(messages.removeSuccess);
|
||||
dispatch(removeFromAliasesSuccess);
|
||||
dispatch(fetchAliases);
|
||||
}).catch(err => dispatch(removeFromAliasesFail(err)));
|
||||
});
|
||||
};
|
||||
|
||||
const removeFromAliasesRequest = () => ({
|
||||
type: ALIASES_REMOVE_REQUEST,
|
||||
});
|
||||
|
||||
const removeFromAliasesSuccess = () => ({
|
||||
type: ALIASES_REMOVE_SUCCESS,
|
||||
});
|
||||
|
||||
const removeFromAliasesFail = (error: unknown) => ({
|
||||
type: ALIASES_REMOVE_FAIL,
|
||||
error,
|
||||
});
|
||||
|
||||
type AliasesAction =
|
||||
ReturnType<typeof fetchAliasesRequest>
|
||||
| ReturnType<typeof fetchAliasesSuccess>
|
||||
| ReturnType<typeof fetchAliasesFail>
|
||||
| ReturnType<typeof fetchAliasesSuggestionsReady>
|
||||
| ReturnType<typeof clearAliasesSuggestions>
|
||||
| ReturnType<typeof changeAliasesSuggestions>
|
||||
| ReturnType<typeof addToAliasesRequest>
|
||||
| ReturnType<typeof addToAliasesSuccess>
|
||||
| ReturnType<typeof addToAliasesFail>
|
||||
| ReturnType<typeof removeFromAliasesRequest>
|
||||
| ReturnType<typeof removeFromAliasesSuccess>
|
||||
| ReturnType<typeof removeFromAliasesFail>;
|
||||
|
||||
export {
|
||||
ALIASES_FETCH_REQUEST,
|
||||
ALIASES_FETCH_SUCCESS,
|
||||
ALIASES_FETCH_FAIL,
|
||||
ALIASES_SUGGESTIONS_CHANGE,
|
||||
ALIASES_SUGGESTIONS_READY,
|
||||
ALIASES_SUGGESTIONS_CLEAR,
|
||||
ALIASES_ADD_REQUEST,
|
||||
ALIASES_ADD_SUCCESS,
|
||||
ALIASES_ADD_FAIL,
|
||||
ALIASES_REMOVE_REQUEST,
|
||||
ALIASES_REMOVE_SUCCESS,
|
||||
ALIASES_REMOVE_FAIL,
|
||||
fetchAliases,
|
||||
fetchAliasesSuggestions,
|
||||
clearAliasesSuggestions,
|
||||
|
|
|
@ -10,30 +10,12 @@ import { PlApiClient, type CreateApplicationParams } from 'pl-api';
|
|||
|
||||
import * as BuildConfig from 'pl-fe/build-config';
|
||||
|
||||
import type { AppDispatch } from 'pl-fe/store';
|
||||
const createApp = (params: CreateApplicationParams, baseURL?: string) => {
|
||||
const client = new PlApiClient(baseURL || BuildConfig.BACKEND_URL || '');
|
||||
|
||||
const APP_CREATE_REQUEST = 'APP_CREATE_REQUEST' as const;
|
||||
const APP_CREATE_SUCCESS = 'APP_CREATE_SUCCESS' as const;
|
||||
const APP_CREATE_FAIL = 'APP_CREATE_FAIL' as const;
|
||||
|
||||
const createApp = (params: CreateApplicationParams, baseURL?: string) =>
|
||||
(dispatch: AppDispatch) => {
|
||||
dispatch({ type: APP_CREATE_REQUEST, params });
|
||||
|
||||
const client = new PlApiClient(baseURL || BuildConfig.BACKEND_URL || '');
|
||||
|
||||
return client.apps.createApplication(params).then((app) => {
|
||||
dispatch({ type: APP_CREATE_SUCCESS, params, app });
|
||||
return app;
|
||||
}).catch(error => {
|
||||
dispatch({ type: APP_CREATE_FAIL, params, error });
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
return client.apps.createApplication(params);
|
||||
};
|
||||
|
||||
export {
|
||||
APP_CREATE_REQUEST,
|
||||
APP_CREATE_SUCCESS,
|
||||
APP_CREATE_FAIL,
|
||||
createApp,
|
||||
};
|
||||
|
|
|
@ -53,9 +53,7 @@ const VERIFY_CREDENTIALS_REQUEST = 'VERIFY_CREDENTIALS_REQUEST' as const;
|
|||
const VERIFY_CREDENTIALS_SUCCESS = 'VERIFY_CREDENTIALS_SUCCESS' as const;
|
||||
const VERIFY_CREDENTIALS_FAIL = 'VERIFY_CREDENTIALS_FAIL' as const;
|
||||
|
||||
const AUTH_ACCOUNT_REMEMBER_REQUEST = 'AUTH_ACCOUNT_REMEMBER_REQUEST' as const;
|
||||
const AUTH_ACCOUNT_REMEMBER_SUCCESS = 'AUTH_ACCOUNT_REMEMBER_SUCCESS' as const;
|
||||
const AUTH_ACCOUNT_REMEMBER_FAIL = 'AUTH_ACCOUNT_REMEMBER_FAIL' as const;
|
||||
|
||||
const customApp = custom('app');
|
||||
|
||||
|
@ -97,7 +95,7 @@ const createAuthApp = () =>
|
|||
website: sourceCode.homepage,
|
||||
};
|
||||
|
||||
return dispatch(createApp(params)).then((app) =>
|
||||
return createApp(params).then((app) =>
|
||||
dispatch<AuthAppCreatedAction>({ type: AUTH_APP_CREATED, app }),
|
||||
);
|
||||
};
|
||||
|
@ -207,34 +205,19 @@ const verifyCredentials = (token: string, accountUrl?: string) =>
|
|||
});
|
||||
};
|
||||
|
||||
interface AuthAccountRememberRequestAction {
|
||||
type: typeof AUTH_ACCOUNT_REMEMBER_REQUEST;
|
||||
accountUrl: string;
|
||||
}
|
||||
|
||||
interface AuthAccountRememberSuccessAction {
|
||||
type: typeof AUTH_ACCOUNT_REMEMBER_SUCCESS;
|
||||
accountUrl: string;
|
||||
account: CredentialAccount;
|
||||
}
|
||||
|
||||
interface AuthAccountRememberFailAction {
|
||||
type: typeof AUTH_ACCOUNT_REMEMBER_FAIL;
|
||||
error: unknown;
|
||||
accountUrl: string;
|
||||
skipAlert: boolean;
|
||||
}
|
||||
|
||||
const rememberAuthAccount = (accountUrl: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch<AuthAccountRememberRequestAction>({ type: AUTH_ACCOUNT_REMEMBER_REQUEST, accountUrl });
|
||||
return KVStore.getItemOrError(`authAccount:${accountUrl}`).then(account => {
|
||||
dispatch(importEntities({ accounts: [account] }));
|
||||
dispatch<AuthAccountRememberSuccessAction>({ type: AUTH_ACCOUNT_REMEMBER_SUCCESS, account, accountUrl });
|
||||
if (account.id === getState().me) dispatch(fetchMeSuccess(account));
|
||||
return account;
|
||||
}).catch(error => {
|
||||
dispatch<AuthAccountRememberFailAction>({ type: AUTH_ACCOUNT_REMEMBER_FAIL, error, accountUrl, skipAlert: true });
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -357,9 +340,7 @@ type AuthAction =
|
|||
| VerifyCredentialsRequestAction
|
||||
| VerifyCredentialsSuccessAction
|
||||
| VerifyCredentialsFailAction
|
||||
| AuthAccountRememberRequestAction
|
||||
| AuthAccountRememberSuccessAction
|
||||
| AuthAccountRememberFailAction;
|
||||
| AuthAccountRememberSuccessAction;
|
||||
|
||||
export {
|
||||
SWITCH_ACCOUNT,
|
||||
|
@ -370,9 +351,7 @@ export {
|
|||
VERIFY_CREDENTIALS_REQUEST,
|
||||
VERIFY_CREDENTIALS_SUCCESS,
|
||||
VERIFY_CREDENTIALS_FAIL,
|
||||
AUTH_ACCOUNT_REMEMBER_REQUEST,
|
||||
AUTH_ACCOUNT_REMEMBER_SUCCESS,
|
||||
AUTH_ACCOUNT_REMEMBER_FAIL,
|
||||
messages,
|
||||
otpVerify,
|
||||
verifyCredentials,
|
||||
|
|
|
@ -10,7 +10,7 @@ import { createApp } from './apps';
|
|||
import type { AppDispatch, RootState } from 'pl-fe/store';
|
||||
|
||||
const createProviderApp = () =>
|
||||
async(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
async (dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const scopes = getScopes(getState());
|
||||
|
||||
const params = {
|
||||
|
@ -20,7 +20,7 @@ const createProviderApp = () =>
|
|||
scopes,
|
||||
};
|
||||
|
||||
return dispatch(createApp(params));
|
||||
return createApp(params);
|
||||
};
|
||||
|
||||
const prepareRequest = (provider: string) =>
|
||||
|
|
|
@ -10,120 +10,60 @@ import type { Account } from 'pl-fe/normalizers/account';
|
|||
import type { MinifiedSuggestion } from 'pl-fe/queries/trends/use-suggested-accounts';
|
||||
import type { AppDispatch, RootState } from 'pl-fe/store';
|
||||
|
||||
const DOMAIN_BLOCK_REQUEST = 'DOMAIN_BLOCK_REQUEST' as const;
|
||||
const DOMAIN_BLOCK_SUCCESS = 'DOMAIN_BLOCK_SUCCESS' as const;
|
||||
const DOMAIN_BLOCK_FAIL = 'DOMAIN_BLOCK_FAIL' as const;
|
||||
|
||||
const DOMAIN_UNBLOCK_REQUEST = 'DOMAIN_UNBLOCK_REQUEST' as const;
|
||||
const DOMAIN_UNBLOCK_SUCCESS = 'DOMAIN_UNBLOCK_SUCCESS' as const;
|
||||
const DOMAIN_UNBLOCK_FAIL = 'DOMAIN_UNBLOCK_FAIL' as const;
|
||||
|
||||
const DOMAIN_BLOCKS_FETCH_REQUEST = 'DOMAIN_BLOCKS_FETCH_REQUEST' as const;
|
||||
const DOMAIN_BLOCKS_FETCH_SUCCESS = 'DOMAIN_BLOCKS_FETCH_SUCCESS' as const;
|
||||
const DOMAIN_BLOCKS_FETCH_FAIL = 'DOMAIN_BLOCKS_FETCH_FAIL' as const;
|
||||
|
||||
const DOMAIN_BLOCKS_EXPAND_REQUEST = 'DOMAIN_BLOCKS_EXPAND_REQUEST' as const;
|
||||
const DOMAIN_BLOCKS_EXPAND_SUCCESS = 'DOMAIN_BLOCKS_EXPAND_SUCCESS' as const;
|
||||
const DOMAIN_BLOCKS_EXPAND_FAIL = 'DOMAIN_BLOCKS_EXPAND_FAIL' as const;
|
||||
|
||||
const blockDomain = (domain: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!isLoggedIn(getState)) return;
|
||||
|
||||
dispatch(blockDomainRequest(domain));
|
||||
|
||||
return getClient(getState).filtering.blockDomain(domain).then(() => {
|
||||
// TODO: Update relationships on block
|
||||
const accounts = selectAccountsByDomain(getState(), domain);
|
||||
if (!accounts) return;
|
||||
dispatch(blockDomainSuccess(domain, accounts));
|
||||
|
||||
queryClient.setQueryData<Array<MinifiedSuggestion>>(['suggestions'], suggestions => suggestions
|
||||
? suggestions.filter((suggestion) => !accounts.includes(suggestion.account_id))
|
||||
: undefined);
|
||||
}).catch(err => {
|
||||
dispatch(blockDomainFail(domain, err));
|
||||
});
|
||||
};
|
||||
|
||||
const blockDomainRequest = (domain: string) => ({
|
||||
type: DOMAIN_BLOCK_REQUEST,
|
||||
domain,
|
||||
});
|
||||
|
||||
const blockDomainSuccess = (domain: string, accounts: string[]) => ({
|
||||
type: DOMAIN_BLOCK_SUCCESS,
|
||||
domain,
|
||||
accounts,
|
||||
});
|
||||
|
||||
const blockDomainFail = (domain: string, error: unknown) => ({
|
||||
type: DOMAIN_BLOCK_FAIL,
|
||||
domain,
|
||||
error,
|
||||
});
|
||||
|
||||
const unblockDomain = (domain: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!isLoggedIn(getState)) return;
|
||||
|
||||
dispatch(unblockDomainRequest(domain));
|
||||
|
||||
return getClient(getState).filtering.unblockDomain(domain).then(() => {
|
||||
// TODO: Update relationships on unblock
|
||||
const accounts = selectAccountsByDomain(getState(), domain);
|
||||
if (!accounts) return;
|
||||
dispatch(unblockDomainSuccess(domain, accounts));
|
||||
}).catch(err => {
|
||||
dispatch(unblockDomainFail(domain, err));
|
||||
});
|
||||
}).catch(() => {});
|
||||
};
|
||||
|
||||
const unblockDomainRequest = (domain: string) => ({
|
||||
type: DOMAIN_UNBLOCK_REQUEST,
|
||||
domain,
|
||||
});
|
||||
|
||||
const unblockDomainSuccess = (domain: string, accounts: string[]) => ({
|
||||
type: DOMAIN_UNBLOCK_SUCCESS,
|
||||
domain,
|
||||
accounts,
|
||||
});
|
||||
|
||||
const unblockDomainFail = (domain: string, error: unknown) => ({
|
||||
type: DOMAIN_UNBLOCK_FAIL,
|
||||
domain,
|
||||
error,
|
||||
});
|
||||
|
||||
const fetchDomainBlocks = () =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!isLoggedIn(getState)) return;
|
||||
|
||||
dispatch(fetchDomainBlocksRequest());
|
||||
|
||||
return getClient(getState).filtering.getDomainBlocks().then(response => {
|
||||
dispatch(fetchDomainBlocksSuccess(response.items, response.next));
|
||||
}).catch(err => {
|
||||
dispatch(fetchDomainBlocksFail(err));
|
||||
});
|
||||
};
|
||||
|
||||
const fetchDomainBlocksRequest = () => ({
|
||||
type: DOMAIN_BLOCKS_FETCH_REQUEST,
|
||||
});
|
||||
|
||||
const fetchDomainBlocksSuccess = (domains: string[], next: (() => Promise<PaginatedResponse<string>>) | null) => ({
|
||||
type: DOMAIN_BLOCKS_FETCH_SUCCESS,
|
||||
domains,
|
||||
next,
|
||||
});
|
||||
|
||||
const fetchDomainBlocksFail = (error: unknown) => ({
|
||||
type: DOMAIN_BLOCKS_FETCH_FAIL,
|
||||
error,
|
||||
});
|
||||
|
||||
const expandDomainBlocks = () =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!isLoggedIn(getState)) return;
|
||||
|
@ -132,13 +72,9 @@ const expandDomainBlocks = () =>
|
|||
|
||||
if (!next) return;
|
||||
|
||||
dispatch(expandDomainBlocksRequest());
|
||||
|
||||
next().then(response => {
|
||||
dispatch(expandDomainBlocksSuccess(response.items, response.next));
|
||||
}).catch(err => {
|
||||
dispatch(expandDomainBlocksFail(err));
|
||||
});
|
||||
}).catch(() => {});
|
||||
};
|
||||
|
||||
const selectAccountsByDomain = (state: RootState, domain: string): string[] => {
|
||||
|
@ -150,48 +86,21 @@ const selectAccountsByDomain = (state: RootState, domain: string): string[] => {
|
|||
return accounts || [];
|
||||
};
|
||||
|
||||
const expandDomainBlocksRequest = () => ({
|
||||
type: DOMAIN_BLOCKS_EXPAND_REQUEST,
|
||||
});
|
||||
|
||||
const expandDomainBlocksSuccess = (domains: string[], next: (() => Promise<PaginatedResponse<string>>) | null) => ({
|
||||
type: DOMAIN_BLOCKS_EXPAND_SUCCESS,
|
||||
domains,
|
||||
next,
|
||||
});
|
||||
|
||||
const expandDomainBlocksFail = (error: unknown) => ({
|
||||
type: DOMAIN_BLOCKS_EXPAND_FAIL,
|
||||
error,
|
||||
});
|
||||
|
||||
type DomainBlocksAction =
|
||||
ReturnType<typeof blockDomainRequest>
|
||||
| ReturnType<typeof blockDomainSuccess>
|
||||
| ReturnType<typeof blockDomainFail>
|
||||
| ReturnType<typeof unblockDomainRequest>
|
||||
| ReturnType<typeof unblockDomainSuccess>
|
||||
| ReturnType<typeof unblockDomainFail>
|
||||
| ReturnType<typeof fetchDomainBlocksRequest>
|
||||
| ReturnType<typeof fetchDomainBlocksSuccess>
|
||||
| ReturnType<typeof fetchDomainBlocksFail>
|
||||
| ReturnType<typeof expandDomainBlocksRequest>
|
||||
| ReturnType<typeof expandDomainBlocksSuccess>
|
||||
| ReturnType<typeof expandDomainBlocksFail>;
|
||||
| ReturnType<typeof expandDomainBlocksSuccess>;
|
||||
|
||||
export {
|
||||
DOMAIN_BLOCK_REQUEST,
|
||||
DOMAIN_BLOCK_SUCCESS,
|
||||
DOMAIN_BLOCK_FAIL,
|
||||
DOMAIN_UNBLOCK_REQUEST,
|
||||
DOMAIN_UNBLOCK_SUCCESS,
|
||||
DOMAIN_UNBLOCK_FAIL,
|
||||
DOMAIN_BLOCKS_FETCH_REQUEST,
|
||||
DOMAIN_BLOCKS_FETCH_SUCCESS,
|
||||
DOMAIN_BLOCKS_FETCH_FAIL,
|
||||
DOMAIN_BLOCKS_EXPAND_REQUEST,
|
||||
DOMAIN_BLOCKS_EXPAND_SUCCESS,
|
||||
DOMAIN_BLOCKS_EXPAND_FAIL,
|
||||
blockDomain,
|
||||
unblockDomain,
|
||||
fetchDomainBlocks,
|
||||
|
|
|
@ -9,16 +9,10 @@ import { STATUS_FETCH_SOURCE_FAIL, STATUS_FETCH_SOURCE_REQUEST, STATUS_FETCH_SOU
|
|||
import type { CreateEventParams, Location, MediaAttachment, PaginatedResponse, Status } from 'pl-api';
|
||||
import type { AppDispatch, RootState } from 'pl-fe/store';
|
||||
|
||||
const EVENT_SUBMIT_REQUEST = 'EVENT_SUBMIT_REQUEST' as const;
|
||||
const EVENT_SUBMIT_SUCCESS = 'EVENT_SUBMIT_SUCCESS' as const;
|
||||
const EVENT_SUBMIT_FAIL = 'EVENT_SUBMIT_FAIL' as const;
|
||||
|
||||
const EVENT_JOIN_REQUEST = 'EVENT_JOIN_REQUEST' as const;
|
||||
const EVENT_JOIN_SUCCESS = 'EVENT_JOIN_SUCCESS' as const;
|
||||
const EVENT_JOIN_FAIL = 'EVENT_JOIN_FAIL' as const;
|
||||
|
||||
const EVENT_LEAVE_REQUEST = 'EVENT_LEAVE_REQUEST' as const;
|
||||
const EVENT_LEAVE_SUCCESS = 'EVENT_LEAVE_SUCCESS' as const;
|
||||
const EVENT_LEAVE_FAIL = 'EVENT_LEAVE_FAIL' as const;
|
||||
|
||||
const EVENT_COMPOSE_CANCEL = 'EVENT_COMPOSE_CANCEL' as const;
|
||||
|
@ -71,8 +65,6 @@ const submitEvent = ({
|
|||
return;
|
||||
}
|
||||
|
||||
dispatch(submitEventRequest());
|
||||
|
||||
const params: CreateEventParams = {
|
||||
name,
|
||||
status,
|
||||
|
@ -91,7 +83,6 @@ const submitEvent = ({
|
|||
: getClient(state).events.editEvent(statusId, params)
|
||||
).then((data) => {
|
||||
dispatch(importEntities({ statuses: [data] }));
|
||||
dispatch(submitEventSuccess(data));
|
||||
toast.success(
|
||||
statusId ? messages.editSuccess : messages.success,
|
||||
{
|
||||
|
@ -101,25 +92,9 @@ const submitEvent = ({
|
|||
);
|
||||
|
||||
return data;
|
||||
}).catch((error) => {
|
||||
dispatch(submitEventFail(error));
|
||||
});
|
||||
};
|
||||
|
||||
const submitEventRequest = () => ({
|
||||
type: EVENT_SUBMIT_REQUEST,
|
||||
});
|
||||
|
||||
const submitEventSuccess = (status: Status) => ({
|
||||
type: EVENT_SUBMIT_SUCCESS,
|
||||
status,
|
||||
});
|
||||
|
||||
const submitEventFail = (error: unknown) => ({
|
||||
type: EVENT_SUBMIT_FAIL,
|
||||
error,
|
||||
});
|
||||
|
||||
const joinEvent = (statusId: string, participationMessage?: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const status = getState().statuses[statusId];
|
||||
|
@ -132,7 +107,6 @@ const joinEvent = (statusId: string, participationMessage?: string) =>
|
|||
|
||||
return getClient(getState).events.joinEvent(statusId, participationMessage).then((data) => {
|
||||
dispatch(importEntities({ statuses: [data] }));
|
||||
dispatch(joinEventSuccess(status.id));
|
||||
toast.success(
|
||||
data.event?.join_state === 'pending' ? messages.joinRequestSuccess : messages.joinSuccess,
|
||||
{
|
||||
|
@ -150,11 +124,6 @@ const joinEventRequest = (statusId: string) => ({
|
|||
statusId,
|
||||
});
|
||||
|
||||
const joinEventSuccess = (statusId: string) => ({
|
||||
type: EVENT_JOIN_SUCCESS,
|
||||
statusId,
|
||||
});
|
||||
|
||||
const joinEventFail = (error: unknown, statusId: string, previousState: Exclude<Status['event'], null>['join_state'] | null) => ({
|
||||
type: EVENT_JOIN_FAIL,
|
||||
error,
|
||||
|
@ -174,7 +143,6 @@ const leaveEvent = (statusId: string) =>
|
|||
|
||||
return getClient(getState).events.leaveEvent(statusId).then((data) => {
|
||||
dispatch(importEntities({ statuses: [data] }));
|
||||
dispatch(leaveEventSuccess(status.id));
|
||||
}).catch((error) => {
|
||||
dispatch(leaveEventFail(error, status.id, status?.event?.join_state || null));
|
||||
});
|
||||
|
@ -185,11 +153,6 @@ const leaveEventRequest = (statusId: string) => ({
|
|||
statusId,
|
||||
});
|
||||
|
||||
const leaveEventSuccess = (statusId: string) => ({
|
||||
type: EVENT_LEAVE_SUCCESS,
|
||||
statusId,
|
||||
});
|
||||
|
||||
const leaveEventFail = (error: unknown, statusId: string, previousState: Exclude<Status['event'], null>['join_state'] | null) => ({
|
||||
type: EVENT_LEAVE_FAIL,
|
||||
statusId,
|
||||
|
@ -270,14 +233,9 @@ const fetchJoinedEvents = () =>
|
|||
};
|
||||
|
||||
type EventsAction =
|
||||
| ReturnType<typeof submitEventRequest>
|
||||
| ReturnType<typeof submitEventSuccess>
|
||||
| ReturnType<typeof submitEventFail>
|
||||
| ReturnType<typeof joinEventRequest>
|
||||
| ReturnType<typeof joinEventSuccess>
|
||||
| ReturnType<typeof joinEventFail>
|
||||
| ReturnType<typeof leaveEventRequest>
|
||||
| ReturnType<typeof leaveEventSuccess>
|
||||
| ReturnType<typeof leaveEventFail>
|
||||
| ReturnType<typeof cancelEventCompose>
|
||||
| EventFormSetAction
|
||||
|
@ -289,14 +247,9 @@ type EventsAction =
|
|||
| { type: typeof JOINED_EVENTS_FETCH_FAIL; error: unknown }
|
||||
|
||||
export {
|
||||
EVENT_SUBMIT_REQUEST,
|
||||
EVENT_SUBMIT_SUCCESS,
|
||||
EVENT_SUBMIT_FAIL,
|
||||
EVENT_JOIN_REQUEST,
|
||||
EVENT_JOIN_SUCCESS,
|
||||
EVENT_JOIN_FAIL,
|
||||
EVENT_LEAVE_REQUEST,
|
||||
EVENT_LEAVE_SUCCESS,
|
||||
EVENT_LEAVE_FAIL,
|
||||
EVENT_COMPOSE_CANCEL,
|
||||
EVENT_FORM_SET,
|
||||
|
|
|
@ -46,7 +46,7 @@ const externalAuthorize = (instance: Instance, baseURL: string) =>
|
|||
(dispatch: AppDispatch) => {
|
||||
const scopes = getInstanceScopes(instance);
|
||||
|
||||
return dispatch(createExternalApp(instance, baseURL)).then((app) => {
|
||||
return createExternalApp(instance, baseURL).then((app) => {
|
||||
const { client_id, redirect_uri } = app;
|
||||
|
||||
const query = new URLSearchParams({
|
||||
|
|
|
@ -46,7 +46,7 @@ const CreateApp: React.FC = () => {
|
|||
const handleCreateApp = () => {
|
||||
const baseURL = getBaseURL(account!);
|
||||
|
||||
return dispatch(createApp(params, baseURL))
|
||||
return createApp(params, baseURL)
|
||||
.then(app => {
|
||||
setApp(app);
|
||||
return app;
|
||||
|
|
Loading…
Reference in a new issue