@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 +0 -1
- package/package.json +1 -1
- package/src/ia-book-actions.js +37 -43
package/demo/index.html
CHANGED
package/package.json
CHANGED
package/src/ia-book-actions.js
CHANGED
|
@@ -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 =
|
|
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
|
|
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
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
763
|
-
|
|
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
|
/**
|