Chore create and update doesn't return useful other than id when we area creating. so we dismiss the value being returned
This commit is contained in:
@@ -191,13 +191,7 @@ export const useCreateChore = () => {
|
|||||||
if (!createdChore) {
|
if (!createdChore) {
|
||||||
throw new Error('Failed to get created chore data')
|
throw new Error('Failed to get created chore data')
|
||||||
}
|
}
|
||||||
// Successfully created the chore on the server, return the created chore
|
return { ...newTask, id: createdChore.res }
|
||||||
// update the local chores cache with the new chore:
|
|
||||||
queryClient.setQueryData(['chores', false], oldData => {
|
|
||||||
if (!oldData) return { res: [createdChore.res] }
|
|
||||||
return { res: [...oldData.res, createdChore.res] }
|
|
||||||
})
|
|
||||||
return createdChore.res
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (isNetworkError(error)) {
|
if (isNetworkError(error)) {
|
||||||
return queueOfflineCreate(newTask)
|
return queueOfflineCreate(newTask)
|
||||||
@@ -258,7 +252,7 @@ export const useUpdateChore = () => {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return updatedChoreRes?.res || updatedChoreRes
|
return updatedChoreRes?.res || updatedChore
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (isNetworkError(error)) {
|
if (isNetworkError(error)) {
|
||||||
return queueOfflineUpdate()
|
return queueOfflineUpdate()
|
||||||
|
|||||||
Reference in New Issue
Block a user