Removed no longer needed async/await when building api client

This commit is contained in:
Alejandro Celaya
2020-03-05 09:23:53 +01:00
parent 397a183f65
commit fa0d3d4047
17 changed files with 23 additions and 25 deletions

View File

@@ -19,7 +19,7 @@ export const selectServer = ({ findServerById }, buildShlinkApiClient) => (serve
dispatch(resetShortUrlParams());
const selectedServer = findServerById(serverId);
const { health } = await buildShlinkApiClient(selectedServer);
const { health } = buildShlinkApiClient(selectedServer);
const version = await health()
.then(({ version }) => version === LATEST_VERSION_CONSTRAINT ? MAX_FALLBACK_VERSION : version)
.then((version) => !versionIsValidSemVer(version) ? MIN_FALLBACK_VERSION : version)

View File

@@ -31,7 +31,7 @@ export default handleActions({
export const createShortUrl = (buildShlinkApiClient) => (data) => async (dispatch, getState) => {
dispatch({ type: CREATE_SHORT_URL_START });
const { createShortUrl } = await buildShlinkApiClient(getState);
const { createShortUrl } = buildShlinkApiClient(getState);
try {
const result = await createShortUrl(data);

View File

@@ -32,7 +32,7 @@ export default handleActions({
export const deleteShortUrl = (buildShlinkApiClient) => (shortCode, domain) => async (dispatch, getState) => {
dispatch({ type: DELETE_SHORT_URL_START });
const { deleteShortUrl } = await buildShlinkApiClient(getState);
const { deleteShortUrl } = buildShlinkApiClient(getState);
try {
await deleteShortUrl(shortCode, domain);

View File

@@ -37,7 +37,7 @@ export default handleActions({
export const editShortUrlMeta = (buildShlinkApiClient) => (shortCode, domain, meta) => async (dispatch, getState) => {
dispatch({ type: EDIT_SHORT_URL_META_START });
const { updateShortUrlMeta } = await buildShlinkApiClient(getState);
const { updateShortUrlMeta } = buildShlinkApiClient(getState);
try {
await updateShortUrlMeta(shortCode, domain, meta);

View File

@@ -31,7 +31,7 @@ export default handleActions({
export const editShortUrlTags = (buildShlinkApiClient) => (shortCode, domain, tags) => async (dispatch, getState) => {
dispatch({ type: EDIT_SHORT_URL_TAGS_START });
const { updateShortUrlTags } = await buildShlinkApiClient(getState);
const { updateShortUrlTags } = buildShlinkApiClient(getState);
try {
const normalizedTags = await updateShortUrlTags(shortCode, domain, tags);

View File

@@ -58,7 +58,7 @@ export default handleActions({
export const listShortUrls = (buildShlinkApiClient) => (params = {}) => async (dispatch, getState) => {
dispatch({ type: LIST_SHORT_URLS_START });
const { listShortUrls } = await buildShlinkApiClient(getState);
const { listShortUrls } = buildShlinkApiClient(getState);
try {
const shortUrls = await listShortUrls(params);

View File

@@ -26,7 +26,7 @@ export default handleActions({
export const deleteTag = (buildShlinkApiClient) => (tag) => async (dispatch, getState) => {
dispatch({ type: DELETE_TAG_START });
const { deleteTags } = await buildShlinkApiClient(getState);
const { deleteTags } = buildShlinkApiClient(getState);
try {
await deleteTags([ tag ]);

View File

@@ -31,7 +31,7 @@ export const editTag = (buildShlinkApiClient, colorGenerator) => (oldName, newNa
getState
) => {
dispatch({ type: EDIT_TAG_START });
const { editTag } = await buildShlinkApiClient(getState);
const { editTag } = buildShlinkApiClient(getState);
try {
await editTag(oldName, newName);

View File

@@ -50,7 +50,7 @@ export const listTags = (buildShlinkApiClient, force = true) => () => async (dis
dispatch({ type: LIST_TAGS_START });
try {
const { listTags } = await buildShlinkApiClient(getState);
const { listTags } = buildShlinkApiClient(getState);
const tags = await listTags();
dispatch({ tags, type: LIST_TAGS });

View File

@@ -8,7 +8,7 @@ const getSelectedServerFromState = (getState) => {
return selectedServer;
};
const buildShlinkApiClient = (axios) => async (getStateOrSelectedServer) => {
const buildShlinkApiClient = (axios) => (getStateOrSelectedServer) => {
const { url, apiKey } = typeof getStateOrSelectedServer === 'function'
? getSelectedServerFromState(getStateOrSelectedServer)
: getStateOrSelectedServer;

View File

@@ -28,7 +28,7 @@ export default handleActions({
export const getShortUrlDetail = (buildShlinkApiClient) => (shortCode, domain) => async (dispatch, getState) => {
dispatch({ type: GET_SHORT_URL_DETAIL_START });
const { getShortUrl } = await buildShlinkApiClient(getState);
const { getShortUrl } = buildShlinkApiClient(getState);
try {
const shortUrl = await getShortUrl(shortCode, domain);

View File

@@ -51,7 +51,7 @@ export default handleActions({
export const getShortUrlVisits = (buildShlinkApiClient) => (shortCode, query) => async (dispatch, getState) => {
dispatch({ type: GET_SHORT_URL_VISITS_START });
const { getShortUrlVisits } = await buildShlinkApiClient(getState);
const { getShortUrlVisits } = buildShlinkApiClient(getState);
const itemsPerPage = 5000;
const isLastPage = ({ currentPage, pagesCount }) => currentPage >= pagesCount;