mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Replace reader's Presenter with ViewModel (#8698)
includes: * Use coroutines in more places * Use domain Manga data class and effectively changing the state system * Replace deprecated onBackPress method Co-authored-by: arkon <arkon@users.noreply.github.com>
This commit is contained in:
		@@ -1,17 +1,16 @@
 | 
			
		||||
package eu.kanade.domain.manga.model
 | 
			
		||||
 | 
			
		||||
import eu.kanade.data.listOfStringsAdapter
 | 
			
		||||
import eu.kanade.domain.base.BasePreferences
 | 
			
		||||
import eu.kanade.tachiyomi.data.cache.CoverCache
 | 
			
		||||
import eu.kanade.tachiyomi.data.database.models.MangaImpl
 | 
			
		||||
import eu.kanade.tachiyomi.source.LocalSource
 | 
			
		||||
import eu.kanade.tachiyomi.source.model.SManga
 | 
			
		||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy
 | 
			
		||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
 | 
			
		||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
 | 
			
		||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView
 | 
			
		||||
import uy.kohesive.injekt.Injekt
 | 
			
		||||
import uy.kohesive.injekt.api.get
 | 
			
		||||
import java.io.Serializable
 | 
			
		||||
import eu.kanade.tachiyomi.data.database.models.Manga as DbManga
 | 
			
		||||
 | 
			
		||||
data class Manga(
 | 
			
		||||
    val id: Long,
 | 
			
		||||
@@ -49,6 +48,12 @@ data class Manga(
 | 
			
		||||
    val bookmarkedFilterRaw: Long
 | 
			
		||||
        get() = chapterFlags and CHAPTER_BOOKMARKED_MASK
 | 
			
		||||
 | 
			
		||||
    val readingModeType: Long
 | 
			
		||||
        get() = viewerFlags and ReadingModeType.MASK.toLong()
 | 
			
		||||
 | 
			
		||||
    val orientationType: Long
 | 
			
		||||
        get() = viewerFlags and OrientationType.MASK.toLong()
 | 
			
		||||
 | 
			
		||||
    val unreadFilter: TriStateFilter
 | 
			
		||||
        get() = when (unreadFilterRaw) {
 | 
			
		||||
            CHAPTER_SHOW_UNREAD -> TriStateFilter.ENABLED_IS
 | 
			
		||||
@@ -187,28 +192,6 @@ fun TriStateFilter.toTriStateGroupState(): ExtendedNavigationView.Item.TriStateG
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TODO: Remove when all deps are migrated
 | 
			
		||||
fun Manga.toDbManga(): DbManga = MangaImpl().also {
 | 
			
		||||
    it.id = id
 | 
			
		||||
    it.source = source
 | 
			
		||||
    it.favorite = favorite
 | 
			
		||||
    it.last_update = lastUpdate
 | 
			
		||||
    it.date_added = dateAdded
 | 
			
		||||
    it.viewer_flags = viewerFlags.toInt()
 | 
			
		||||
    it.chapter_flags = chapterFlags.toInt()
 | 
			
		||||
    it.cover_last_modified = coverLastModified
 | 
			
		||||
    it.url = url
 | 
			
		||||
    it.title = title
 | 
			
		||||
    it.artist = artist
 | 
			
		||||
    it.author = author
 | 
			
		||||
    it.description = description
 | 
			
		||||
    it.genre = genre?.let(listOfStringsAdapter::encode)
 | 
			
		||||
    it.status = status.toInt()
 | 
			
		||||
    it.thumbnail_url = thumbnailUrl
 | 
			
		||||
    it.update_strategy = updateStrategy
 | 
			
		||||
    it.initialized = initialized
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fun Manga.toMangaUpdate(): MangaUpdate {
 | 
			
		||||
    return MangaUpdate(
 | 
			
		||||
        id = id,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user