@internetarchive/ia-book-actions 1.1.0-alpha12 → 1.1.0-alpha14
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 +1 -1
- package/package.json +1 -1
- package/src/ia-book-actions.js +15 -9
package/demo/index.html
CHANGED
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
iaBookActions.returnUrl = '';
|
|
132
132
|
iaBookActions.localCache = localCache;
|
|
133
133
|
|
|
134
|
-
let loanTotalTime2Min = { loanTotalTime:
|
|
134
|
+
let loanTotalTime2Min = { loanTotalTime: 65, loanRenewAtLast: 60, pageChangedInLast: 15 };
|
|
135
135
|
let loanTotalTime5Min = { loanTotalTime: 300, loanRenewAtLast: 180, pageChangedInLast: 15 };
|
|
136
136
|
let loanTotalTime1Hour = { loanTotalTime: 3600, loanRenewAtLast: 660, pageChangedInLast: 900 };
|
|
137
137
|
|
package/package.json
CHANGED
package/src/ia-book-actions.js
CHANGED
|
@@ -89,7 +89,7 @@ export default class IABookActions extends LitElement {
|
|
|
89
89
|
this.lendingOptions = {};
|
|
90
90
|
this.borrowType = null; // 'browsed'|'borrowed'
|
|
91
91
|
this.browseTimer = undefined; // timeout
|
|
92
|
-
this.timerExecutionSeconds =
|
|
92
|
+
this.timerExecutionSeconds = 10;
|
|
93
93
|
|
|
94
94
|
/** @deprecated */
|
|
95
95
|
this.toast = undefined;
|
|
@@ -133,7 +133,9 @@ export default class IABookActions extends LitElement {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
sentryCaptureMsg(msg) {
|
|
136
|
-
|
|
136
|
+
log(window?.Sentry);
|
|
137
|
+
log(window?.Sentry?.captureMessage(msg));
|
|
138
|
+
if (window?.Sentry) window?.Sentry?.captureMessage(msg);
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
firstUpdated() {
|
|
@@ -289,19 +291,23 @@ export default class IABookActions extends LitElement {
|
|
|
289
291
|
|
|
290
292
|
/**
|
|
291
293
|
* auto-renew interval may stale when tab is in background,
|
|
292
|
-
*
|
|
294
|
+
* when user jump on the books tab,
|
|
295
|
+
* the [visibilitychange] event can trigger timer to show relavent messages
|
|
293
296
|
*/
|
|
294
297
|
document.addEventListener("visibilitychange", async () => {
|
|
295
298
|
if (!document.hidden) {
|
|
296
299
|
log('visibilitychange is not hidden time: ------------------ ', new Date().getMinutes(), new Date().getSeconds());
|
|
297
300
|
|
|
298
|
-
|
|
299
|
-
|
|
301
|
+
if (this.borrowType === 'browsed' && this.lendingStatus.browsingExpired === false) {
|
|
302
|
+
const loanTime = await this.localCache.get(`${this.identifier}-loanTime`);
|
|
303
|
+
const secondsLeft = Math.round((loanTime - new Date()) / 1000); // different in seconds
|
|
300
304
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
+
if (secondsLeft >= this.timerExecutionSeconds) {
|
|
306
|
+
this.setIntervalExecutionBlock(Number(secondsLeft));
|
|
307
|
+
} else {
|
|
308
|
+
this.browseHasExpired();
|
|
309
|
+
this.disconnectedCallback();
|
|
310
|
+
}
|
|
305
311
|
}
|
|
306
312
|
}
|
|
307
313
|
});
|