Improve code quality

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura
2022-03-12 14:14:56 +05:30
parent 48ec6224e7
commit a76dcb289a
3 changed files with 41 additions and 44 deletions

View File

@@ -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;