Skip to content

Commit

Permalink
fix: Prevent crash when reopening current tab
Browse files Browse the repository at this point in the history
  • Loading branch information
jmir1 committed Sep 5, 2023
1 parent b06c85d commit e08926b
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 11 deletions.
6 changes: 4 additions & 2 deletions app/src/main/java/eu/kanade/presentation/util/Navigator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import soup.compose.material.motion.animation.rememberSlideDistance
*/
val LocalBackPress: ProvidableCompositionLocal<(() -> Unit)?> = staticCompositionLocalOf { null }

interface Tab : cafe.adriel.voyager.navigator.tab.Tab {
suspend fun onReselect(navigator: Navigator) {}
abstract class Tab : cafe.adriel.voyager.navigator.tab.Tab {

override val key: ScreenKey = uniqueScreenKey
open suspend fun onReselect(navigator: Navigator) {}
}

// TODO: this prevents crashes in nested navigators with transitions not being disposed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil

data class BrowseTab(
private val toExtensions: Boolean = false,
) : Tab {
) : Tab() {

override val options: TabOptions
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import kotlinx.coroutines.flow.collectLatest

data class CategoriesTab(
private val isManga: Boolean = false,
) : Tab {
) : Tab() {

override val options: TabOptions
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil

data class DownloadsTab(
private val isManga: Boolean = false,
) : Tab {
) : Tab() {

override val options: TabOptions
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil

data class HistoriesTab(
private val fromMore: Boolean,
) : Tab {
) : Tab() {

override val options: TabOptions
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import tachiyomi.presentation.core.screens.LoadingScreen
import tachiyomi.source.local.entries.anime.isLocal
import uy.kohesive.injekt.injectLazy

object AnimeLibraryTab : Tab {
object AnimeLibraryTab : Tab() {

val libraryPreferences: LibraryPreferences by injectLazy()
private val fromMore = libraryPreferences.bottomNavStyle().get() == 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import tachiyomi.presentation.core.screens.LoadingScreen
import tachiyomi.source.local.entries.manga.isLocal
import uy.kohesive.injekt.injectLazy

object MangaLibraryTab : Tab {
object MangaLibraryTab : Tab() {

val libraryPreferences: LibraryPreferences by injectLazy()
private val fromMore = libraryPreferences.bottomNavStyle().get() == 2
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy

object MoreTab : Tab {
object MoreTab : Tab() {

override val options: TabOptions
@Composable
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import eu.kanade.tachiyomi.ui.stats.manga.mangaStatsTab

data class StatsTab(
private val isManga: Boolean = false,
) : Tab {
) : Tab() {

override val options: TabOptions
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import eu.kanade.tachiyomi.ui.updates.manga.mangaUpdatesTab
data class UpdatesTab(
private val fromMore: Boolean,
private val inMiddle: Boolean,
) : Tab {
) : Tab() {

override val options: TabOptions
@Composable
Expand Down

0 comments on commit e08926b

Please sign in to comment.