Skip to content

Commit 5de0ceb

Browse files
committed
fix crash in grid
1 parent 1f5b57f commit 5de0ceb

File tree

1 file changed

+3
-2
lines changed
  • app/src/main/java/io/github/wiiznokes/gitnote/ui/screen/app/grid

1 file changed

+3
-2
lines changed

app/src/main/java/io/github/wiiznokes/gitnote/ui/screen/app/grid/GridScreen.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
6666
import androidx.lifecycle.viewmodel.compose.viewModel
6767
import androidx.paging.compose.LazyPagingItems
6868
import androidx.paging.compose.collectAsLazyPagingItems
69+
import androidx.paging.compose.itemKey
6970
import io.github.wiiznokes.gitnote.R
7071
import io.github.wiiznokes.gitnote.data.room.Note
7172
import io.github.wiiznokes.gitnote.ui.component.CustomDropDown
@@ -296,9 +297,9 @@ private fun GridNotesView(
296297

297298
items(
298299
count = gridNotes.itemCount,
299-
key = { index -> gridNotes[index]!!.note.id }
300+
key = gridNotes.itemKey { it.note.id }
300301
) { index ->
301-
val gridNote = gridNotes[index]!!
302+
val gridNote = gridNotes[index] ?: return@items
302303

303304
NoteCard(
304305
gridNote = gridNote,

0 commit comments

Comments
 (0)