Fix time until component round for week interval. (#679)
* Fix time until component round for week interval. * Add forceFloorOnTimeIntervals parameter.
This commit is contained in:
parent
0293ba4a52
commit
a0559cbb24
@ -21,7 +21,7 @@
|
|||||||
<app-time-until [time]="(1 * i) + now + 61000" [fastRender]="false" [fixedRender]="true"></app-time-until>
|
<app-time-until [time]="(1 * i) + now + 61000" [fastRender]="false" [fixedRender]="true"></app-time-until>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template #timeDiffMainnet>
|
<ng-template #timeDiffMainnet>
|
||||||
<app-time-until [time]="(timeAvg * i) + now + timeAvg" [fastRender]="false" [fixedRender]="true"></app-time-until>
|
<app-time-until [time]="(timeAvg * i) + now + timeAvg" [fastRender]="false" [fixedRender]="true" [forceFloorOnTimeIntervals]="['hour']"></app-time-until>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</div>
|
</div>
|
||||||
<ng-template #mergedBlock>
|
<ng-template #mergedBlock>
|
||||||
|
@ -15,6 +15,7 @@ export class TimeUntilComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
@Input() time: number;
|
@Input() time: number;
|
||||||
@Input() fastRender = false;
|
@Input() fastRender = false;
|
||||||
@Input() fixedRender = false;
|
@Input() fixedRender = false;
|
||||||
|
@Input() forceFloorOnTimeIntervals: string[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private ref: ChangeDetectorRef,
|
private ref: ChangeDetectorRef,
|
||||||
@ -67,10 +68,10 @@ export class TimeUntilComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
let counter: number;
|
let counter: number;
|
||||||
for (const i in this.intervals) {
|
for (const i in this.intervals) {
|
||||||
if (this.intervals.hasOwnProperty(i)) {
|
if (this.intervals.hasOwnProperty(i)) {
|
||||||
if (i === 'minute') {
|
if (this.forceFloorOnTimeIntervals && this.forceFloorOnTimeIntervals.indexOf(i) > -1) {
|
||||||
counter = Math.round(seconds / this.intervals[i]);
|
|
||||||
} else {
|
|
||||||
counter = Math.floor(seconds / this.intervals[i]);
|
counter = Math.floor(seconds / this.intervals[i]);
|
||||||
|
} else {
|
||||||
|
counter = Math.round(seconds / this.intervals[i]);
|
||||||
}
|
}
|
||||||
const dateStrings = dates(counter);
|
const dateStrings = dates(counter);
|
||||||
if (counter > 0) {
|
if (counter > 0) {
|
||||||
|
@ -120,7 +120,7 @@
|
|||||||
<app-time-until [time]="(60 * 1000 * txInBlockIndex) + now" [fastRender]="false" [fixedRender]="true"></app-time-until>
|
<app-time-until [time]="(60 * 1000 * txInBlockIndex) + now" [fastRender]="false" [fixedRender]="true"></app-time-until>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template #timeEstimateDefault>
|
<ng-template #timeEstimateDefault>
|
||||||
<app-time-until *ngIf="(timeAvg$ | async) as timeAvg;" [time]="(timeAvg * txInBlockIndex) + now + timeAvg" [fastRender]="false" [fixedRender]="true"></app-time-until>
|
<app-time-until *ngIf="(timeAvg$ | async) as timeAvg;" [time]="(timeAvg * txInBlockIndex) + now + timeAvg" [fastRender]="false" [fixedRender]="true" [forceFloorOnTimeIntervals]="['hour']"></app-time-until>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user