Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Commit

Permalink
Avoid race condition on save in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Aug 13, 2017
1 parent 9b7e181 commit 7765852
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Changelog of Pull Request Notifier for Bitbucket.

## Unreleased
### No issue
doc

[9b7e1818eac83aa](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/9b7e1818eac83aa) Tomas Bjerre *2017-08-13 16:41:06*

## 3.11
### No issue
Continuing with next notification if it crashes

Expand Down
30 changes: 18 additions & 12 deletions src/main/resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ define('plugin/prnfb/utils', [
dataType: "json",
data: jsonString,
success: function(data) {
whenDone();
if (data && data.uuid) {
doSetupForm(formSelector, url + '/' + data.uuid);
}
AJS.flag({
close: 'auto',
type: 'success',
title: 'Saved',
body: '<p>=)</p>'
whenDone(function() {
if (data && data.uuid) {
doSetupForm(formSelector, url + '/' + data.uuid);
}
AJS.flag({
close: 'auto',
type: 'success',
title: 'Saved',
body: '<p>=)</p>'
});
});
},
error: function(xhr, status, error) {
Expand Down Expand Up @@ -184,7 +185,9 @@ define('plugin/prnfb/utils', [
function setupForm(formSelector, url, postUrl) {
$(formSelector).submit(function(e) {
e.preventDefault();
postForm(postUrl, formSelector, function() {});
postForm(postUrl, formSelector, function(f) {
f();
});
});

doSetupForm(formSelector, url);
Expand All @@ -208,7 +211,8 @@ define('plugin/prnfb/utils', [
});
});

function populateSelect() {
function populateSelect(whenDone) {
clearForm(formSelector);
$.getJSON(restResource, function(data) {
$(formSelector + ' [name=uuid]').empty();
$(formSelector + ' [name=uuid]').append('<option value="">New</option>');
Expand All @@ -217,8 +221,10 @@ define('plugin/prnfb/utils', [
name = name.replace(/<script>/g, 'script');
$(formSelector + ' [name=uuid]').append('<option value="' + data[i].uuid + '">' + (data[i].projectKey || '') + ' ' + (data[i].repositorySlug || '') + ' ' + name + '</option>');
}
if (whenDone) {
whenDone();
}
});
clearForm(formSelector);
}
populateSelect();

Expand Down

0 comments on commit 7765852

Please sign in to comment.