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
|
### Fixed
|
||||||
- Fix Shikimori tracking not working ([@MajorTanya](https://github.com/MajorTanya)) ([#3497](https://github.com/mihonapp/mihon/pull/3497))
|
- 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
|
## [v0.20.0] - 2026-06-27
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ fun MangaNotesScreen(
|
|||||||
titleContent = {
|
titleContent = {
|
||||||
AppBarTitle(
|
AppBarTitle(
|
||||||
title = stringResource(MR.strings.action_edit_notes),
|
title = stringResource(MR.strings.action_edit_notes),
|
||||||
subtitle = state.manga.title,
|
subtitle = state.mangaTitle,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
navigateUp = navigateUp,
|
navigateUp = navigateUp,
|
||||||
|
|||||||
@@ -161,7 +161,15 @@ class MangaScreen(
|
|||||||
onMigrateClicked = {
|
onMigrateClicked = {
|
||||||
navigator.push(MigrationConfigScreen(successState.manga.id))
|
navigator.push(MigrationConfigScreen(successState.manga.id))
|
||||||
}.takeIf { successState.manga.favorite },
|
}.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,
|
onMultiBookmarkClicked = screenModel::bookmarkChapters,
|
||||||
onMultiMarkAsReadClicked = screenModel::markChaptersRead,
|
onMultiMarkAsReadClicked = screenModel::markChaptersRead,
|
||||||
onMarkPreviousAsReadClicked = screenModel::markPreviousChapterRead,
|
onMarkPreviousAsReadClicked = screenModel::markPreviousChapterRead,
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
package eu.kanade.tachiyomi.ui.manga.notes
|
package eu.kanade.tachiyomi.ui.manga.notes
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
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.StateScreenModel
|
||||||
import cafe.adriel.voyager.core.model.rememberScreenModel
|
import cafe.adriel.voyager.core.model.rememberScreenModel
|
||||||
import cafe.adriel.voyager.core.model.screenModelScope
|
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.manga.MangaNotesScreen
|
||||||
import eu.kanade.presentation.util.Screen
|
import eu.kanade.presentation.util.Screen
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
import tachiyomi.core.common.util.lang.launchNonCancellable
|
import tachiyomi.core.common.util.lang.launchNonCancellable
|
||||||
import tachiyomi.domain.manga.interactor.UpdateMangaNotes
|
import tachiyomi.domain.manga.interactor.UpdateMangaNotes
|
||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
@@ -19,13 +25,21 @@ import uy.kohesive.injekt.Injekt
|
|||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
class MangaNotesScreen(
|
class MangaNotesScreen(
|
||||||
private val manga: Manga,
|
private val mangaId: Long,
|
||||||
|
private val mangaTitle: String,
|
||||||
|
private val mangaNotes: String,
|
||||||
) : Screen() {
|
) : Screen() {
|
||||||
@Composable
|
@Composable
|
||||||
override fun Content() {
|
override fun Content() {
|
||||||
val navigator = LocalNavigator.currentOrThrow
|
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()
|
val state by screenModel.state.collectAsState()
|
||||||
|
|
||||||
MangaNotesScreen(
|
MangaNotesScreen(
|
||||||
@@ -36,9 +50,11 @@ class MangaNotesScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class Model(
|
private class Model(
|
||||||
private val manga: Manga,
|
mangaTitle: String,
|
||||||
|
mangaNotes: String,
|
||||||
|
private val mangaId: Long,
|
||||||
private val updateMangaNotes: UpdateMangaNotes = Injekt.get(),
|
private val updateMangaNotes: UpdateMangaNotes = Injekt.get(),
|
||||||
) : StateScreenModel<State>(State(manga, manga.notes)) {
|
) : StateScreenModel<State>(State(mangaId, mangaTitle, mangaNotes)) {
|
||||||
|
|
||||||
fun updateNotes(content: String) {
|
fun updateNotes(content: String) {
|
||||||
if (content == state.value.notes) return
|
if (content == state.value.notes) return
|
||||||
@@ -48,14 +64,15 @@ class MangaNotesScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
screenModelScope.launchNonCancellable {
|
screenModelScope.launchNonCancellable {
|
||||||
updateMangaNotes(manga.id, content)
|
updateMangaNotes(mangaId, content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
data class State(
|
data class State(
|
||||||
val manga: Manga,
|
val mangaId: Long,
|
||||||
|
val mangaTitle: String,
|
||||||
val notes: String,
|
val notes: String,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user