Skip to content

Commit

Permalink
Revert "skip simultaneous duplicated call"
Browse files Browse the repository at this point in the history
This reverts commit c453fbc.
  • Loading branch information
hj940709 committed Jan 13, 2025
1 parent c453fbc commit 545d1ab
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions client/util/apiConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Howl } from 'howler'
/**
* ApiConnection simplifies redux usage
*/
const locks = {}

const getAxios = axios.create({ baseURL: `${basePath}api` })

export const callApi = async (url, method = 'get', data, query) => {
Expand All @@ -22,25 +22,17 @@ export const callApi = async (url, method = 'get', data, query) => {
})
}

export default (route, prefix, method = 'get', data, query, cache) => {
if (method==='get' && locks[route]) {
return {
type: `${prefix}_LOCKED`,
}
}
locks[route] = true
return {
type: `${prefix}_ATTEMPT`,
requestSettings: {
route,
method,
data,
prefix,
query,
cache,
},
}
}
export default (route, prefix, method = 'get', data, query, cache) => ({
type: `${prefix}_ATTEMPT`,
requestSettings: {
route,
method,
data,
prefix,
query,
cache,
},
})

const SERVER_UNRESPONSIVE_STATUSES = [502, 503, 504]
const SERVER_INTERNAL_ERROR_STATUS = 500
Expand Down Expand Up @@ -180,7 +172,6 @@ export const handleRequest = store => next => async action => {
handleError(store, err, prefix, query)
}
}
locks[route] = false
}
}

Expand Down

0 comments on commit 545d1ab

Please sign in to comment.