@internetarchive/ia-book-actions 1.1.0-alpha5 → 1.1.0-alpha7

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/demo/index.html CHANGED
@@ -390,7 +390,6 @@
390
390
  </div>
391
391
  <div>
392
392
  <button id="show_expired_modal">While Browsing (`user_has_browsed`), Expire book & show its modal</button>
393
- how_expired_modal
394
393
  </div>
395
394
  </td>
396
395
  <td class="availableToBorrow">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/ia-book-actions",
3
- "version": "1.1.0-alpha5",
3
+ "version": "1.1.0-alpha7",
4
4
  "description": "Bookreader actions for borrowable book",
5
5
  "author": "Internet Archive",
6
6
  "license": "AGPL-3.0-only",
@@ -90,7 +90,7 @@ export default class IABookActions extends LitElement {
90
90
  this.lendingOptions = {};
91
91
  this.borrowType = null; // 'browsed'|'borrowed'
92
92
  this.browseTimer = undefined; // timeout
93
- this.timerExecutionSeconds = 2;
93
+ this.timerExecutionSeconds = 3;
94
94
 
95
95
  /** @deprecated */
96
96
  this.toast = undefined;
@@ -315,7 +315,7 @@ export default class IABookActions extends LitElement {
315
315
  }
316
316
 
317
317
  /**
318
- * Show the warning modal to ask user if they are still reading
318
+ * Show the waring modal to ask user if they are still reading
319
319
  */
320
320
  async showWarningModal() {
321
321
  log('****** showWarningModal ******');
@@ -494,29 +494,28 @@ export default class IABookActions extends LitElement {
494
494
  * - show message when book is expired
495
495
  * - show message having remaining time when book is about to auto returned
496
496
  */
497
- async showToastMessage() {
498
- await this.useToastManager();
499
-
500
- // if secondsLeft < 60, consider it 1 minute
501
- let { secondsLeft } = this.loanRenewResult;
502
- if (secondsLeft === undefined) {
503
- secondsLeft = this.lendingStatus.secondsLeftOnLoan;
504
- } else {
505
- secondsLeft = secondsLeft > 60 ? secondsLeft : 60;
506
- }
507
-
508
- // eslint-disable-next-line no-undef
509
- const config = new ToastConfig();
510
- config.dismissOnClick = true;
511
- config.texts = this.loanRenewHelper?.getMessageTexts(
512
- this.loanRenewResult.texts,
513
- secondsLeft
514
- );
515
-
516
- this.toast?.showToast({
517
- config,
518
- });
519
- }
497
+ // async showToastMessage() {
498
+ // await this.useToastManager();
499
+
500
+ // // if secondsLeft < 60, consider it 1 minute
501
+ // let { secondsLeft } = this.loanRenewResult;
502
+ // if (secondsLeft === undefined) {
503
+ // secondsLeft = this.lendingStatus.secondsLeftOnLoan;
504
+ // } else {
505
+ // secondsLeft = secondsLeft > 60 ? secondsLeft : 60;
506
+ // }
507
+
508
+ // const config = new ToastConfig();
509
+ // config.dismisOnClick = true;
510
+ // config.texts = this.loanRenewHelper?.getMessageTexts(
511
+ // this.loanRenewResult.texts,
512
+ // secondsLeft
513
+ // );
514
+
515
+ // this.toast?.showToast({
516
+ // config,
517
+ // });
518
+ // }
520
519
 
521
520
  /**
522
521
  * Execute when loan is expired
@@ -690,11 +689,8 @@ export default class IABookActions extends LitElement {
690
689
  // if really updated, escape from here
691
690
  const resync = await this.reSyncTimerIfGoneOff(secondsLeft);
692
691
 
693
- if (resync) {
694
- log('startTimerCountdown --- stale, timer has resyncd', {
695
- secondsLeft,
696
- });
697
- return;
692
+ if (resync.resyncd) {
693
+ secondsLeft = resync.whatShouldLeft;
698
694
  }
699
695
 
700
696
  log('startTimerCountdown --- countdown still valid. continue...', {
@@ -743,28 +739,26 @@ export default class IABookActions extends LitElement {
743
739
  const whatShouldLeft = Math.round(secondsShouldLeft);
744
740
  const timerElSeconds = this.timerCountdownEl.secondsLeftOnLoan || 0;
745
741
 
746
- log(`reSyncTimerIfGoneOff?`, {
747
- whatIsleft,
748
- whatShouldLeft,
749
- timerElSeconds,
750
- timeLeftInMin: Math.ceil(timerSecondsLeft / 60),
751
- });
752
-
753
- if (timerElSeconds !== whatShouldLeft || whatIsleft !== whatShouldLeft) {
742
+ if (whatIsleft !== whatShouldLeft) {
754
743
  // set lending status with new time to update decrementor
755
744
  const currStatus = {
756
745
  ...this.lendingStatus,
757
746
  secondsLeftOnLoan: whatShouldLeft,
758
747
  };
759
748
  this.lendingStatus = currStatus;
760
- }
761
749
 
762
- if (whatIsleft !== whatShouldLeft) {
763
- log(`reSyncTimerIfGoneOff --- let's re-sync.`);
750
+ log(`reSyncTimerIfGoneOff,\nlet's re-sync --- `, {
751
+ whatIsleft,
752
+ whatShouldLeft,
753
+ timerElSeconds,
754
+ timeLeftInMin: Math.ceil(timerSecondsLeft / 60),
755
+ }, '\ntimer resyncd --- ', {
756
+ whatShouldLeft,
757
+ });
764
758
 
765
- return true;
759
+ return { resyncd: true, whatShouldLeft };
766
760
  }
767
- return false;
761
+ return { resyncd: false, whatShouldLeft };
768
762
  }
769
763
 
770
764
  /**