Skip to content

Commit b97ec00

Browse files
jessevzjessevz
andauthored
Fixed retrieving cracks of a task (#444)
* Fixed retrieving cracks of a task * Fixed eslint suggestions --------- Co-authored-by: jessevz <[email protected]>
1 parent c424eb6 commit b97ec00

File tree

1 file changed

+4
-43
lines changed

1 file changed

+4
-43
lines changed

src/app/core/_datasources/hashes.datasource.ts

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { catchError, finalize, of } from 'rxjs';
33
import { JHash } from '@models/hash.model';
44
import { Filter, FilterType } from '@models/request-params.model';
55
import { ResponseWrapper } from '@models/response.model';
6-
import { JTask } from '@models/task.model';
76

87
import { JsonAPISerializer } from '@services/api/serializer-service';
98
import { SERV } from '@services/main.config';
@@ -27,59 +26,21 @@ export class HashesDataSource extends BaseDataSource<JHash> {
2726
this.loading = true;
2827

2928
if (this._dataType === 'tasks') {
30-
const paramsTasks = new RequestParamBuilder().addInitial(this).addInclude('hashlist');
31-
if (query) {
32-
paramsTasks.addFilter(query);
33-
}
34-
const taskService = this.service.get(SERV.TASKS, this._id, paramsTasks.create());
29+
const hashesService = this.service.ghelper(SERV.HELPER, 'getCracksOfTask?task=' + this._id);
3530

3631
this.subscriptions.push(
37-
taskService
32+
hashesService
3833
.pipe(
3934
catchError(() => of([])),
4035
finalize(() => (this.loading = false))
4136
)
4237
.subscribe((response: ResponseWrapper) => {
43-
const task = new JsonAPISerializer().deserialize<JTask>({
38+
const hashes = new JsonAPISerializer().deserialize<JHash[]>({
4439
data: response.data,
4540
included: response.included
4641
});
4742

48-
const hashlistId = task.hashlist.id;
49-
50-
const paramsHashlist = new RequestParamBuilder()
51-
.addInitial(this)
52-
.addInclude('hashlist')
53-
.addFilter({ field: 'hashlistId', operator: FilterType.EQUAL, value: hashlistId })
54-
.addFilter({ field: 'isCracked', operator: FilterType.EQUAL, value: true })
55-
.addFilter({ field: 'hashlistId', operator: FilterType.EQUAL, value: hashlistId });
56-
if (query) {
57-
paramsHashlist.addFilter(query);
58-
}
59-
const hashlistService = this.service.getAll(SERV.HASHES, paramsHashlist.create());
60-
61-
this.subscriptions.push(
62-
hashlistService
63-
.pipe(
64-
catchError(() => of([])),
65-
finalize(() => (this.loading = false))
66-
)
67-
.subscribe((responseHash: ResponseWrapper) => {
68-
const hashes = new JsonAPISerializer().deserialize<JHash[]>({
69-
data: responseHash.data,
70-
included: responseHash.included
71-
});
72-
73-
const length = responseHash.meta.page.total_elements;
74-
const nextLink = responseHash.links.next;
75-
const prevLink = responseHash.links.prev;
76-
const after = nextLink ? new URL(nextLink).searchParams.get('page[after]') : null;
77-
const before = prevLink ? new URL(prevLink).searchParams.get('page[before]') : null;
78-
79-
this.setPaginationConfig(this.pageSize, length, after, before, this.index);
80-
this.setData(hashes);
81-
})
82-
);
43+
this.setData(hashes);
8344
})
8445
);
8546
} else {

0 commit comments

Comments
 (0)