Skip to content

Commit

Permalink
fix save workspace retry
Browse files Browse the repository at this point in the history
  • Loading branch information
satellitestudiodesign committed Aug 8, 2024
1 parent 54bb37f commit 0d64412
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/fishing-map/features/workspace/workspace.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export const saveWorkspaceThunk = createAsyncThunk(

const saveWorkspace = async (tries = 0): Promise<Workspace<WorkspaceState> | undefined> => {
let workspaceUpdated
if (tries < 2) {
if (tries < 4) {
try {
const name = tries > 0 ? defaultName + `_${tries}` : defaultName
workspaceUpdated = await GFWAPI.fetch<Workspace<WorkspaceState>>(`/workspaces`, {
Expand All @@ -338,7 +338,7 @@ export const saveWorkspaceThunk = createAsyncThunk(
} as FetchOptions<WorkspaceUpsert<WorkspaceState>>)
} catch (e: any) {
// Means we already have a workspace with this name
if (e.status === 400) {
if (e.status === 422 && e.message.includes('duplicated')) {
return await saveWorkspace(tries + 1)
}
console.warn('Error creating workspace', e)
Expand Down

0 comments on commit 0d64412

Please sign in to comment.