@@ -33,6 +33,8 @@ internal interface MangaRepository {
33
33
val manga: Flow <List <UIManga >>
34
34
val refreshStatus: Flow <MangaRefreshStatus >
35
35
suspend fun getChapterData (mangaId : String ,chapterId : String ): List <String >?
36
+ @Deprecated(" Use UserEvent.RefreshManga event instead of using this directly" )
37
+ suspend fun forceRefresh ()
36
38
}
37
39
38
40
internal class MangaRepositoryImpl (
@@ -64,6 +66,7 @@ internal class MangaRepositoryImpl(
64
66
private var isLoggedIn: Boolean = false
65
67
66
68
init {
69
+ Clog .i(" MangaRepository init" )
67
70
externalScope.launch {
68
71
// refresh manga on login
69
72
try {
@@ -74,17 +77,17 @@ internal class MangaRepositoryImpl(
74
77
is AuthenticationEvent .LoggedIn -> {
75
78
if (! isLoggedIn) {
76
79
isLoggedIn = true
77
- forceRefresh( )
80
+ refreshMangaThrottled( Unit )
78
81
}
79
82
}
80
83
is AuthenticationEvent .LoggedOut -> {
81
84
isLoggedIn = false
82
85
}
83
86
is AppLifecycleEvent .AppForegrounded -> {
84
- forceRefresh( )
87
+ refreshMangaThrottled( Unit )
85
88
}
86
89
is UserEvent .RefreshManga -> {
87
- forceRefresh( )
90
+ refreshMangaThrottled( Unit )
88
91
}
89
92
is UserEvent .SetMarkChapterRead -> {
90
93
markChapterRead(it.mangaId, it.chapterId, it.read)
@@ -102,10 +105,13 @@ internal class MangaRepositoryImpl(
102
105
e.printStackTrace()
103
106
}
104
107
}
108
+
109
+ refreshMangaThrottled(Unit )
105
110
}
106
111
107
- private fun forceRefresh () {
108
- if (isLoggedIn) refreshMangaThrottled(Unit )
112
+ @Deprecated(" Use UserEvent.RefreshManga event instead of using this directly" )
113
+ override suspend fun forceRefresh () {
114
+ refreshMangaThrottled(Unit )
109
115
}
110
116
111
117
private fun generateUIManga (dbSeries : List <MangaEntity >, dbChapters : List <ChapterEntity >): List <UIManga > {
0 commit comments