fix: admin/fs: resaving same masks field led to losing it

Massimo Melina committed Jun 3, 2022 at 17:44 UTC 8a37e408f2f75fa9ca36b816a9316fb08e577ba2
1 file changed +2 -3
admin/src/FileForm.ts
+2 -3
@@ -61,8 +61,7 @@ export default function FileForm({ file }: { file: VfsNode }) {
61 save: {
62 sx: modifiedSx(!isEqualLax(values, file)),
63 async onClick() {
64 - const props = _.pickBy(values, (v,k) =>
65 - v !== file[k as keyof typeof values])
64 + const props = { ...values }
65 if (!props.masks)
66 props.masks = null // undefined cannot be serialized
67 if (!isRoot)
@@ -71,7 +70,7 @@ export default function FileForm({ file }: { file: VfsNode }) {
70 uri: values.id,
71 props,
72 })
74 - if (props.name) // when the name changes, the id of the selected file is changing too, and we have to update it in the state if we want it to be correctly re-selected after reload
73 + if (props.name !== file.name) // when the name changes, the id of the selected file is changing too, and we have to update it in the state if we want it to be correctly re-selected after reload
74 state.selectedFiles[0].id = file.id.slice(0, -file.name.length) + props.name
75 reloadVfs()
76 }