LP#1673870: avoid e-session cookie weirdness
authorGalen Charlton <gmc@equinoxinitiative.org>
Thu, 31 Aug 2017 16:59:40 +0000 (12:59 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 1 Sep 2017 20:06:50 +0000 (16:06 -0400)
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 <gmc@equinoxinitiative.org>
Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/web/js/ui/default/opac/ebook_api/loggedin.js

index 970066a..abc46e5 100644 (file)
@@ -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'));