@internetarchive/ia-book-actions 0.0.6-4 → 0.0.6-5
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
|
@@ -32,8 +32,12 @@ export default function ActionsHandlerService(options) {
|
|
|
32
32
|
body: formData,
|
|
33
33
|
})
|
|
34
34
|
.then(response => {
|
|
35
|
+
// test changes, (won't affect you)
|
|
35
36
|
if (baseHost == '/demo/1' || baseHost == '/demo/') {
|
|
36
|
-
return {
|
|
37
|
+
return {
|
|
38
|
+
error: 'This book is not available to browse at this time. Please try again later.',
|
|
39
|
+
// error: 'This book is not available to borrow at this time. Please try again later.',
|
|
40
|
+
};
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
// The response is a Response instance.
|
|
@@ -97,7 +97,6 @@ export default class ActionsHandler extends LitElement {
|
|
|
97
97
|
this.handleReadItNow();
|
|
98
98
|
},
|
|
99
99
|
error: data => {
|
|
100
|
-
console.log(data);
|
|
101
100
|
alert(data.error);
|
|
102
101
|
this.toggleActionBarState(context, data);
|
|
103
102
|
},
|
|
@@ -116,7 +115,6 @@ export default class ActionsHandler extends LitElement {
|
|
|
116
115
|
URLHelper.goToUrl(`/details/${this.identifier}`, true);
|
|
117
116
|
},
|
|
118
117
|
error: data => {
|
|
119
|
-
console.log(data);
|
|
120
118
|
alert(data.error);
|
|
121
119
|
this.toggleActionBarState(context);
|
|
122
120
|
},
|
|
@@ -134,7 +132,6 @@ export default class ActionsHandler extends LitElement {
|
|
|
134
132
|
this.handleReadItNow();
|
|
135
133
|
},
|
|
136
134
|
error: data => {
|
|
137
|
-
console.log(data);
|
|
138
135
|
alert(data.error);
|
|
139
136
|
this.toggleActionBarState(context, data);
|
|
140
137
|
},
|
|
@@ -152,7 +149,6 @@ export default class ActionsHandler extends LitElement {
|
|
|
152
149
|
URLHelper.goToUrl(URLHelper.getRedirectUrl(), true);
|
|
153
150
|
},
|
|
154
151
|
error: data => {
|
|
155
|
-
console.log(data);
|
|
156
152
|
alert(data.error);
|
|
157
153
|
this.toggleActionBarState(context);
|
|
158
154
|
},
|
|
@@ -170,7 +166,6 @@ export default class ActionsHandler extends LitElement {
|
|
|
170
166
|
URLHelper.goToUrl(URLHelper.getRedirectUrl(), true);
|
|
171
167
|
},
|
|
172
168
|
error: data => {
|
|
173
|
-
console.log(data);
|
|
174
169
|
alert(data.error);
|
|
175
170
|
this.toggleActionBarState(context);
|
|
176
171
|
},
|
|
@@ -230,7 +225,7 @@ export default class ActionsHandler extends LitElement {
|
|
|
230
225
|
toggleActionBarState(context, data = {}) {
|
|
231
226
|
this.dispatchEvent(
|
|
232
227
|
new CustomEvent('toggle-action-bar-state', {
|
|
233
|
-
detail: { context, data }
|
|
228
|
+
detail: { context, data },
|
|
234
229
|
})
|
|
235
230
|
);
|
|
236
231
|
}
|
package/src/ia-book-actions.js
CHANGED
|
@@ -183,18 +183,20 @@ export default class IABookActions extends LitElement {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
toggleActionBarState(e) {
|
|
186
|
-
|
|
186
|
+
// toggle activity loader
|
|
187
|
+
this.disable = !this.disable;
|
|
187
188
|
|
|
188
189
|
// update action bar states is book is not available to browse or borrow.
|
|
189
190
|
if (e?.detail?.data?.error) {
|
|
190
191
|
const errorMsg = e.detail.data.error;
|
|
191
|
-
if (errorMsg.match(/
|
|
192
|
-
const currStatus = {
|
|
192
|
+
if (errorMsg.match(/not available to browse/gm)) {
|
|
193
|
+
const currStatus = {...this.lendingStatus, available_to_browse: false };
|
|
194
|
+
this.lendingStatus = currStatus;
|
|
195
|
+
} else if (errorMsg.match(/not available to borrow/gm)) {
|
|
196
|
+
const currStatus = { ...this.lendingStatus, available_to_borrow: false };
|
|
193
197
|
this.lendingStatus = currStatus;
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
|
-
|
|
197
|
-
this.disable = !this.disable;
|
|
198
200
|
}
|
|
199
201
|
|
|
200
202
|
get iconClass() {
|