@stoker-platform/web-app 0.5.215 → 0.5.216

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.216
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: prevent redirect to newly created records before server write completes
8
+
3
9
  ## 0.5.215
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.215",
3
+ "version": "0.5.216",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
package/src/Form.tsx CHANGED
@@ -4183,7 +4183,7 @@ function RecordForm({
4183
4183
  }
4184
4184
 
4185
4185
  const onValid = () => {
4186
- if (!isServerReadOnly) {
4186
+ if (!(serverWrite || isServerReadOnly)) {
4187
4187
  if (onSuccess) onSuccess({ ...recordToSave, id: docId, Collection_Path: path } as StokerRecord)
4188
4188
  }
4189
4189
  }
@@ -4211,6 +4211,8 @@ function RecordForm({
4211
4211
 
4212
4212
  if (isServerReadOnly) {
4213
4213
  setIsAddingServer(false)
4214
+ }
4215
+ if (serverWrite || isServerReadOnly) {
4214
4216
  if (onSuccess)
4215
4217
  onSuccess({ ...recordToSave, id: docId, Collection_Path: path } as StokerRecord)
4216
4218
  }
@@ -4276,7 +4278,11 @@ function RecordForm({
4276
4278
  return
4277
4279
  }
4278
4280
  const serverWrite = isServerUpdate(collection, { ...recordToSave, id }, userData)
4279
- const optimisticUpdate = { ...originalRecord, ...cloneDeep(recordToSave) } as StokerRecord
4281
+ const optimisticUpdate = {
4282
+ ...(originalRecord ?? record),
4283
+ ...cloneDeep(recordToSave),
4284
+ id,
4285
+ } as StokerRecord
4280
4286
  setOptimisticUpdate(labels.collection, optimisticUpdate)
4281
4287
 
4282
4288
  setGlobalLoading("+", id, serverWrite, !(serverWrite || isServerReadOnly))