From 0d644126d959f2cce3fbf7f90b7d93928a571ef7 Mon Sep 17 00:00:00 2001 From: satellitestudiodesign Date: Thu, 8 Aug 2024 13:25:34 +0200 Subject: [PATCH] fix save workspace retry --- apps/fishing-map/features/workspace/workspace.slice.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/fishing-map/features/workspace/workspace.slice.ts b/apps/fishing-map/features/workspace/workspace.slice.ts index 607f58a4fd..333911845c 100644 --- a/apps/fishing-map/features/workspace/workspace.slice.ts +++ b/apps/fishing-map/features/workspace/workspace.slice.ts @@ -317,7 +317,7 @@ export const saveWorkspaceThunk = createAsyncThunk( const saveWorkspace = async (tries = 0): Promise | undefined> => { let workspaceUpdated - if (tries < 2) { + if (tries < 4) { try { const name = tries > 0 ? defaultName + `_${tries}` : defaultName workspaceUpdated = await GFWAPI.fetch>(`/workspaces`, { @@ -338,7 +338,7 @@ export const saveWorkspaceThunk = createAsyncThunk( } as FetchOptions>) } 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)