Skip to content

Commit ebb7b27

Browse files
fix: cr suggestions
1 parent 511d7fa commit ebb7b27

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

core/modules/order/components/UserOrdersHistory.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ export default {
2525
},
2626
methods: {
2727
onBottomScroll () {
28+
const totalCount = this.$store.state.user.orders_history.total_count ? this.$store.state.user.orders_history.total_count : 0;
29+
const isLastPage = this.pagination.current > Math.ceil(totalCount / this.pagination.perPage);
30+
if (!isLastPage) {
2831
this.pagination.current++;
29-
this.$store.dispatch('user/appendOrdersHistory', { pageSize: this.pagination.perPage, currentPage: this.pagination.current });
32+
this.$store.dispatch('user/appendOrdersHistory', {
33+
pageSize: this.pagination.perPage,
34+
currentPage: this.pagination.current
35+
});
3036
}
3137
}
3238
}

core/modules/user/test/unit/store/actions.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,14 @@ describe('User actions', () => {
472472
const pageSize = data.pageSize;
473473
const currentPage = data.currentPage;
474474

475-
await (userActions as any).appendOrdersHistory(contextMock, {
475+
const result = await (userActions as any).appendOrdersHistory(contextMock, {
476476
pageSize,
477477
currentPage
478478
})
479479

480480
expect(contextMock.commit).toBeCalledWith(types.USER_ORDERS_HISTORY_LOADED, responseOb.result);
481+
expect(EventBus.$emit).toBeCalledWith('user-after-loaded-orders', result);
482+
expect(result).toBe(responseOb.result)
481483
})
482484
})
483485

0 commit comments

Comments
 (0)