Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Add infinity scroll for forged blocks #335

Merged
merged 5 commits into from
Jun 7, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/components/forging/forging.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ app.component('forging', {
*/
updateAllData() {
this.updateDelegate();
this.updateForgedBlocks(10);
this.updateForgedBlocks(20);

this.updateForgingStats('today', moment().set({ hour: 0, minute: 0, second: 0 }));
this.updateForgingStats('last24h', moment().subtract(1, 'days'));
Expand Down Expand Up @@ -104,8 +104,10 @@ app.component('forging', {
* @todo Replace loader with a loader service
*/
loadMoreBlocks() {
this.blocksLoaded = false;
this.updateForgedBlocks(20, this.blocks.length);
if (this.blocksLoaded && this.blocks.length !== 0) {
this.blocksLoaded = false;
this.updateForgedBlocks(20, this.blocks.length);
}
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/components/forging/forging.pug
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ md-card.offline-hide
md-card(flex-gt-xs=100, layout-padding)
md-card-title
md-card-title-text
span.md-title.delegate-name {{$ctrl.delegate.username}}
span.md-title.delegate-name {{$ctrl.delegate.username}}
span(md-position-mode='target-right target')
span {{$ctrl.statistics.total | lsk | number:2 }} LSK Earned
md-content(layout='column', layout-gt-xs='row', ng-if='$ctrl.delegate.username')
md-card(flex-50, flex-gt-xs=25, layout-padding)
.info-panel.info-panel-grey
span.title Today
span.title Today
span.pull-right {{$ctrl.statistics.today | lsk | number:2 }} LSK
md-card(flex-50, flex-gt-xs=25, layout-padding)
.info-panel.info-panel-grey
span.title Last 24 hours
span.title Last 24 hours
span.pull-right {{$ctrl.statistics.last24h | lsk | number:2 }} LSK
md-card(flex-50, flex-gt-xs=25, layout-padding)
.info-panel.info-panel-grey
span.title {{'Last 7 days'}}
span.title {{'Last 7 days'}}
span.pull-right {{$ctrl.statistics.last7d | lsk | number:2 }} LSK
md-card(flex-50, flex-gt-xs=25, layout-padding)
.info-panel.info-panel-grey
span.title {{'Last 30 days'}}
span.title {{'Last 30 days'}}
span.pull-right {{$ctrl.statistics.last30d | lsk | number:2 }} LSK
div(layout='column', layout-gt-xs='row', ng-if='$ctrl.delegate.username')
md-card(flex-gt-xs=33, layout-align='center center', layout-padding)
Expand Down Expand Up @@ -71,7 +71,7 @@ md-card.offline-hide
th(md-column) Timestamp
th(md-column) Total fee
th(md-column) Reward
tbody(md-body)
tbody(md-body, infinite-scroll='$ctrl.loadMoreBlocks()', infinite-scroll-distance='1')
tr(md-row, ng-repeat='block in $ctrl.blocks')
td(md-cell data-title='tableBlocks.cols.height', sortable="'height'") {{block.height}}
td(md-cell data-title='tableBlocks.cols.blockId', ng-show='$ctrl.showAllColumns') {{block.id}}
Expand Down
1 change: 1 addition & 0 deletions test/components/forging/forging.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ describe('forging component controller', () => {
const deferred = $q.defer();
forgingApiMock.expects('getForgedBlocks').returns(deferred.promise);
controller.blocks = blocks;
controller.blocksLoaded = true;

controller.loadMoreBlocks();
deferred.resolve({
Expand Down