Skip to content

Commit

Permalink
Revert "fix: refresh stale data on update form"
Browse files Browse the repository at this point in the history
This reverts commit 7ab3126.
  • Loading branch information
Scott Young authored and hein-j committed Nov 18, 2022
1 parent e658019 commit b1444cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3896,9 +3896,8 @@ export default function MyPostForm(props) {
modelFields = onSubmit(modelFields);
}
try {
const original = await DataStore.query(Post, id);
await DataStore.save(
Post.copyOf(original, (updated) => {
Post.copyOf(postRecord, (updated) => {
Object.assign(updated, modelFields);
})
);
Expand Down Expand Up @@ -4471,9 +4470,8 @@ export default function MyFlexUpdateForm(props) {
modelFields = onSubmit(modelFields);
}
try {
const original = await DataStore.query(Flex0, id);
await DataStore.save(
Flex0.copyOf(original, (updated) => {
Flex0.copyOf(flex0Record, (updated) => {
Object.assign(updated, modelFields);
})
);
Expand Down Expand Up @@ -6462,9 +6460,8 @@ export default function InputGalleryUpdateForm(props) {
modelFields = onSubmit(modelFields);
}
try {
const original = await DataStore.query(InputGallery, id);
await DataStore.save(
InputGallery.copyOf(original, (updated) => {
InputGallery.copyOf(inputGalleryRecord, (updated) => {
Object.assign(updated, modelFields);
})
);
Expand Down
25 changes: 1 addition & 24 deletions packages/codegen-ui-react/lib/forms/form-renderer-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,29 +555,6 @@ export const buildOnChangeStatement = (
export const buildDataStoreExpression = (dataStoreActionType: 'update' | 'create', importedModelName: string) => {
if (dataStoreActionType === 'update') {
return [
factory.createVariableStatement(
undefined,
factory.createVariableDeclarationList(
[
factory.createVariableDeclaration(
factory.createIdentifier('original'),
undefined,
undefined,
factory.createAwaitExpression(
factory.createCallExpression(
factory.createPropertyAccessExpression(
factory.createIdentifier('DataStore'),
factory.createIdentifier('query'),
),
undefined,
[factory.createIdentifier(importedModelName), factory.createIdentifier('id')],
),
),
),
],
NodeFlags.Const,
),
),
factory.createExpressionStatement(
factory.createAwaitExpression(
factory.createCallExpression(
Expand All @@ -594,7 +571,7 @@ export const buildDataStoreExpression = (dataStoreActionType: 'update' | 'create
),
undefined,
[
factory.createIdentifier('original'),
factory.createIdentifier(`${lowerCaseFirst(importedModelName)}Record`),
factory.createArrowFunction(
undefined,
undefined,
Expand Down

0 comments on commit b1444cd

Please sign in to comment.