Fix crash when putting app in background while on notes screen (#3515)
This commit is contained in:
@@ -18,6 +18,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
||||
|
||||
### Fixed
|
||||
- Fix Shikimori tracking not working ([@MajorTanya](https://github.com/MajorTanya)) ([#3497](https://github.com/mihonapp/mihon/pull/3497))
|
||||
- Fix crash when putting app in background while on notes screen ([@AntsyLich](https://github.com/AntsyLich)) ([#3515](https://github.com/mihonapp/mihon/pull/3515))
|
||||
|
||||
## [v0.20.0] - 2026-06-27
|
||||
### Added
|
||||
|
||||
@@ -25,7 +25,7 @@ fun MangaNotesScreen(
|
||||
titleContent = {
|
||||
AppBarTitle(
|
||||
title = stringResource(MR.strings.action_edit_notes),
|
||||
subtitle = state.manga.title,
|
||||
subtitle = state.mangaTitle,
|
||||
)
|
||||
},
|
||||
navigateUp = navigateUp,
|
||||
|
||||
@@ -161,7 +161,15 @@ class MangaScreen(
|
||||
onMigrateClicked = {
|
||||
navigator.push(MigrationConfigScreen(successState.manga.id))
|
||||
}.takeIf { successState.manga.favorite },
|
||||
onEditNotesClicked = { navigator.push(MangaNotesScreen(manga = successState.manga)) },
|
||||
onEditNotesClicked = {
|
||||
navigator.push(
|
||||
MangaNotesScreen(
|
||||
mangaId = successState.manga.id,
|
||||
mangaTitle = successState.manga.title,
|
||||
mangaNotes = successState.manga.notes,
|
||||
),
|
||||
)
|
||||
},
|
||||
onMultiBookmarkClicked = screenModel::bookmarkChapters,
|
||||
onMultiMarkAsReadClicked = screenModel::markChaptersRead,
|
||||
onMarkPreviousAsReadClicked = screenModel::markPreviousChapterRead,
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
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
|
||||
@@ -12,6 +17,7 @@ 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
|
||||
@@ -19,13 +25,21 @@ import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class MangaNotesScreen(
|
||||
private val manga: Manga,
|
||||
private val mangaId: Long,
|
||||
private val mangaTitle: String,
|
||||
private val mangaNotes: String,
|
||||
) : Screen() {
|
||||
@Composable
|
||||
override fun Content() {
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
|
||||
val screenModel = rememberScreenModel { Model(manga) }
|
||||
val screenModel = rememberScreenModel {
|
||||
Model(
|
||||
mangaId = mangaId,
|
||||
mangaTitle = mangaTitle,
|
||||
mangaNotes = mangaNotes,
|
||||
)
|
||||
}
|
||||
val state by screenModel.state.collectAsState()
|
||||
|
||||
MangaNotesScreen(
|
||||
@@ -36,9 +50,11 @@ class MangaNotesScreen(
|
||||
}
|
||||
|
||||
private class Model(
|
||||
private val manga: Manga,
|
||||
mangaTitle: String,
|
||||
mangaNotes: String,
|
||||
private val mangaId: Long,
|
||||
private val updateMangaNotes: UpdateMangaNotes = Injekt.get(),
|
||||
) : StateScreenModel<State>(State(manga, manga.notes)) {
|
||||
) : StateScreenModel<State>(State(mangaId, mangaTitle, mangaNotes)) {
|
||||
|
||||
fun updateNotes(content: String) {
|
||||
if (content == state.value.notes) return
|
||||
@@ -48,14 +64,15 @@ class MangaNotesScreen(
|
||||
}
|
||||
|
||||
screenModelScope.launchNonCancellable {
|
||||
updateMangaNotes(manga.id, content)
|
||||
updateMangaNotes(mangaId, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Immutable
|
||||
data class State(
|
||||
val manga: Manga,
|
||||
val mangaId: Long,
|
||||
val mangaTitle: String,
|
||||
val notes: String,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user