Работа над списком книг в серии

This commit is contained in:
Book Pauk
2022-10-10 17:02:58 +07:00
parent ec96d4af39
commit 0e2ef4133e
6 changed files with 139 additions and 10 deletions

View File

@@ -220,6 +220,16 @@ class Api {
return response;
}
async getSeriesBookList(seriesId) {
const response = await this.request({action: 'get-series-book-list', seriesId});
if (response.error) {
throw new Error(response.error);
}
return response;
}
async getGenreTree() {
const response = await this.request({action: 'get-genre-tree'});

View File

@@ -878,6 +878,29 @@ class Search {
}
}
async loadSeriesBooks(seriesId) {
try {
let result;
if (this.abCacheEnabled) {
const key = `series-${seriesId}-${this.inpxHash}`;
const data = await authorBooksStorage.getData(key);
if (data) {
result = JSON.parse(data);
} else {
result = await this.api.getBookList(seriesId);
await authorBooksStorage.setData(key, JSON.stringify(result));
}
} else {
result = await this.api.getBookList(seriesId);
}
return JSON.parse(result.books);
} catch (e) {
this.$root.stdDialog.alert(e.message, 'Ошибка');
}
}
filterBooks(loadedBooks) {
const s = this.search;