diff --git a/src/app/core/_datasources/hashes.datasource.ts b/src/app/core/_datasources/hashes.datasource.ts index b96d1b63..435267c9 100644 --- a/src/app/core/_datasources/hashes.datasource.ts +++ b/src/app/core/_datasources/hashes.datasource.ts @@ -3,7 +3,6 @@ import { catchError, finalize, of } from 'rxjs'; import { JHash } from '@models/hash.model'; import { Filter, FilterType } from '@models/request-params.model'; import { ResponseWrapper } from '@models/response.model'; -import { JTask } from '@models/task.model'; import { JsonAPISerializer } from '@services/api/serializer-service'; import { SERV } from '@services/main.config'; @@ -27,59 +26,21 @@ export class HashesDataSource extends BaseDataSource { this.loading = true; if (this._dataType === 'tasks') { - const paramsTasks = new RequestParamBuilder().addInitial(this).addInclude('hashlist'); - if (query) { - paramsTasks.addFilter(query); - } - const taskService = this.service.get(SERV.TASKS, this._id, paramsTasks.create()); + const hashesService = this.service.ghelper(SERV.HELPER, 'getCracksOfTask?task=' + this._id); this.subscriptions.push( - taskService + hashesService .pipe( catchError(() => of([])), finalize(() => (this.loading = false)) ) .subscribe((response: ResponseWrapper) => { - const task = new JsonAPISerializer().deserialize({ + const hashes = new JsonAPISerializer().deserialize({ data: response.data, included: response.included }); - const hashlistId = task.hashlist.id; - - const paramsHashlist = new RequestParamBuilder() - .addInitial(this) - .addInclude('hashlist') - .addFilter({ field: 'hashlistId', operator: FilterType.EQUAL, value: hashlistId }) - .addFilter({ field: 'isCracked', operator: FilterType.EQUAL, value: true }) - .addFilter({ field: 'hashlistId', operator: FilterType.EQUAL, value: hashlistId }); - if (query) { - paramsHashlist.addFilter(query); - } - const hashlistService = this.service.getAll(SERV.HASHES, paramsHashlist.create()); - - this.subscriptions.push( - hashlistService - .pipe( - catchError(() => of([])), - finalize(() => (this.loading = false)) - ) - .subscribe((responseHash: ResponseWrapper) => { - const hashes = new JsonAPISerializer().deserialize({ - data: responseHash.data, - included: responseHash.included - }); - - const length = responseHash.meta.page.total_elements; - const nextLink = responseHash.links.next; - const prevLink = responseHash.links.prev; - const after = nextLink ? new URL(nextLink).searchParams.get('page[after]') : null; - const before = prevLink ? new URL(prevLink).searchParams.get('page[before]') : null; - - this.setPaginationConfig(this.pageSize, length, after, before, this.index); - this.setData(hashes); - }) - ); + this.setData(hashes); }) ); } else {