@internetarchive/ia-book-actions 0.0.29-alpha7 → 0.0.29-alpha9

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.0.29-alpha7",
3
+ "version": "0.0.29-alpha9",
4
4
  "description": "Bookreader actions for borrowable book",
5
5
  "author": "Internet Archive",
6
6
  "license": "AGPL-3.0-only",
@@ -23,7 +23,6 @@ export default class TimerCountdown extends LitElement {
23
23
 
24
24
  updated(changed) {
25
25
  if (changed.has('time') && this.time > 0) {
26
-
27
26
  clearInterval(this.timerInterval);
28
27
  this.timerCountdown();
29
28
  }
@@ -27,7 +27,7 @@ export class OneHourAutoRenew {
27
27
 
28
28
  // private props
29
29
  this.resultRes = {
30
- toastTexts: this.autoReturnMessage,
30
+ toastTexts: '',
31
31
  hideToast: true,
32
32
  renewNow: false,
33
33
  browseAgainNow: false,
@@ -36,7 +36,7 @@ export class OneHourAutoRenew {
36
36
  return this.handleBookAutoRenew();
37
37
  }
38
38
 
39
- async handleBookAutoRenew() {
39
+ handleBookAutoRenew() {
40
40
  try {
41
41
  // if page is not clicked in last 15 minutes,
42
42
  // instantaly renew it if user viewed new page in last 10 minutes
@@ -84,8 +84,6 @@ export class OneHourAutoRenew {
84
84
  this.resultRes.browseAgainNow = true;
85
85
 
86
86
  this.setNewBrowseTime();
87
- } else {
88
- console.log("can't autorenew this time!");
89
87
  }
90
88
 
91
89
  this.setPageFlippedTime();
@@ -117,6 +117,9 @@ export default class IABookActions extends LitElement {
117
117
  this.addEventListener('autoRenewAttempt', async event => {
118
118
  const isPageClick = event.detail.bookPageChange;
119
119
 
120
+ // early return if user is not browsed book
121
+ if (isPageClick && this.borrowType !== 'browsed') return nothing;
122
+
120
123
  this.autoRenewRes = await new OneHourAutoRenew(
121
124
  isPageClick,
122
125
  this.identifier,
@@ -132,9 +135,17 @@ export default class IABookActions extends LitElement {
132
135
  this.browseAgainNow = this.autoRenewRes.browseAgainNow;
133
136
 
134
137
  if (this.browseAgainNow) {
138
+ this.tokenPoller.disconnectedInterval();
139
+
140
+ // start tokenPoller after 2 minute
141
+ setTimeout(() => {
142
+ this.startLoanTokenPoller();
143
+ }, this.tokenDelay);
144
+
135
145
  await this.browseHasRenew();
136
- // this.resetTimerCountdown = true;
137
146
  }
147
+
148
+ return nothing;
138
149
  });
139
150
  }
140
151
 
@@ -162,7 +173,6 @@ export default class IABookActions extends LitElement {
162
173
  secondsLeftOnLoan: secondsLeft,
163
174
  };
164
175
  this.lendingStatus = currStatus;
165
- // this.performUpdate()
166
176
 
167
177
  this.startBrowseTimer();
168
178
  }