From 54733e6ceb541d314687f46f5a01cf2f08dec89e Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 15 Jul 2023 09:54:29 -0400 Subject: [PATCH] Mark some state data classes as immutable --- .../ui/browse/migration/search/MigrateDialog.kt | 2 ++ .../tachiyomi/ui/manga/track/TrackInfoDialog.kt | 6 ++++++ .../eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt | 12 +++++------- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateDialog.kt index 496a40c584..137af5eff5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateDialog.kt @@ -16,6 +16,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateListOf @@ -313,6 +314,7 @@ internal class MigrateDialogScreenModel( ) } + @Immutable data class State( val isMigrating: Boolean = false, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackInfoDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackInfoDialog.kt index 1ed1895a92..04c5cd40d6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackInfoDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackInfoDialog.kt @@ -20,6 +20,7 @@ import androidx.compose.material3.SelectableDates import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -265,6 +266,7 @@ data class TrackInfoDialogHomeScreen( .filter { (it.service as? EnhancedTrackService)?.accept(source) ?: true } } + @Immutable data class State( val trackItems: List = emptyList(), ) @@ -314,6 +316,7 @@ private data class TrackStatusSelectorScreen( } } + @Immutable data class State( val selection: Int, ) @@ -369,6 +372,7 @@ private data class TrackChapterSelectorScreen( } } + @Immutable data class State( val selection: Int, ) @@ -419,6 +423,7 @@ private data class TrackScoreSelectorScreen( } } + @Immutable data class State( val selection: String, ) @@ -724,6 +729,7 @@ data class TrackServiceSearchScreen( mutableState.update { it.copy(selected = selected) } } + @Immutable data class State( val queryResult: Result>? = null, val selected: TrackSearch? = null, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt index 7a7a313a61..0fa5423c35 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.reader import android.app.Application import android.net.Uri +import androidx.compose.runtime.Immutable import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope @@ -790,16 +791,12 @@ class ReaderViewModel( } } - /** - * Results of the set as cover feature. - */ enum class SetAsCoverResult { - Success, AddToLibraryFirst, Error + Success, + AddToLibraryFirst, + Error, } - /** - * Results of the save image feature. - */ sealed class SaveImageResult { class Success(val uri: Uri) : SaveImageResult() class Error(val error: Throwable) : SaveImageResult() @@ -844,6 +841,7 @@ class ReaderViewModel( } } + @Immutable data class State( val manga: Manga? = null, val viewerChapters: ViewerChapters? = null,