Рефакторинг

This commit is contained in:
Book Pauk
2022-10-25 16:57:53 +07:00
parent b598a43361
commit 5c03e06648

View File

@@ -197,69 +197,41 @@ class Api {
} else if (response && response.error == 'server_busy') { } else if (response && response.error == 'server_busy') {
await this.showBusyDialog(); await this.showBusyDialog();
} else { } else {
if (response.error) {
throw new Error(response.error);
}
return response; return response;
} }
} }
} }
async authorSearch(query) { async authorSearch(query) {
const response = await this.request({action: 'author-search', query}); return await this.request({action: 'author-search', query});
if (response.error) {
throw new Error(response.error);
} }
return response; async seriesSearch(query) {
return await this.request({action: 'series-search', query});
} }
async getAuthorBookList(authorId) { async getAuthorBookList(authorId) {
const response = await this.request({action: 'get-author-book-list', authorId}); return await this.request({action: 'get-author-book-list', authorId});
if (response.error) {
throw new Error(response.error);
}
return response;
} }
async getSeriesBookList(series) { async getSeriesBookList(series) {
const response = await this.request({action: 'get-series-book-list', series}); return await this.request({action: 'get-series-book-list', series});
if (response.error) {
throw new Error(response.error);
}
return response;
} }
async getGenreTree() { async getGenreTree() {
const response = await this.request({action: 'get-genre-tree'}); return await this.request({action: 'get-genre-tree'});
if (response.error) {
throw new Error(response.error);
}
return response;
} }
async getBookLink(params) { async getBookLink(params) {
const response = await this.request(Object.assign({action: 'get-book-link'}, params), 120); return await this.request(Object.assign({action: 'get-book-link'}, params), 120);
if (response.error) {
throw new Error(response.error);
}
return response;
} }
async getConfig() { async getConfig() {
const response = await this.request({action: 'get-config'}); return await this.request({action: 'get-config'});
if (response.error) {
throw new Error(response.error);
}
return response;
} }
} }