Skip to content

Commit

Permalink
guarding against unlikely race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
yohsii committed May 24, 2020
1 parent cf87b97 commit 763c80b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion core/Controllers/WorkflowController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public async Task<IActionResult> Notifications(int since)
public async Task<IActionResult> Create(PuckWorkflowItem model) {
var success = false;
var message = "";
PuckWorkflowItem wfi = null;
bool lockTaken = false;
try
{
Expand All @@ -118,6 +119,8 @@ public async Task<IActionResult> Create(PuckWorkflowItem model) {
repo.AddPuckWorkflowItem(model);
repo.SaveChanges();

wfi = model;

success = true;
}
catch (Exception ex)
Expand All @@ -130,7 +133,7 @@ public async Task<IActionResult> Create(PuckWorkflowItem model) {
// slock1.Release();
}

return Json(new {success=success,message=message });
return Json(new {success=success,message=message,workflowItem=wfi });
}

[HttpPost]
Expand Down
9 changes: 8 additions & 1 deletion puckweb/wwwroot/Areas/puck/assets/js/puck.actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,14 @@ var displayMarkup = function (parentId, type, variant, fromVariant,contentId,con

var userObject = { username: userName, userRoles: userRoles, userGroups: userGroups };
var services = {
add: function (status, message, group, assignees, f) { addWorkflowItem(id, variant, status, "none", message, group, type, assignees, f || function () { }); },
add: function (status, message, group, assignees, f) {
addWorkflowItem(id, variant, status, "none", message, group, type, assignees, function (data) {
setTimeout(function () {
workflowItems[id + variant] = data.workflowItem;
},500);
if (f) f();
});
},
complete: function (status, f) { completeWorkflowItem(id, variant, status || "complete", f || function () { }); },
msg: msg
};
Expand Down

0 comments on commit 763c80b

Please sign in to comment.