Adds @Stable tag to Notification Card models

This commit is contained in:
Vitor Pamplona 2023-05-25 18:27:05 -04:00
parent aed7f46ca0
commit e9bdc045ba
3 changed files with 13 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Bolt
import androidx.compose.material.icons.filled.ExpandMore
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
@ -92,6 +93,7 @@ fun UserReactionsRow(model: UserReactionsViewModel, accountViewModel: AccountVie
}
}
@Stable
class UserReactionsViewModel : ViewModel() {
var user: User? = null

View File

@ -2,6 +2,7 @@ package com.vitorpamplona.amethyst.ui.screen
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.Stable
import com.vitorpamplona.amethyst.model.Note
import com.vitorpamplona.amethyst.model.User
import kotlinx.collections.immutable.ImmutableList
@ -92,9 +93,17 @@ class MessageSetCard(val note: Note) : Card() {
override fun id() = note.idHex
}
@Immutable
sealed class CardFeedState {
@Immutable
object Loading : CardFeedState()
@Stable
class Loaded(val feed: MutableState<ImmutableList<Card>>) : CardFeedState()
@Immutable
object Empty : CardFeedState()
@Immutable
class FeedError(val errorMessage: String) : CardFeedState()
}

View File

@ -1,6 +1,7 @@
package com.vitorpamplona.amethyst.ui.screen
import android.util.Log
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
@ -33,6 +34,7 @@ import kotlinx.coroutines.launch
import kotlin.time.ExperimentalTime
import kotlin.time.measureTimedValue
@Stable
class NotificationViewModel : CardFeedViewModel(NotificationFeedFilter)
open class CardFeedViewModel(val localFilter: FeedFilter<Note>) : ViewModel() {