Improve code quality
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
48ec6224e7
commit
a76dcb289a
3 changed files with 41 additions and 44 deletions
|
|
@ -14,14 +14,10 @@ class EventLimit {
|
|||
return this._from;
|
||||
}
|
||||
|
||||
get end() {
|
||||
get length() {
|
||||
return this._from + this.maxEvents;
|
||||
}
|
||||
|
||||
setMaxEvents(maxEvents) {
|
||||
this.maxEvents = maxEvents;
|
||||
}
|
||||
|
||||
setFrom(from) {
|
||||
this._from = from < 0 ? 0 : from;
|
||||
}
|
||||
|
|
@ -29,7 +25,7 @@ class EventLimit {
|
|||
paginate(backwards, limit, timelineLength) {
|
||||
this._from = backwards ? this._from - limit : this._from + limit;
|
||||
|
||||
if (!backwards && this.end > timelineLength) {
|
||||
if (!backwards && this.length > timelineLength) {
|
||||
this._from = timelineLength - this.maxEvents;
|
||||
}
|
||||
if (this._from < 0) this._from = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue