@internetarchive/ia-book-actions 0.1.11-b49 → 0.1.11-b50

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/ia-book-actions",
3
- "version": "0.1.11-b49",
3
+ "version": "0.1.11-b50",
4
4
  "description": "Bookreader actions for borrowable book",
5
5
  "author": "Internet Archive",
6
6
  "license": "AGPL-3.0-only",
@@ -159,7 +159,6 @@ export default class IABookActions extends LitElement {
159
159
  }
160
160
 
161
161
  if (changed.has('loanRenewResult') && this.loanRenewResult.renewNow) {
162
- log("UPDATED --- loanRenewResult.renewNow is true, clearing intervals");
163
162
  window.IALendingIntervals.clearAll();
164
163
  }
165
164
  }
@@ -259,7 +258,8 @@ export default class IABookActions extends LitElement {
259
258
  * - if book is going to renew, need to wait until renew is completed
260
259
  */
261
260
  setTimeout(() => {
262
- if (!hasExpired && !window.IALendingIntervals.tokenPoller) this.startLoanTokenPoller();
261
+ if (!hasExpired && !window.IALendingIntervals.tokenPoller)
262
+ this.startLoanTokenPoller();
263
263
  }, 100);
264
264
 
265
265
  this.requestUpdate();
@@ -281,13 +281,6 @@ export default class IABookActions extends LitElement {
281
281
  this.autoLoanRenewChecker(true);
282
282
  }
283
283
  });
284
-
285
- window.focus(() => {
286
- log('WINDOW FOCUS', this.borrowType);
287
- if (this.borrowType === 'browsed') {
288
- this.autoLoanRenewChecker(true);
289
- }
290
- });
291
284
  }
292
285
 
293
286
  /**
@@ -450,8 +443,6 @@ export default class IABookActions extends LitElement {
450
443
  * Show modal when book is auto returned
451
444
  */
452
445
  async showExpiredModal() {
453
- log('showExpiredModal()');
454
-
455
446
  const config = new ModalConfig({
456
447
  headline: '',
457
448
  showCloseButton: false,
@@ -566,14 +557,8 @@ export default class IABookActions extends LitElement {
566
557
  secondsLeftOnLoan,
567
558
  } = this.lendingStatus;
568
559
 
569
- log('startBrowseTimerstartBrowseTimer just cleared timer', {
570
- browsingExpired,
571
- user_has_browsed,
572
- secondsLeftOnLoan,
573
- });
574
-
575
560
  if (!user_has_browsed || browsingExpired) {
576
- log('user not browsed', {
561
+ log('startBrowseTimer --- !user_has_browsed || browsingExpired', {
577
562
  user_has_browsed,
578
563
  browsingExpired,
579
564
  secondsLeftOnLoan,
@@ -583,7 +568,7 @@ export default class IABookActions extends LitElement {
583
568
 
584
569
  window.IALendingIntervals.browseExpireTimeout = setTimeout(() => {
585
570
  log(
586
- 'start `this.browseTimer will fire his.browseHasExpired() - secondsLeftOnLoan',
571
+ 'startBrowseTimer > browseExpireTimeout --- will expire loan',
587
572
  secondsLeftOnLoan
588
573
  );
589
574
  this.browseHasExpired();
@@ -654,14 +639,11 @@ export default class IABookActions extends LitElement {
654
639
  */
655
640
  async handleLoanAutoRenewed(event) {
656
641
  if (this.loanRenewResult.renewNow) {
657
- // window?.IALendingIntervals?.clearAll();
658
-
659
642
  // Now, let's reset loan duration & this.lendingStatus
660
643
  const loanTime = await this.localCache.get(`${this.identifier}-loanTime`);
661
644
  const secondsLeft = Math.round((loanTime - new Date()) / 1000); // different in seconds
662
645
 
663
- // testing console....
664
- log('~~~ IABookActions: handleLoanAutoRenewed:- ', {
646
+ log('IABookActions: handleLoanAutoRenewed --- ', {
665
647
  ajaxResponse: event?.detail?.data,
666
648
  loanRenewResult: this.loanRenewResult,
667
649
  secondsLeftOnLoan: secondsLeft,
@@ -704,13 +686,13 @@ export default class IABookActions extends LitElement {
704
686
  const resync = await this.reSyncTimerIfGoneOff(secondsLeft);
705
687
 
706
688
  if (resync) {
707
- log('timer has resyncd, abort stale startTimerCountdown - ', {
689
+ log('startTimerCountdown --- stale, timer has resyncd', {
708
690
  secondsLeft,
709
691
  });
710
692
  return;
711
693
  }
712
694
 
713
- log('startTimerCountdown - countdown still valid. continue...', {
695
+ log('startTimerCountdown --- countdown still valid. continue...', {
714
696
  resync,
715
697
  secondsLeft,
716
698
  loanRenewAtLast: this.loanRenewTimeConfig.loanRenewAtLast,
@@ -773,7 +755,7 @@ export default class IABookActions extends LitElement {
773
755
  }
774
756
 
775
757
  if (whatIsleft !== whatShouldLeft) {
776
- log(`timer is gone off, let's re-sync,`);
758
+ log(`reSyncTimerIfGoneOff --- let's re-sync.`);
777
759
 
778
760
  return true;
779
761
  }
@@ -789,7 +771,10 @@ export default class IABookActions extends LitElement {
789
771
  * @memberof IABookActions
790
772
  */
791
773
  async loanRenewAttempt(secondsLeft) {
792
- log('loanRenewAttempt()', secondsLeft, this.loanRenewResult);
774
+ log('loanRenewAttempt ---', {
775
+ secondsLeft,
776
+ loanRenewResult: this.loanRenewResult,
777
+ });
793
778
  let loanSecondsLeft = secondsLeft;
794
779
  /**
795
780
  * auto-renew is not possible in last seconds (let say 50 second) because,
@@ -799,7 +784,7 @@ export default class IABookActions extends LitElement {
799
784
  * so if seconds left is < 50, just expire the loan
800
785
  */
801
786
  if (loanSecondsLeft < 50) {
802
- log('if (loanSecondsLeft < 50) {');
787
+ log('loanRenewAttempt --- loanSecondsLeft < 50, will expire');
803
788
  await this.browseHasExpired();
804
789
  return;
805
790
  }