Refactor code execution to use async functions
This refactoring is required for Sentry tracing. It ensures that the respective functions only return as soon as a code execution finished. With this approach, we can then instrument the duration of the functions, so that Sentry spans are created as desired. Co-authored-by: Jan Graichen <jgraichen@altimos.de>
This commit is contained in:

committed by
Sebastian Serth

parent
c8609e5392
commit
86c67f3c9a
@@ -28,13 +28,13 @@ $(document).on('turbolinks:load', function() {
|
||||
function submitCode(event) {
|
||||
const button = $(event.target) || $('#submit');
|
||||
this.startSentryTransaction(button);
|
||||
this.createSubmission(button, null, function (response) {
|
||||
if (response.redirect) {
|
||||
this.autosaveIfChanged();
|
||||
this.stopCode(event);
|
||||
this.editors = [];
|
||||
Turbolinks.clearCache();
|
||||
Turbolinks.visit(response.redirect);
|
||||
}
|
||||
})
|
||||
const submission = await this.createSubmission(button, null).catch(this.ajaxError.bind(this));
|
||||
if (!submission) return;
|
||||
if (!submission.redirect) return;
|
||||
|
||||
this.autosaveIfChanged();
|
||||
this.stopCode(event);
|
||||
this.editors = [];
|
||||
Turbolinks.clearCache();
|
||||
Turbolinks.visit(submission.redirect);
|
||||
}
|
||||
|
Reference in New Issue
Block a user