@internetarchive/ia-book-actions 1.4.4-alpha18 → 1.4.4-alpha19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "author": "Internet Archive",
9
9
  "license": "AGPL-3.0-only",
10
- "version": "1.4.4-alpha18",
10
+ "version": "1.4.4-alpha19",
11
11
  "main": "index.js",
12
12
  "module": "index.js",
13
13
  "publishConfig": {
@@ -55,6 +55,10 @@ export default class IABookActions extends LitElement {
55
55
  type: Function,
56
56
  attribute: false,
57
57
  },
58
+ reloadPageImages: {
59
+ type: Function,
60
+ attribute: false,
61
+ },
58
62
  barType: { type: String },
59
63
  sharedObserver: { attribute: false },
60
64
  disableActionGroup: { type: Boolean },
@@ -77,6 +81,7 @@ export default class IABookActions extends LitElement {
77
81
  this.width = 0;
78
82
  this.bwbPurchaseUrl = '';
79
83
  this.lendingBarPostInit = () => {};
84
+ this.reloadPageImages = () => {};
80
85
  this.barType = 'action'; // 'title'|'action'
81
86
  this.sharedObserver = undefined;
82
87
  this.disableActionGroup = false;
@@ -762,6 +767,12 @@ export default class IABookActions extends LitElement {
762
767
  // triggered this renewal.
763
768
  this.skipNextInitialTokenCall = true;
764
769
 
770
+ // A page image requested in the gap between expiry and this renewal
771
+ // landing can come back broken — browsers don't retry a failed <img>
772
+ // on their own. Retry once, right when access is confirmed good
773
+ // again, rather than leaving it broken until the patron reloads.
774
+ this.reloadPageImages();
775
+
765
776
  if (this.recoveringFromLoanExpiry) {
766
777
  // Only now is it safe to re-initialize BookReader — not for a
767
778
  // routine top-up, where that would be disruptive. Call it
@@ -958,6 +958,7 @@ describe('autoRenewExpiredLoan', () => {
958
958
  );
959
959
  await el.updateComplete;
960
960
  el.postInitComplete = true;
961
+ el.reloadPageImages = Sinon.spy();
961
962
 
962
963
  await el.localCache.set({
963
964
  key: 'foobar-loanTime',
@@ -985,6 +986,8 @@ describe('autoRenewExpiredLoan', () => {
985
986
  await el.updateComplete;
986
987
 
987
988
  expect(startTokenPollerSpy.calledOnceWith(true)).to.be.true;
989
+ // Retries any page image broken during the gap this renewal just closed.
990
+ expect(el.reloadPageImages.called).to.be.true;
988
991
  });
989
992
 
990
993
  it('calls lendingBarPostInit directly on a recovery renewal and skips the initial create_token', async () => {
@@ -1006,6 +1009,7 @@ describe('autoRenewExpiredLoan', () => {
1006
1009
  );
1007
1010
  await el.updateComplete;
1008
1011
  el.lendingBarPostInit = Sinon.spy();
1012
+ el.reloadPageImages = Sinon.spy();
1009
1013
 
1010
1014
  await el.localCache.set({
1011
1015
  key: 'foobar-loanTime',
@@ -1030,6 +1034,7 @@ describe('autoRenewExpiredLoan', () => {
1030
1034
  // create_token success callback.
1031
1035
  expect(el.lendingBarPostInit.calledOnce).to.be.true;
1032
1036
  expect(el.postInitComplete).to.be.true;
1037
+ expect(el.reloadPageImages.called).to.be.true;
1033
1038
 
1034
1039
  await el.updateComplete;
1035
1040
  await aTimeout(150); // let the 100ms token-poller-restart check run