Skip to content

Commit

Permalink
Fix compatibility code in ActionsController to properly handle the ob…
Browse files Browse the repository at this point in the history
…solete UpdatedDataModels (#885)
  • Loading branch information
ivarne authored Nov 6, 2024
1 parent 4006bfc commit 7339ae8
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/Altinn.App.Api/Controllers/ActionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,25 @@ await _appMetadata.GetApplicationMetadata(),
);
}

#pragma warning disable CS0618 // Type or member is obsolete

// Ensure that the data mutator has the previous binary data for the data elements
// that were updated so that it shows up in diff for validation
// and ensures that it gets saved to storage
if (result.UpdatedDataModels is { Count: > 0 })
{
await Task.WhenAll(
result.UpdatedDataModels.Select(row => dataMutator.GetFormData(new DataElementIdentifier(row.Key)))
);
foreach (var (elementId, data) in result.UpdatedDataModels)
{
// If the data mutator missed a that was returned with the deprecated UpdatedDataModels
// we still need to return it to the frontend, but we assume it was already saved to storage
dataMutator.SetFormData(new DataElementIdentifier(elementId), data);
}
}
#pragma warning restore CS0618 // Type or member is obsolete

var changes = dataMutator.GetDataElementChanges(initializeAltinnRowId: true);

await dataMutator.UpdateInstanceData(changes);
Expand All @@ -198,17 +217,6 @@ await _appMetadata.GetApplicationMetadata(),
c => c.CurrentFormData
);

#pragma warning disable CS0618 // Type or member is obsolete
if (result.UpdatedDataModels is { Count: > 0 })
{
foreach (var (elementId, data) in result.UpdatedDataModels)
{
// If the data mutator missed a that was returned with the deprecated UpdatedDataModels
// we still need to return it to the frontend, but we assume it was already saved to storage
updatedDataModels.TryAdd(elementId, data);
}
}
#pragma warning restore CS0618 // Type or member is obsolete
return Ok(
new UserActionResponse()
{
Expand Down

0 comments on commit 7339ae8

Please sign in to comment.