Add guard against out of bounds indices in story viewer.

This commit is contained in:
Alex Hart 2022-05-17 09:28:17 -03:00 committed by Cody Henthorne
parent 9d518879dd
commit 8407f2ff69

View file

@ -108,7 +108,7 @@ class StoryViewerViewModel(
fun onGoToNext(recipientId: RecipientId) {
store.update {
if (it.pages[it.page] == recipientId) {
if (it.page in it.pages.indices && it.pages[it.page] == recipientId) {
updatePages(it, it.page + 1)
} else {
it
@ -118,7 +118,7 @@ class StoryViewerViewModel(
fun onGoToPrevious(recipientId: RecipientId) {
store.update {
if (it.pages[it.page] == recipientId) {
if (it.page in it.pages.indices && it.pages[it.page] == recipientId) {
updatePages(it, max(0, it.page - 1))
} else {
it