Revert "Fix crash when putting app in background while on notes screen (#3515)"
This reverts commit 76cc04c8f4.
This commit is contained in:
@@ -25,7 +25,7 @@ fun MangaNotesScreen(
|
||||
titleContent = {
|
||||
AppBarTitle(
|
||||
title = stringResource(MR.strings.action_edit_notes),
|
||||
subtitle = state.mangaTitle,
|
||||
subtitle = state.manga.title,
|
||||
)
|
||||
},
|
||||
navigateUp = navigateUp,
|
||||
|
||||
@@ -161,15 +161,7 @@ class MangaScreen(
|
||||
onMigrateClicked = {
|
||||
navigator.push(MigrationConfigScreen(successState.manga.id))
|
||||
}.takeIf { successState.manga.favorite },
|
||||
onEditNotesClicked = {
|
||||
navigator.push(
|
||||
MangaNotesScreen(
|
||||
mangaId = successState.manga.id,
|
||||
mangaTitle = successState.manga.title,
|
||||
mangaNotes = successState.manga.notes,
|
||||
),
|
||||
)
|
||||
},
|
||||
onEditNotesClicked = { navigator.push(MangaNotesScreen(manga = successState.manga)) },
|
||||
onMultiBookmarkClicked = screenModel::bookmarkChapters,
|
||||
onMultiMarkAsReadClicked = screenModel::markChaptersRead,
|
||||
onMarkPreviousAsReadClicked = screenModel::markPreviousChapterRead,
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
package eu.kanade.tachiyomi.ui.manga.notes
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.platform.AndroidClipboard
|
||||
import androidx.compose.ui.platform.LocalClipboard
|
||||
import androidx.compose.ui.platform.nativeClipboardManager
|
||||
import cafe.adriel.voyager.core.model.StateScreenModel
|
||||
import cafe.adriel.voyager.core.model.rememberScreenModel
|
||||
import cafe.adriel.voyager.core.model.screenModelScope
|
||||
@@ -17,7 +12,6 @@ import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import eu.kanade.presentation.manga.MangaNotesScreen
|
||||
import eu.kanade.presentation.util.Screen
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.serialization.Serializable
|
||||
import tachiyomi.core.common.util.lang.launchNonCancellable
|
||||
import tachiyomi.domain.manga.interactor.UpdateMangaNotes
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
@@ -25,21 +19,13 @@ import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class MangaNotesScreen(
|
||||
private val mangaId: Long,
|
||||
private val mangaTitle: String,
|
||||
private val mangaNotes: String,
|
||||
private val manga: Manga,
|
||||
) : Screen() {
|
||||
@Composable
|
||||
override fun Content() {
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
|
||||
val screenModel = rememberScreenModel {
|
||||
Model(
|
||||
mangaId = mangaId,
|
||||
mangaTitle = mangaTitle,
|
||||
mangaNotes = mangaNotes,
|
||||
)
|
||||
}
|
||||
val screenModel = rememberScreenModel { Model(manga) }
|
||||
val state by screenModel.state.collectAsState()
|
||||
|
||||
MangaNotesScreen(
|
||||
@@ -50,11 +36,9 @@ class MangaNotesScreen(
|
||||
}
|
||||
|
||||
private class Model(
|
||||
mangaTitle: String,
|
||||
mangaNotes: String,
|
||||
private val mangaId: Long,
|
||||
private val manga: Manga,
|
||||
private val updateMangaNotes: UpdateMangaNotes = Injekt.get(),
|
||||
) : StateScreenModel<State>(State(mangaId, mangaTitle, mangaNotes)) {
|
||||
) : StateScreenModel<State>(State(manga, manga.notes)) {
|
||||
|
||||
fun updateNotes(content: String) {
|
||||
if (content == state.value.notes) return
|
||||
@@ -64,15 +48,14 @@ class MangaNotesScreen(
|
||||
}
|
||||
|
||||
screenModelScope.launchNonCancellable {
|
||||
updateMangaNotes(mangaId, content)
|
||||
updateMangaNotes(manga.id, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Immutable
|
||||
data class State(
|
||||
val mangaId: Long,
|
||||
val mangaTitle: String,
|
||||
val manga: Manga,
|
||||
val notes: String,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user