Skip to content

Commit

Permalink
[demo] Fix IndexOutOfBounds
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanTsune committed May 4, 2021
1 parent c8a4208 commit 5d6eaf0
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ class MailRepository : IMailRepository {
}

override suspend fun getList(page: Int, size: Int): List<Mail> {
return mailList.subList(page * size, (page + 1) * size).toList()
return mailList.subList(
(page * size).coerceAtMost(mailList.size - 1),
((page + 1) * size).coerceAtMost(mailList.size - 1),
).toList()
}

override suspend fun delete(mail: Mail) {
Expand Down

0 comments on commit 5d6eaf0

Please sign in to comment.