Skip to content

Commit 1005210

Browse files
authored
Fixed #657 (#660)
- Removed totalPage and TotalEntries from pagination
1 parent 2b18ca2 commit 1005210

15 files changed

+20
-56
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"ripemd160": "^2.0.2",
102102
"rxjs": "^6.5.3",
103103
"rxjs-compat": "^6.5.3",
104-
"symbol-openapi-typescript-fetch-client": "0.9.6",
104+
"symbol-openapi-typescript-fetch-client": "0.9.7-SNAPSHOT.202009041234",
105105
"tweetnacl": "^1.0.3",
106106
"utf8": "^3.0.0",
107107
"ws": "^7.2.3"

src/infrastructure/Http.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ export abstract class Http {
139139
data.map((d) => mapper(d, networkType)),
140140
pagination?.pageNumber,
141141
pagination?.pageSize,
142-
pagination?.totalEntries,
143-
pagination?.totalPages,
144142
);
145143
}
146144
}

src/infrastructure/Page.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,8 @@ export class Page<T> {
2727
* @param data the page data
2828
* @param pageNumber the current page number starting from 1.
2929
* @param pageSize the page size.
30-
* @param totalEntries the total entries.
31-
* @param totalPages the total pages for the given criteria.
3230
*/
33-
constructor(
34-
public readonly data: T[],
35-
public readonly pageNumber: number,
36-
public readonly pageSize: number,
37-
public readonly totalEntries: number,
38-
public readonly totalPages: number,
39-
) {
40-
this.isLastPage = this.pageNumber >= this.totalPages;
31+
constructor(public readonly data: T[], public readonly pageNumber: number, public readonly pageSize: number) {
32+
this.isLastPage = !this.data.length || this.pageSize > this.data.length;
4133
}
4234
}

test/infrastructure/AccountHttp.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ describe('AccountHttp', () => {
129129
const pagination = {} as Pagination;
130130
pagination.pageNumber = 1;
131131
pagination.pageSize = 1;
132-
pagination.totalEntries = 1;
133-
pagination.totalPages = 1;
134132

135133
const body = {} as AccountPage;
136134
body.data = [accountInfoDto];

test/infrastructure/BlockHttp.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ describe('BlockHttp', () => {
109109
const pagination = {} as Pagination;
110110
pagination.pageNumber = 1;
111111
pagination.pageSize = 1;
112-
pagination.totalEntries = 1;
113-
pagination.totalPages = 1;
114112

115113
const body = {} as BlockPage;
116114
body.data = [blockInfoDto];

test/infrastructure/MetadataHttp.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ describe('MetadataHttp', () => {
4949
const pagination = {} as Pagination;
5050
pagination.pageNumber = 1;
5151
pagination.pageSize = 1;
52-
pagination.totalEntries = 1;
53-
pagination.totalPages = 1;
5452

5553
const metadataDTOMosaic = {} as MetadataInfoDTO;
5654
metadataDTOMosaic.id = 'aaa';

test/infrastructure/MosaicHttp.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ describe('MosaicHttp', () => {
9999
const pagination = {} as Pagination;
100100
pagination.pageNumber = 1;
101101
pagination.pageSize = 1;
102-
pagination.totalEntries = 1;
103-
pagination.totalPages = 1;
104102

105103
const body = {} as MosaicPage;
106104
body.data = [mosaicInfoDto];

test/infrastructure/NamespaceHttp.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ describe('NamespaceHttp', () => {
208208
const pagination = {} as Pagination;
209209
pagination.pageNumber = 1;
210210
pagination.pageSize = 1;
211-
pagination.totalEntries = 1;
212-
pagination.totalPages = 1;
213211

214212
const body = {} as NamespacePage;
215213
body.data = [namespaceInfoDto];

test/infrastructure/Page.spec.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,20 @@ describe('Page', () => {
3030
[TransferTransaction.create(Deadline.create(), account.address, [], PlainMessage.create(''), NetworkType.TEST_NET)],
3131
1,
3232
1,
33-
1,
34-
1,
3533
);
3634
expect(page.data.length).to.be.equal(1);
3735
expect(page.pageNumber).to.be.equal(1);
3836
expect(page.pageSize).to.be.equal(1);
39-
expect(page.totalEntries).to.be.equal(1);
40-
expect(page.isLastPage).to.be.true;
37+
expect(page.isLastPage).to.be.false;
4138

4239
page = new Page<Transaction>(
4340
[TransferTransaction.create(Deadline.create(), account.address, [], PlainMessage.create(''), NetworkType.TEST_NET)],
44-
1,
45-
1,
46-
1,
47-
3,
41+
2,
42+
2,
4843
);
49-
expect(page.isLastPage).to.be.false;
44+
expect(page.isLastPage).to.be.true;
45+
46+
page = new Page<Transaction>([], 2, 2);
47+
expect(page.isLastPage).to.be.true;
5048
});
5149
});

0 commit comments

Comments
 (0)