Add guard against out of bounds indices in story viewer.

fork-5.53.8
Alex Hart 2022-05-17 09:28:17 -03:00 zatwierdzone przez Cody Henthorne
rodzic 9d518879dd
commit 8407f2ff69
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

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