@internetarchive/ia-book-actions 0.0.7-10 → 0.0.7-11
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
|
@@ -12,6 +12,7 @@ export class LoanTokenPoller extends LitElement {
|
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
14
14
|
this.identifier = '';
|
|
15
|
+
this.callback = () => {};
|
|
15
16
|
this.loanTokenPollingDelay = window.location.pathname === '/demo/' ? 2000 : 120000; // 120000 ms = 2 min
|
|
16
17
|
this.loanTokenInterval = undefined;
|
|
17
18
|
this.localCache = new LocalCache();
|
|
@@ -21,8 +22,9 @@ export class LoanTokenPoller extends LitElement {
|
|
|
21
22
|
this.loanTokenInterval = undefined;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
async enableBookAccess(identifier, borrowType) {
|
|
25
|
+
async enableBookAccess(identifier, borrowType, callback) {
|
|
25
26
|
this.identifier = identifier
|
|
27
|
+
this.callback = callback;
|
|
26
28
|
let consecutiveLoanCounts = 1;
|
|
27
29
|
|
|
28
30
|
if (borrowType) {
|
|
@@ -71,6 +73,7 @@ export class LoanTokenPoller extends LitElement {
|
|
|
71
73
|
async handleLoanTokenPoller() {
|
|
72
74
|
const action = 'create_token';
|
|
73
75
|
// await new Promise(r => setTimeout(r, 3000));
|
|
76
|
+
console.log(this.callback)
|
|
74
77
|
ActionsHandlerService({
|
|
75
78
|
identifier: this.identifier,
|
|
76
79
|
action,
|
|
@@ -79,7 +82,11 @@ export class LoanTokenPoller extends LitElement {
|
|
|
79
82
|
this.handleLendingActionError({detail: { action, data }})
|
|
80
83
|
// this.dispatchActionError(action, data);
|
|
81
84
|
clearInterval(this.loanTokenInterval); // stop token fetch api
|
|
85
|
+
this.callback();
|
|
82
86
|
},
|
|
87
|
+
success: () => {
|
|
88
|
+
this.callback();
|
|
89
|
+
}
|
|
83
90
|
});
|
|
84
91
|
}
|
|
85
92
|
|
package/src/ia-book-actions.js
CHANGED
|
@@ -66,7 +66,7 @@ export default class IABookActions extends LoanTokenPoller {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
updated(changed) {
|
|
69
|
-
console.log(changed)
|
|
69
|
+
// console.log(changed)
|
|
70
70
|
if (changed.has('lendingStatus') || changed.has('bwbPurchaseUrl')) {
|
|
71
71
|
this.setupLendingToolbarActions();
|
|
72
72
|
this.update();
|
|
@@ -159,18 +159,18 @@ export default class IABookActions extends LoanTokenPoller {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
console.log('this.borrowType', this.borrowType);
|
|
162
|
-
// enable access of borrowed/browsed books
|
|
163
|
-
if (this.borrowType) {
|
|
164
|
-
await this.enableBookAccess(this.identifier, this.borrowType);
|
|
165
|
-
}
|
|
166
162
|
|
|
167
163
|
/**
|
|
168
|
-
* this callback function use to:-
|
|
169
|
-
* - disptach
|
|
164
|
+
* this.lendingBarPostInit() callback function use to:-
|
|
165
|
+
* - disptach lendingFlow::PostInit event
|
|
170
166
|
* - initialize bookreader using br.init()
|
|
171
167
|
*/
|
|
172
|
-
|
|
173
|
-
|
|
168
|
+
if (this.borrowType) {
|
|
169
|
+
// enable access of borrowed/browsed books
|
|
170
|
+
this.enableBookAccess(this.identifier, this.borrowType, this.lendingBarPostInit);
|
|
171
|
+
} else {
|
|
172
|
+
this.lendingBarPostInit();
|
|
173
|
+
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
render() {
|