@internetarchive/ia-book-actions 0.1.0 → 0.1.2
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
CHANGED
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
let loanTotalTime5Min = { loanTotalTime: 300, loanRenewAtLast: 180, pageChangedInLast: 15 };
|
|
136
136
|
let loanTotalTime1Hour = { loanTotalTime: 3600, loanRenewAtLast: 600, pageChangedInLast: 900 };
|
|
137
137
|
|
|
138
|
-
iaBookActions.loanRenewTimeConfig =
|
|
138
|
+
iaBookActions.loanRenewTimeConfig = loanTotalTime1Hour;
|
|
139
139
|
|
|
140
140
|
let lendingStatus1 = iaBookActions.lendingStatus;
|
|
141
141
|
let secondsLeftOnLoan = iaBookActions.loanRenewTimeConfig.loanTotalTime;
|
|
@@ -210,11 +210,14 @@
|
|
|
210
210
|
lendingStatus1.secondsLeftOnLoan = secondsLeftOnLoan;
|
|
211
211
|
lendingStatus1.browsingExpired = false;
|
|
212
212
|
|
|
213
|
+
const expireDate = new Date(
|
|
214
|
+
new Date().getTime() + iaBookActions.loanRenewTimeConfig.loanTotalTime * 1000
|
|
215
|
+
);
|
|
213
216
|
try {
|
|
214
217
|
// set a value
|
|
215
218
|
await localCache.set({
|
|
216
219
|
key: `${identifier}-loanTime`,
|
|
217
|
-
value:
|
|
220
|
+
value: expireDate,
|
|
218
221
|
ttl: Number(iaBookActions.loanRenewTimeConfig.loanTotalTime),
|
|
219
222
|
});
|
|
220
223
|
|
package/package.json
CHANGED
|
@@ -118,8 +118,7 @@ export default class TimerCountdown extends LitElement {
|
|
|
118
118
|
>
|
|
119
119
|
<circle class="circle" cx="50" cy="50" r="50" />
|
|
120
120
|
</svg>
|
|
121
|
-
<span class="sr-only">${this.remainingTime}</span>
|
|
122
|
-
<span>${this.remainingTime}</span>
|
|
121
|
+
<span class="sr-only">${this.remainingTime} left</span>
|
|
123
122
|
`;
|
|
124
123
|
}
|
|
125
124
|
|
|
@@ -130,7 +129,8 @@ export default class TimerCountdown extends LitElement {
|
|
|
130
129
|
|
|
131
130
|
return css`
|
|
132
131
|
:host {
|
|
133
|
-
right:
|
|
132
|
+
right: 0;
|
|
133
|
+
margin-right: 10px;
|
|
134
134
|
position: absolute;
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -46,17 +46,12 @@ export class LoanRenewHelper {
|
|
|
46
46
|
*/
|
|
47
47
|
async pageChanged() {
|
|
48
48
|
const {
|
|
49
|
-
loanTotalTime, // 60
|
|
50
49
|
loanRenewAtLast, // 50
|
|
51
50
|
} = this.loanRenewTimeConfig;
|
|
52
51
|
const currentTime = new Date();
|
|
53
52
|
const loanTime = await this.localCache.get(`${this.identifier}-loanTime`);
|
|
54
53
|
|
|
55
|
-
const lastTimeFrame = this.changeTime(
|
|
56
|
-
loanTime,
|
|
57
|
-
loanTotalTime - loanRenewAtLast,
|
|
58
|
-
'add'
|
|
59
|
-
);
|
|
54
|
+
const lastTimeFrame = this.changeTime(loanTime, loanRenewAtLast, 'sub');
|
|
60
55
|
|
|
61
56
|
// if user viewed new page in last 10 minutes, renew immediately
|
|
62
57
|
if (lastTimeFrame !== null && currentTime >= lastTimeFrame) {
|