diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 36d82dded..07e55f17f 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -1178,17 +1178,24 @@ }) } - function getUserSyncs(options) { + async function getUserSyncs(options) { if (!options) { options = {}; } var userId = getId(options) - return $.ajax({ - type: 'GET', - dataType: "json", - url: "/api/users/" + userId + "/syncs?" + $.param(options), - processData: false - }) + + try { + return await $.ajax({ + type: 'GET', + dataType: "json", + url: "/api/users/" + userId + "/syncs?" + $.param(options), + processData: false + }) + } catch (error) { + console.error(error); + throw(error) + } + } function getUserSync(options) { @@ -1503,11 +1510,11 @@ function deleteRecordingClaim(id) { return $.ajax({ - type: "DELETE", - dataType: "json", - contentType: 'application/json', - url: "/api/recordings/" + id + "/claim" - }); + type: "DELETE", + dataType: "json", + contentType: 'application/json', + url: "/api/recordings/" + id + "/claim" + }); } function claimRecording(options) { diff --git a/web/app/assets/javascripts/paginator.js b/web/app/assets/javascripts/paginator.js index b77906538..6f35fd198 100644 --- a/web/app/assets/javascripts/paginator.js +++ b/web/app/assets/javascripts/paginator.js @@ -41,10 +41,9 @@ var working = paginator.data('working'); if(!working) { paginator.data('working', true); - + onPageSelected(targetPage) - .then(function(resp) { - const [data, textStatus, jqXHR] = resp; + .then(function(data, textStatus, jqXHR) { totalEntries = data.total_entries || parseInt(jqXHR.getResponseHeader('total-entries')); pages = calculatePages(totalEntries, perPage); options = { pages: pages, @@ -58,12 +57,9 @@ paginator.data('working', false); }) - .catch(function(){ + .catch(function(err){ paginator.data('working', false); }); - // .always(function() { - // paginator.data('working', false); - // }); } else { diff --git a/web/app/assets/javascripts/sync_viewer.js.coffee b/web/app/assets/javascripts/sync_viewer.js.coffee index 6d35e6baa..563734e64 100644 --- a/web/app/assets/javascripts/sync_viewer.js.coffee +++ b/web/app/assets/javascripts/sync_viewer.js.coffee @@ -108,8 +108,7 @@ context.JK.SyncViewer = class SyncViewer getUserSyncs: (page) => @rest.getUserSyncs({since: page * @limit, limit: @limit}) - .done(this.processUserSyncs) - + .then((response) => this.processUserSyncs(response)) load: () => @list.empty() @@ -118,7 +117,7 @@ context.JK.SyncViewer = class SyncViewer this.renderHeader() this.getUserSyncs(0) - .done((response) => + .then((response) => $paginator = context.JK.Paginator.create(response.total_entries, @limit, 0, this.getUserSyncs) @paginator.empty().append($paginator); ) @@ -973,31 +972,31 @@ context.JK.SyncViewer = class SyncViewer title: "Confirm Deletion", html: "Are you sure you want to delete this recording?", yes: () => { - this.rest.deleteRecordingClaim(recordingId).done(async response=> { + rest.deleteRecordingClaim(recordingId) + .done(async (response) => { const cmd = { type: 'recording_directory', action: 'delete', queue: 'cleanup', recording_id: recordingId}; - // now check if the sync is gone entirely, allowing us to delete it from the UI - this.rest.getUserSync({user_sync_id: recordingId}).done(userSync => { + rest.getUserSync({user_sync_id: recordingId}).done(userSync => { // the user sync is still here. tell user it'll be done as soon as they've uploaded their files - return context.JK.ackBubble($delete, 'file-sync-delayed-deletion', {}, {offsetParent: $delete.closest('.dialog')}); + context.JK.ackBubble($delete, 'file-sync-delayed-deletion', {}, {offsetParent: $delete.closest('.dialog')}); }) .fail(function(xhr) { if (xhr.status === 404) { // the userSync is gone; remove from file manager dynamically const $recordingHolder = $details.closest('.recording-holder'); - return $recordingHolder.slideUp(); + $recordingHolder.slideUp(); } else { - return this.app.ajaxError(arguments); + app.ajaxError(arguments); } - }.bind(this)); + }); await context.jamClient.OnTrySyncCommand(cmd); }) - .fail(this.app.ajaxError); + //.fail(app.ajaxError); } }); @@ -1096,7 +1095,6 @@ context.JK.SyncViewer = class SyncViewer # @since = response.next processUserSyncs: `async function(response){ - this.list.empty(); // check if no entries @@ -1147,7 +1145,8 @@ context.JK.SyncViewer = class SyncViewer this.separateByRecording(); - return this.since = response.next; + this.since = response.next; + return response; }` resolveTrack: (commandMetadata) =>