From 0cbe5b5a064d99c726d4e6137b28a321bbc72381 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 31 Aug 2017 12:59:40 -0400 Subject: [PATCH] LP#1673870: avoid e-session cookie weirdness This patch is a bit of hackery to work around an intermittent (but frequent) situation where the vendor session cookie got cleared right before invoking the cancel hold method, leading to its failure. Signed-off-by: Galen Charlton Signed-off-by: Jeff Davis Signed-off-by: Bill Erickson --- .../web/js/ui/default/opac/ebook_api/loggedin.js | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Open-ILS/web/js/ui/default/opac/ebook_api/loggedin.js b/Open-ILS/web/js/ui/default/opac/ebook_api/loggedin.js index 970066a91f..abc46e5084 100644 --- a/Open-ILS/web/js/ui/default/opac/ebook_api/loggedin.js +++ b/Open-ILS/web/js/ui/default/opac/ebook_api/loggedin.js @@ -170,20 +170,24 @@ function updateHoldView() { hold_status = h.queue_position + ' / ' + h.queue_size; } h.doCancelHold = function() { - var ebook = new Ebook(this.vendor, this.title_id); - ebook.cancelHold(authtoken, patron_id, function(resp) { - if (resp.error_msg) { - console.log('Cancel hold failed: ' + resp.error_msg); - dojo.removeClass('ebook_cancel_hold_failed', "hidden"); - } else { - console.log('Cancel hold succeeded!'); - dojo.destroy("hold-" + ebook.id); - dojo.removeClass('ebook_cancel_hold_succeeded', "hidden"); - // Updating the transaction cache to remove the canceled hold - // is inconvenient, so we skip cleanupAfterAction() and merely - // clear transaction cache to force a refresh on next page load. - dojo.cookie('ebook_xact_cache', '', {path: '/', expires: '-1h'}); - } + var vendor = this.vendor; + var title_id = this.title_id; + checkSession(vendor, function() { + var ebook = new Ebook(vendor, title_id); + ebook.cancelHold(authtoken, patron_id, function(resp) { + if (resp.error_msg) { + console.log('Cancel hold failed: ' + resp.error_msg); + dojo.removeClass('ebook_cancel_hold_failed', "hidden"); + } else { + console.log('Cancel hold succeeded!'); + dojo.destroy("hold-" + ebook.id); + dojo.removeClass('ebook_cancel_hold_succeeded', "hidden"); + // Updating the transaction cache to remove the canceled hold + // is inconvenient, so we skip cleanupAfterAction() and merely + // clear transaction cache to force a refresh on next page load. + dojo.cookie('ebook_xact_cache', '', {path: '/', expires: '-1h'}); + } + }); }); }; var tr = dojo.create("tr", { id: "hold-" + h.title_id }, dojo.byId('ebook_holds_main_table_body')); -- 2.11.0