@internetarchive/ia-book-actions 0.0.8 → 0.0.9
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 +1 -1
- package/src/components/info-icon.js +1 -1
- package/src/ia-book-actions.js +40 -32
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ export class InfoIcon extends LitElement {
|
|
|
13
13
|
super();
|
|
14
14
|
this.iconClass = '';
|
|
15
15
|
this.helpURL =
|
|
16
|
-
'https://help.archive.org/
|
|
16
|
+
'https://help.archive.org/help/borrowing-from-the-lending-library';
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
render() {
|
package/src/ia-book-actions.js
CHANGED
|
@@ -162,39 +162,13 @@ export default class IABookActions extends LitElement {
|
|
|
162
162
|
this.startBrowseTimer();
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
* it takes 5 params
|
|
170
|
-
* 1. this.identifier
|
|
171
|
-
* 2. this.borrowType
|
|
172
|
-
* 3. successCallback - it used to
|
|
173
|
-
* - disptach lendingFlow::PostInit event
|
|
174
|
-
* - initialize bookreader using br.init()
|
|
175
|
-
* 4. errorCallback
|
|
176
|
-
* 5. tokenPollerDelay
|
|
177
|
-
*/
|
|
178
|
-
if (this.barType === 'action') {
|
|
179
|
-
if (this.tokenPoller) {
|
|
180
|
-
this.tokenPoller.disconnectedInterval();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const successCallback = () => {
|
|
184
|
-
this.lendingBarPostInit();
|
|
185
|
-
};
|
|
186
|
-
const errorCallback = eventObj => {
|
|
187
|
-
this.handleLendingActionError(eventObj);
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
this.tokenPoller = new LoanTokenPoller(
|
|
191
|
-
this.identifier,
|
|
192
|
-
this.borrowType,
|
|
193
|
-
successCallback,
|
|
194
|
-
errorCallback,
|
|
195
|
-
this.tokenDelay // 1000 ms = 1 sec
|
|
196
|
-
);
|
|
165
|
+
// early return if not borrowed or no action-bar
|
|
166
|
+
if (!this.borrowType || this.barType === 'title') {
|
|
167
|
+
this.lendingBarPostInit();
|
|
168
|
+
return;
|
|
197
169
|
}
|
|
170
|
+
|
|
171
|
+
this.startLoanTokenPoller();
|
|
198
172
|
}
|
|
199
173
|
|
|
200
174
|
render() {
|
|
@@ -236,6 +210,40 @@ export default class IABookActions extends LitElement {
|
|
|
236
210
|
`;
|
|
237
211
|
}
|
|
238
212
|
|
|
213
|
+
/**
|
|
214
|
+
* enable access of borrowed/browsed books
|
|
215
|
+
*/
|
|
216
|
+
startLoanTokenPoller() {
|
|
217
|
+
if (this.tokenPoller) {
|
|
218
|
+
this.tokenPoller.disconnectedInterval();
|
|
219
|
+
}
|
|
220
|
+
const successCallback = () => {
|
|
221
|
+
this.lendingBarPostInit();
|
|
222
|
+
};
|
|
223
|
+
const errorCallback = eventObj => {
|
|
224
|
+
this.handleLendingActionError(eventObj);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* LoanTokenPoller is a class that polls the loan token
|
|
229
|
+
* it takes 5 params
|
|
230
|
+
* 1. this.identifier
|
|
231
|
+
* 2. this.borrowType
|
|
232
|
+
* 3. successCallback - it used to
|
|
233
|
+
* - disptach lendingFlow::PostInit event
|
|
234
|
+
* - initialize bookreader using br.init()
|
|
235
|
+
* 4. errorCallback
|
|
236
|
+
* 5. tokenPollerDelay
|
|
237
|
+
*/
|
|
238
|
+
this.tokenPoller = new LoanTokenPoller(
|
|
239
|
+
this.identifier,
|
|
240
|
+
this.borrowType,
|
|
241
|
+
successCallback,
|
|
242
|
+
errorCallback,
|
|
243
|
+
this.tokenDelay // 1000 ms = 1 sec
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
239
247
|
/*
|
|
240
248
|
* custom event handler to toggle action group visibility
|
|
241
249
|
*
|