Рефакторинг
This commit is contained in:
@@ -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) {
|
async seriesSearch(query) {
|
||||||
throw new Error(response.error);
|
return await this.request({action: 'series-search', query});
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user