mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Format round 2
This commit is contained in:
@@ -42,7 +42,7 @@ class App : Application(), DefaultLifecycleObserver {
|
||||
ThemeMode.System -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
ThemeMode.Light -> AppCompatDelegate.MODE_NIGHT_NO
|
||||
ThemeMode.Dark -> AppCompatDelegate.MODE_NIGHT_YES
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
.launchIn(ProcessLifecycleOwner.get().lifecycleScope)
|
||||
@@ -65,8 +65,8 @@ class App : Application(), DefaultLifecycleObserver {
|
||||
AppCompatDelegate.setApplicationLocales(
|
||||
LocaleListCompat.create(
|
||||
Locale.forLanguageTag(it),
|
||||
Locale.forLanguageTag("en")
|
||||
)
|
||||
Locale.forLanguageTag("en"),
|
||||
),
|
||||
)
|
||||
} else if (
|
||||
AppCompatDelegate.getApplicationLocales().isEmpty.not() &&
|
||||
|
||||
@@ -21,7 +21,7 @@ import me.tatarka.inject.annotations.Provides
|
||||
abstract class AppComponent(
|
||||
@get:AppScope
|
||||
@get:Provides
|
||||
val context: Context
|
||||
val context: Context,
|
||||
) : ViewModelComponent, DataComponent, DomainComponent, UiComponent {
|
||||
|
||||
abstract val appMigrations: AppMigrations
|
||||
|
||||
@@ -13,7 +13,7 @@ import me.tatarka.inject.annotations.Inject
|
||||
|
||||
class AppMigrations @Inject constructor(
|
||||
private val migrationPreferences: MigrationPreferences,
|
||||
private val contextWrapper: ContextWrapper
|
||||
private val contextWrapper: ContextWrapper,
|
||||
) {
|
||||
|
||||
fun runMigrations(): Boolean {
|
||||
|
||||
@@ -58,12 +58,12 @@ class MainActivity : AppCompatActivity() {
|
||||
DisposableEffect(systemUiController, useDarkIcons, primaryColor) {
|
||||
systemUiController.setStatusBarColor(
|
||||
color = primaryColor,
|
||||
darkIcons = useDarkIcons
|
||||
darkIcons = useDarkIcons,
|
||||
)
|
||||
systemUiController.setNavigationBarColor(
|
||||
color = Color.Transparent,
|
||||
darkIcons = useDarkIcons,
|
||||
navigationBarContrastEnforced = false
|
||||
navigationBarContrastEnforced = false,
|
||||
)
|
||||
|
||||
onDispose {}
|
||||
|
||||
@@ -44,7 +44,7 @@ class ReaderActivity : AppCompatActivity() {
|
||||
ReaderMenu(
|
||||
chapterIndex = chapterIndex,
|
||||
mangaId = mangaId,
|
||||
onCloseRequest = onBackPressedDispatcher::onBackPressed
|
||||
onCloseRequest = onBackPressedDispatcher::onBackPressed,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,8 @@ class AndroidDownloadService : Service() {
|
||||
log.info { "using an intent with action $action" }
|
||||
when (action) {
|
||||
Actions.START.name,
|
||||
Actions.RESTART.name -> startWebsocket()
|
||||
Actions.RESTART.name,
|
||||
-> startWebsocket()
|
||||
Actions.STOP.name -> stopSelf()
|
||||
else -> log.info { "This should never happen. No action in the received intent" }
|
||||
}
|
||||
@@ -158,7 +159,7 @@ class AndroidDownloadService : Service() {
|
||||
if (serverUrl.protocol == URLProtocol.HTTPS) {
|
||||
url.protocol = URLProtocol.WSS
|
||||
}
|
||||
}
|
||||
},
|
||||
) {
|
||||
errorConnectionCount = 0
|
||||
status.value = Status.RUNNING
|
||||
@@ -208,14 +209,14 @@ class AndroidDownloadService : Service() {
|
||||
MR.strings.chapter_downloading_progress
|
||||
.format(
|
||||
current,
|
||||
max
|
||||
max,
|
||||
)
|
||||
.toString(this@AndroidDownloadService)
|
||||
.toString(this@AndroidDownloadService),
|
||||
)
|
||||
}.build()
|
||||
notificationManager.notify(
|
||||
Notifications.ID_DOWNLOADER_DOWNLOADING,
|
||||
notification
|
||||
notification,
|
||||
)
|
||||
} else {
|
||||
notificationManager.cancel(Notifications.ID_DOWNLOADER_DOWNLOADING)
|
||||
|
||||
@@ -115,7 +115,8 @@ class AndroidLibraryService : Service() {
|
||||
log.info { "using an intent with action $action" }
|
||||
when (action) {
|
||||
Actions.START.name,
|
||||
Actions.RESTART.name -> startWebsocket()
|
||||
Actions.RESTART.name,
|
||||
-> startWebsocket()
|
||||
Actions.STOP.name -> stopSelf()
|
||||
else -> log.info { "This should never happen. No action in the received intent" }
|
||||
}
|
||||
@@ -158,7 +159,7 @@ class AndroidLibraryService : Service() {
|
||||
if (serverUrl.protocol == URLProtocol.HTTPS) {
|
||||
url.protocol = URLProtocol.WSS
|
||||
}
|
||||
}
|
||||
},
|
||||
) {
|
||||
errorConnectionCount = 0
|
||||
status.value = Status.RUNNING
|
||||
@@ -205,14 +206,14 @@ class AndroidLibraryService : Service() {
|
||||
setContentTitle(
|
||||
MR.strings.notification_updating
|
||||
.format(current, total)
|
||||
.toString(this@AndroidLibraryService)
|
||||
.toString(this@AndroidLibraryService),
|
||||
)
|
||||
setStyle(NotificationCompat.BigTextStyle().bigText(updatingText))
|
||||
setProgress(total, current, false)
|
||||
}.build()
|
||||
notificationManager.notify(
|
||||
Notifications.ID_LIBRARY_PROGRESS,
|
||||
notification
|
||||
notification,
|
||||
)
|
||||
} else {
|
||||
notificationManager.cancel(Notifications.ID_LIBRARY_PROGRESS)
|
||||
|
||||
@@ -55,15 +55,15 @@ object Notifications {
|
||||
},
|
||||
buildNotificationChannelGroup(GROUP_APK_UPDATES) {
|
||||
setName(MR.strings.group_updates.desc().toString(context))
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
notificationService.createNotificationChannelsCompat(
|
||||
listOf(
|
||||
buildNotificationChannel(
|
||||
CHANNEL_DOWNLOADER_RUNNING,
|
||||
NotificationManagerCompat.IMPORTANCE_LOW
|
||||
NotificationManagerCompat.IMPORTANCE_LOW,
|
||||
) {
|
||||
setName(MR.strings.channel_active.desc().toString(context))
|
||||
setGroup(GROUP_DOWNLOADER)
|
||||
@@ -71,7 +71,7 @@ object Notifications {
|
||||
},
|
||||
buildNotificationChannel(
|
||||
CHANNEL_DOWNLOADER_DOWNLOADING,
|
||||
NotificationManagerCompat.IMPORTANCE_LOW
|
||||
NotificationManagerCompat.IMPORTANCE_LOW,
|
||||
) {
|
||||
setName(MR.strings.channel_progress.desc().toString(context))
|
||||
setGroup(GROUP_DOWNLOADER)
|
||||
@@ -79,7 +79,7 @@ object Notifications {
|
||||
},
|
||||
buildNotificationChannel(
|
||||
CHANNEL_LIBRARY_UPDATES,
|
||||
NotificationManagerCompat.IMPORTANCE_LOW
|
||||
NotificationManagerCompat.IMPORTANCE_LOW,
|
||||
) {
|
||||
setName(MR.strings.channel_active.desc().toString(context))
|
||||
setGroup(GROUP_LIBRARY)
|
||||
@@ -87,7 +87,7 @@ object Notifications {
|
||||
},
|
||||
buildNotificationChannel(
|
||||
CHANNEL_LIBRARY_PROGRESS,
|
||||
NotificationManagerCompat.IMPORTANCE_LOW
|
||||
NotificationManagerCompat.IMPORTANCE_LOW,
|
||||
) {
|
||||
setName(MR.strings.channel_progress.desc().toString(context))
|
||||
setGroup(GROUP_LIBRARY)
|
||||
@@ -95,19 +95,19 @@ object Notifications {
|
||||
},
|
||||
buildNotificationChannel(
|
||||
CHANNEL_APP_UPDATE,
|
||||
NotificationManagerCompat.IMPORTANCE_DEFAULT
|
||||
NotificationManagerCompat.IMPORTANCE_DEFAULT,
|
||||
) {
|
||||
setGroup(GROUP_APK_UPDATES)
|
||||
setName(MR.strings.group_updates_channel_app.desc().toString(context))
|
||||
},
|
||||
buildNotificationChannel(
|
||||
CHANNEL_EXTENSIONS_UPDATE,
|
||||
NotificationManagerCompat.IMPORTANCE_DEFAULT
|
||||
NotificationManagerCompat.IMPORTANCE_DEFAULT,
|
||||
) {
|
||||
setGroup(GROUP_APK_UPDATES)
|
||||
setName(MR.strings.group_updates_channel_ext.desc().toString(context))
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class UpdateCheckWorker(private val context: Context, workerParams: WorkerParame
|
||||
7,
|
||||
TimeUnit.DAYS,
|
||||
3,
|
||||
TimeUnit.HOURS
|
||||
TimeUnit.HOURS,
|
||||
)
|
||||
.addTag(TAG)
|
||||
.setConstraints(constraints)
|
||||
|
||||
@@ -20,7 +20,7 @@ import androidx.core.app.NotificationChannelGroupCompat
|
||||
*/
|
||||
fun buildNotificationChannelGroup(
|
||||
channelId: String,
|
||||
block: (NotificationChannelGroupCompat.Builder.() -> Unit)
|
||||
block: (NotificationChannelGroupCompat.Builder.() -> Unit),
|
||||
): NotificationChannelGroupCompat {
|
||||
val builder = NotificationChannelGroupCompat.Builder(channelId)
|
||||
builder.block()
|
||||
@@ -38,7 +38,7 @@ fun buildNotificationChannelGroup(
|
||||
fun buildNotificationChannel(
|
||||
channelId: String,
|
||||
channelImportance: Int,
|
||||
block: (NotificationChannelCompat.Builder.() -> Unit)
|
||||
block: (NotificationChannelCompat.Builder.() -> Unit),
|
||||
): NotificationChannelCompat {
|
||||
val builder = NotificationChannelCompat.Builder(channelId, channelImportance)
|
||||
builder.block()
|
||||
|
||||
@@ -16,9 +16,9 @@ actual class PreferenceStoreFactory @Inject constructor(private val context: Con
|
||||
SharedPreferencesSettings(
|
||||
context.getSharedPreferences(
|
||||
names.joinToString(separator = "_"),
|
||||
Context.MODE_PRIVATE
|
||||
)
|
||||
)
|
||||
Context.MODE_PRIVATE,
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,46 +18,46 @@ import kotlinx.coroutines.withContext
|
||||
@DelicateCoroutinesApi
|
||||
fun launch(
|
||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||
block: suspend CoroutineScope.() -> Unit
|
||||
block: suspend CoroutineScope.() -> Unit,
|
||||
) = GlobalScope.launch(Dispatchers.Default, start, block)
|
||||
|
||||
@DelicateCoroutinesApi
|
||||
fun launchUI(
|
||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||
block: suspend CoroutineScope.() -> Unit
|
||||
block: suspend CoroutineScope.() -> Unit,
|
||||
) = GlobalScope.launch(Dispatchers.Main, start, block)
|
||||
|
||||
@DelicateCoroutinesApi
|
||||
fun launchIO(
|
||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||
block: suspend CoroutineScope.() -> Unit
|
||||
block: suspend CoroutineScope.() -> Unit,
|
||||
) = GlobalScope.launch(Dispatchers.IO, start, block)
|
||||
|
||||
fun CoroutineScope.launchDefault(
|
||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||
block: suspend CoroutineScope.() -> Unit
|
||||
block: suspend CoroutineScope.() -> Unit,
|
||||
) = launch(Dispatchers.Default, start, block)
|
||||
|
||||
fun CoroutineScope.launchUI(
|
||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||
block: suspend CoroutineScope.() -> Unit
|
||||
block: suspend CoroutineScope.() -> Unit,
|
||||
) = launch(Dispatchers.Main, start, block)
|
||||
|
||||
fun CoroutineScope.launchIO(
|
||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||
block: suspend CoroutineScope.() -> Unit
|
||||
block: suspend CoroutineScope.() -> Unit,
|
||||
) = launch(Dispatchers.IO, start, block)
|
||||
|
||||
suspend fun <T> withDefaultContext(
|
||||
block: suspend CoroutineScope.() -> T
|
||||
block: suspend CoroutineScope.() -> T,
|
||||
): T = withContext(Dispatchers.Default, block)
|
||||
|
||||
suspend fun <T> withUIContext(
|
||||
block: suspend CoroutineScope.() -> T
|
||||
block: suspend CoroutineScope.() -> T,
|
||||
): T = withContext(Dispatchers.Main, block)
|
||||
|
||||
suspend fun <T> withIOContext(
|
||||
block: suspend CoroutineScope.() -> T
|
||||
block: suspend CoroutineScope.() -> T,
|
||||
): T = withContext(Dispatchers.IO, block)
|
||||
|
||||
fun Throwable.throwIfCancellation() { if (this is CancellationException) throw this }
|
||||
|
||||
@@ -26,7 +26,7 @@ import kotlinx.coroutines.yield
|
||||
*/
|
||||
internal open class ProcessChannel<T>(
|
||||
internal val inChannel: Channel<T>,
|
||||
internal val outChannel: Channel<T>
|
||||
internal val outChannel: Channel<T>,
|
||||
) : Channel<T> {
|
||||
@ExperimentalCoroutinesApi
|
||||
override val isClosedForReceive: Boolean
|
||||
@@ -46,7 +46,7 @@ internal open class ProcessChannel<T>(
|
||||
|
||||
@Deprecated(
|
||||
"Since 1.2.0, binary compatibility with versions <= 1.1.x",
|
||||
level = DeprecationLevel.HIDDEN
|
||||
level = DeprecationLevel.HIDDEN,
|
||||
)
|
||||
override fun cancel(cause: Throwable?): Boolean {
|
||||
outChannel.cancel()
|
||||
@@ -67,14 +67,14 @@ internal open class ProcessChannel<T>(
|
||||
@Deprecated(
|
||||
"Deprecated in the favour of 'trySend' method",
|
||||
replaceWith = ReplaceWith("trySend(element).isSuccess"),
|
||||
level = DeprecationLevel.ERROR
|
||||
level = DeprecationLevel.ERROR,
|
||||
)
|
||||
override fun offer(element: T): Boolean = inChannel.trySend(element).isSuccess
|
||||
|
||||
@Deprecated(
|
||||
"Deprecated in the favour of 'tryReceive'. Please note that the provided replacement does not rethrow channel's close cause as 'poll' did, for the precise replacement please refer to the 'poll' documentation",
|
||||
replaceWith = ReplaceWith("tryReceive().getOrNull()"),
|
||||
level = DeprecationLevel.ERROR
|
||||
level = DeprecationLevel.ERROR,
|
||||
)
|
||||
override fun poll(): T? = outChannel.tryReceive().getOrNull()
|
||||
|
||||
@@ -101,7 +101,7 @@ internal open class ProcessChannel<T>(
|
||||
internal class PriorityChannelImpl<T>(
|
||||
private val maxCapacity: Int,
|
||||
scope: CoroutineScope,
|
||||
comparator: Comparator<T>
|
||||
comparator: Comparator<T>,
|
||||
) : ProcessChannel<T>(
|
||||
// why a rendezvous channel should be the input channel?
|
||||
// because we buffer and sort the messages in the co-routine
|
||||
@@ -111,7 +111,7 @@ internal class PriorityChannelImpl<T>(
|
||||
// output channel is rendezvous channel because we may still
|
||||
// get higher priority input meanwhile and we will send that
|
||||
// when output consumer is ready to take it
|
||||
outChannel = Channel(Channel.RENDEZVOUS)
|
||||
outChannel = Channel(Channel.RENDEZVOUS),
|
||||
) {
|
||||
private val buffer = PriorityQueue(comparator)
|
||||
|
||||
@@ -198,5 +198,5 @@ internal class PriorityChannelImpl<T>(
|
||||
fun <T> PriorityChannel(
|
||||
maxCapacity: Int = 4096,
|
||||
scope: CoroutineScope,
|
||||
comparator: Comparator<T>
|
||||
comparator: Comparator<T>,
|
||||
): Channel<T> = PriorityChannelImpl(maxCapacity, scope, comparator)
|
||||
|
||||
@@ -14,7 +14,7 @@ import kotlinx.serialization.modules.SerializersModule
|
||||
* providing preference instances to classes that may not use them at all.
|
||||
*/
|
||||
class LazyPreferenceStore(
|
||||
private val lazyStore: Lazy<PreferenceStore>
|
||||
private val lazyStore: Lazy<PreferenceStore>,
|
||||
) : PreferenceStore {
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ class LazyPreferenceStore(
|
||||
key: String,
|
||||
defaultValue: T,
|
||||
serializer: (T) -> String,
|
||||
deserializer: (String) -> T
|
||||
deserializer: (String) -> T,
|
||||
): Preference<T> {
|
||||
return lazyStore.value.getObject(key, defaultValue, serializer, deserializer)
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class LazyPreferenceStore(
|
||||
key: String,
|
||||
defaultValue: T,
|
||||
serializer: KSerializer<T>,
|
||||
serializersModule: SerializersModule
|
||||
serializersModule: SerializersModule,
|
||||
): Preference<T> {
|
||||
return lazyStore.value.getJsonObject(key, defaultValue, serializer)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ interface PreferenceStore {
|
||||
key: String,
|
||||
defaultValue: T,
|
||||
serializer: (T) -> String,
|
||||
deserializer: (String) -> T
|
||||
deserializer: (String) -> T,
|
||||
): Preference<T>
|
||||
|
||||
/**
|
||||
@@ -64,7 +64,7 @@ interface PreferenceStore {
|
||||
key: String,
|
||||
defaultValue: T,
|
||||
serializer: KSerializer<T>,
|
||||
serializersModule: SerializersModule = EmptySerializersModule()
|
||||
serializersModule: SerializersModule = EmptySerializersModule(),
|
||||
): Preference<T>
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ interface PreferenceStore {
|
||||
*/
|
||||
inline fun <reified T : Enum<T>> PreferenceStore.getEnum(
|
||||
key: String,
|
||||
defaultValue: T
|
||||
defaultValue: T,
|
||||
): Preference<T> {
|
||||
return getObject(
|
||||
key,
|
||||
@@ -85,6 +85,6 @@ inline fun <reified T : Enum<T>> PreferenceStore.getEnum(
|
||||
} catch (e: IllegalArgumentException) {
|
||||
defaultValue
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ internal object StringSetAdapter : Adapter<Set<String>> {
|
||||
|
||||
internal class ObjectAdapter<T>(
|
||||
private val serializer: (T) -> String,
|
||||
private val deserializer: (String) -> T
|
||||
private val deserializer: (String) -> T,
|
||||
) : Adapter<T> {
|
||||
|
||||
override fun get(key: String, preferences: ObservableSettings): T {
|
||||
@@ -144,7 +144,7 @@ internal class ObjectAdapter<T>(
|
||||
internal class JsonObjectAdapter<T>(
|
||||
private val defaultValue: T,
|
||||
private val serializer: KSerializer<T>,
|
||||
private val serializersModule: SerializersModule = EmptySerializersModule()
|
||||
private val serializersModule: SerializersModule = EmptySerializersModule(),
|
||||
) : Adapter<T> {
|
||||
|
||||
override fun get(key: String, preferences: ObservableSettings): T {
|
||||
|
||||
@@ -19,7 +19,7 @@ internal class StandardPreference<T>(
|
||||
private val preferences: ObservableSettings,
|
||||
private val key: String,
|
||||
private val defaultValue: T,
|
||||
private val adapter: Adapter<T>
|
||||
private val adapter: Adapter<T>,
|
||||
) : Preference<T> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,7 +62,7 @@ class StandardPreferenceStore(private val preferences: ObservableSettings) : Pre
|
||||
key: String,
|
||||
defaultValue: T,
|
||||
serializer: (T) -> String,
|
||||
deserializer: (String) -> T
|
||||
deserializer: (String) -> T,
|
||||
): Preference<T> {
|
||||
val adapter = ObjectAdapter(serializer, deserializer)
|
||||
return StandardPreference(preferences, key, defaultValue, adapter)
|
||||
@@ -75,7 +75,7 @@ class StandardPreferenceStore(private val preferences: ObservableSettings) : Pre
|
||||
key: String,
|
||||
defaultValue: T,
|
||||
serializer: KSerializer<T>,
|
||||
serializersModule: SerializersModule
|
||||
serializersModule: SerializersModule,
|
||||
): Preference<T> {
|
||||
val adapter = JsonObjectAdapter(defaultValue, serializer, serializersModule)
|
||||
return StandardPreference(preferences, key, defaultValue, adapter)
|
||||
|
||||
@@ -40,6 +40,6 @@ object ImageUtil {
|
||||
JPG("image/jpeg", "jpg"),
|
||||
PNG("image/png", "png"),
|
||||
GIF("image/gif", "gif"),
|
||||
WEBP("image/webp", "webp")
|
||||
WEBP("image/webp", "webp"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ actual class PreferenceStoreFactory @Inject constructor() {
|
||||
actual fun create(vararg names: String): PreferenceStore {
|
||||
return StandardPreferenceStore(
|
||||
PreferencesSettings(
|
||||
rootNode.node(names.joinToString(separator = "/"))
|
||||
)
|
||||
rootNode.node(names.joinToString(separator = "/")),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ actual class PreferenceStoreFactory @Inject constructor() {
|
||||
actual fun create(vararg names: String): PreferenceStore {
|
||||
return StandardPreferenceStore(
|
||||
NSUserDefaultsSettings(
|
||||
NSUserDefaults.standardUserDefaults
|
||||
)
|
||||
NSUserDefaults.standardUserDefaults,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class FlowIOResponseConverter @Inject constructor(private val json: Json) : Resp
|
||||
override fun <RequestType : Any?> wrapResponse(
|
||||
typeData: TypeData,
|
||||
requestFunction: suspend () -> Pair<TypeInfo, HttpResponse?>,
|
||||
ktorfit: Ktorfit
|
||||
ktorfit: Ktorfit,
|
||||
): Any {
|
||||
return flow {
|
||||
try {
|
||||
|
||||
@@ -21,7 +21,7 @@ actual class DateHandler @Inject constructor() {
|
||||
"",
|
||||
"MM/dd/yy",
|
||||
"dd/MM/yy",
|
||||
"yyyy-MM-dd"
|
||||
"yyyy-MM-dd",
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ actual class DateHandler @Inject constructor() {
|
||||
"",
|
||||
"MM/dd/yy",
|
||||
"dd/MM/yy",
|
||||
"yyyy-MM-dd"
|
||||
"yyyy-MM-dd",
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import me.tatarka.inject.annotations.Provides
|
||||
@Component
|
||||
abstract class AppComponent(
|
||||
@get:Provides
|
||||
val context: ContextWrapper
|
||||
val context: ContextWrapper,
|
||||
) : ViewModelComponent, DataComponent, DomainComponent, UiComponent {
|
||||
|
||||
abstract val appMigrations: AppMigrations
|
||||
|
||||
@@ -13,7 +13,7 @@ import me.tatarka.inject.annotations.Inject
|
||||
|
||||
class AppMigrations @Inject constructor(
|
||||
private val migrationPreferences: MigrationPreferences,
|
||||
private val contextWrapper: ContextWrapper
|
||||
private val contextWrapper: ContextWrapper,
|
||||
) {
|
||||
|
||||
fun runMigrations(): Boolean {
|
||||
|
||||
@@ -47,45 +47,45 @@ fun initializeLogger(loggingLocation: Path) {
|
||||
newAppender("Console", "Console")
|
||||
.addAttribute(
|
||||
"target",
|
||||
ConsoleAppender.Target.SYSTEM_OUT
|
||||
ConsoleAppender.Target.SYSTEM_OUT,
|
||||
)
|
||||
.add(
|
||||
newLayout("PatternLayout")
|
||||
.addAttribute("disableAnsi", "false")
|
||||
.addAttribute("pattern", consolePattern)
|
||||
)
|
||||
.addAttribute("pattern", consolePattern),
|
||||
),
|
||||
)
|
||||
add(
|
||||
newAppender("Rolling", "RollingFile")
|
||||
.addAttribute(
|
||||
"fileName",
|
||||
loggingLocation.toString().trimEnd('/', '\\') + "/rolling.log"
|
||||
loggingLocation.toString().trimEnd('/', '\\') + "/rolling.log",
|
||||
)
|
||||
.addAttribute(
|
||||
"filePattern",
|
||||
loggingLocation.toString().trimEnd('/', '\\') + "/archive/rolling-%d{yyyy-MM-dd-}.log.gz"
|
||||
loggingLocation.toString().trimEnd('/', '\\') + "/archive/rolling-%d{yyyy-MM-dd-}.log.gz",
|
||||
)
|
||||
.add(
|
||||
newLayout("PatternLayout")
|
||||
.addAttribute("pattern", filePattern)
|
||||
.addAttribute("pattern", filePattern),
|
||||
)
|
||||
.addComponent(
|
||||
newComponent<_>("Policies")
|
||||
.addComponent(
|
||||
newComponent<_>("CronTriggeringPolicy")
|
||||
.addAttribute("schedule", "0 0 0 * * ?")
|
||||
.addAttribute("evaluateOnStartup", "true")
|
||||
.addAttribute("evaluateOnStartup", "true"),
|
||||
)
|
||||
.addComponent(
|
||||
newComponent<_>("SizeBasedTriggeringPolicy")
|
||||
.addAttribute("size", "100M")
|
||||
)
|
||||
)
|
||||
.addAttribute("size", "100M"),
|
||||
),
|
||||
),
|
||||
)
|
||||
add(
|
||||
newRootLogger(Level.DEBUG)
|
||||
.add(newAppenderRef("Console"))
|
||||
.add(newAppenderRef("Rolling"))
|
||||
.add(newAppenderRef("Rolling")),
|
||||
)
|
||||
}
|
||||
ctx.configuration = builder.build()
|
||||
@@ -97,7 +97,7 @@ fun initializeLogger(loggingLocation: Path) {
|
||||
java.util.logging.Level.FINE
|
||||
} else {
|
||||
java.util.logging.Level.WARNING
|
||||
}
|
||||
},
|
||||
)
|
||||
JLogManager.getLogManager().getLogger("com.github.weisj.darklaf").apply {
|
||||
handlers.forEach { removeHandler(it) }
|
||||
|
||||
@@ -143,7 +143,7 @@ suspend fun main() {
|
||||
val (
|
||||
position,
|
||||
size,
|
||||
placement
|
||||
placement,
|
||||
) = WindowGet.from(windowSettings.get())
|
||||
|
||||
val confirmExit = uiPreferences.confirmExit().asStateIn(GlobalScope)
|
||||
@@ -161,7 +161,7 @@ suspend fun main() {
|
||||
val windowState = rememberWindowState(
|
||||
size = size,
|
||||
position = position,
|
||||
placement = placement
|
||||
placement = placement,
|
||||
)
|
||||
|
||||
val icon = remember { StableHolder(MR.images.icon.image.toPainter()) }
|
||||
@@ -197,7 +197,7 @@ suspend fun main() {
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
},
|
||||
) {
|
||||
LaunchedEffect(Unit) {
|
||||
serverService.startServer()
|
||||
@@ -216,7 +216,7 @@ suspend fun main() {
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.padding(bottom = 64.dp),
|
||||
context = context
|
||||
context = context,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -226,7 +226,7 @@ suspend fun main() {
|
||||
initialized == ServerResult.STARTING,
|
||||
errorMessage = stringResource(MR.strings.unable_to_start_server),
|
||||
retryMessage = stringResource(MR.strings.action_start_anyway),
|
||||
retry = serverService::startAnyway
|
||||
retry = serverService::startAnyway,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -240,8 +240,8 @@ suspend fun main() {
|
||||
negativeButton(stringResource(MR.strings.action_cancel))
|
||||
},
|
||||
properties = getMaterialDialogProperties(
|
||||
size = DpSize(400.dp, 200.dp)
|
||||
)
|
||||
size = DpSize(400.dp, 200.dp),
|
||||
),
|
||||
) {
|
||||
title(stringResource(MR.strings.confirm_exit))
|
||||
message(stringResource(MR.strings.confirm_exit_message))
|
||||
@@ -269,7 +269,7 @@ fun ToastOverlay(modifier: Modifier, context: ContextWrapper) {
|
||||
Length.SHORT -> 2.seconds
|
||||
Length.LONG -> 5.seconds
|
||||
else -> ZERO
|
||||
}
|
||||
},
|
||||
)
|
||||
toast = null
|
||||
}
|
||||
@@ -277,13 +277,13 @@ fun ToastOverlay(modifier: Modifier, context: ContextWrapper) {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
Crossfade(
|
||||
toast?.first,
|
||||
modifier = modifier
|
||||
modifier = modifier,
|
||||
) { toast ->
|
||||
if (toast != null) {
|
||||
Card(
|
||||
Modifier.sizeIn(maxWidth = 200.dp),
|
||||
shape = CircleShape,
|
||||
backgroundColor = Color.DarkGray
|
||||
backgroundColor = Color.DarkGray,
|
||||
) {
|
||||
Text(
|
||||
toast,
|
||||
@@ -292,7 +292,7 @@ fun ToastOverlay(modifier: Modifier, context: ContextWrapper) {
|
||||
maxLines = 2,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
fontSize = 12.sp,
|
||||
textAlign = TextAlign.Center
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,26 +29,26 @@ class ServerListeners @Inject constructor() {
|
||||
private fun <T> Flow<T>.startWith(value: T) = onStart { emit(value) }
|
||||
|
||||
private val _mangaListener = MutableSharedFlow<List<Long>>(
|
||||
extraBufferCapacity = Channel.UNLIMITED
|
||||
extraBufferCapacity = Channel.UNLIMITED,
|
||||
)
|
||||
val mangaListener = _mangaListener.asSharedFlow()
|
||||
|
||||
private val _chapterIndexesListener = MutableSharedFlow<Pair<Long, List<Int>?>>(
|
||||
extraBufferCapacity = Channel.UNLIMITED
|
||||
extraBufferCapacity = Channel.UNLIMITED,
|
||||
)
|
||||
val chapterIndexesListener = _chapterIndexesListener.asSharedFlow()
|
||||
|
||||
private val _chapterIdsListener = MutableSharedFlow<Pair<Long?, List<Long>>>(
|
||||
extraBufferCapacity = Channel.UNLIMITED
|
||||
extraBufferCapacity = Channel.UNLIMITED,
|
||||
)
|
||||
val chapterIdsListener = _chapterIdsListener.asSharedFlow()
|
||||
|
||||
private val categoryMangaListener = MutableSharedFlow<Long>(
|
||||
extraBufferCapacity = Channel.UNLIMITED
|
||||
extraBufferCapacity = Channel.UNLIMITED,
|
||||
)
|
||||
|
||||
private val extensionListener = MutableSharedFlow<List<String>>(
|
||||
extraBufferCapacity = Channel.UNLIMITED
|
||||
extraBufferCapacity = Channel.UNLIMITED,
|
||||
)
|
||||
|
||||
fun <T> combineMangaUpdates(flow: Flow<T>, predate: (suspend (List<Long>) -> Boolean)? = null) =
|
||||
@@ -86,7 +86,7 @@ class ServerListeners @Inject constructor() {
|
||||
fun <T> combineChapters(
|
||||
flow: Flow<T>,
|
||||
indexPredate: (suspend (Long, List<Int>?) -> Boolean)? = null,
|
||||
idPredate: (suspend (Long?, List<Long>) -> Boolean)? = null
|
||||
idPredate: (suspend (Long?, List<Long>) -> Boolean)? = null,
|
||||
): Flow<T> {
|
||||
val indexListener = if (indexPredate != null) {
|
||||
_chapterIndexesListener.filter { indexPredate(it.first, it.second) }.startWith(Unit)
|
||||
|
||||
@@ -11,5 +11,5 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class BackupValidationResult(
|
||||
val missingSources: List<String>,
|
||||
val missingTrackers: List<String>
|
||||
val missingTrackers: List<String>,
|
||||
)
|
||||
|
||||
@@ -31,19 +31,19 @@ interface BackupRepository {
|
||||
@POST("api/v1/backup/import/file")
|
||||
fun importBackupFile(
|
||||
@Part("") formData: List<PartData>,
|
||||
@ReqBuilder block: HttpRequestBuilder.() -> Unit = {}
|
||||
@ReqBuilder block: HttpRequestBuilder.() -> Unit = {},
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@Multipart
|
||||
@POST("api/v1/backup/validate/file")
|
||||
fun validateBackupFile(
|
||||
@Part("") formData: List<PartData>,
|
||||
@ReqBuilder block: HttpRequestBuilder.() -> Unit = {}
|
||||
@ReqBuilder block: HttpRequestBuilder.() -> Unit = {},
|
||||
): Flow<BackupValidationResult>
|
||||
|
||||
@GET("api/v1/backup/export/file")
|
||||
fun exportBackupFile(
|
||||
@ReqBuilder block: HttpRequestBuilder.() -> Unit = {}
|
||||
@ReqBuilder block: HttpRequestBuilder.() -> Unit = {},
|
||||
): Flow<HttpResponse>
|
||||
|
||||
companion object {
|
||||
@@ -54,7 +54,7 @@ interface BackupRepository {
|
||||
Headers.build {
|
||||
append(HttpHeaders.ContentType, ContentType.MultiPart.FormData.toString())
|
||||
append(HttpHeaders.ContentDisposition, "filename=backup.proto.gz")
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.lighthousegames.logging.logging
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
abstract class WebsocketService(
|
||||
protected val serverPreferences: ServerPreferences,
|
||||
protected val client: Http
|
||||
protected val client: Http,
|
||||
) {
|
||||
protected val json = Json {
|
||||
ignoreUnknownKeys = true
|
||||
@@ -62,7 +62,7 @@ abstract class WebsocketService(
|
||||
if (serverUrl.protocol == URLProtocol.HTTPS) {
|
||||
url.protocol = URLProtocol.WSS
|
||||
}
|
||||
}
|
||||
},
|
||||
) {
|
||||
errorConnectionCount = 0
|
||||
_status.value = Status.RUNNING
|
||||
@@ -96,13 +96,13 @@ abstract class WebsocketService(
|
||||
enum class Status {
|
||||
STARTING,
|
||||
RUNNING,
|
||||
STOPPED
|
||||
STOPPED,
|
||||
}
|
||||
|
||||
enum class Actions {
|
||||
STOP,
|
||||
START,
|
||||
RESTART
|
||||
RESTART,
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class AddMangaToCategory @Inject constructor(
|
||||
private val categoryRepository: CategoryRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, categoryId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId, categoryId)
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class GetMangaListFromCategory @Inject constructor(
|
||||
private val categoryRepository: CategoryRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(categoryId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(categoryId)
|
||||
@@ -37,11 +37,11 @@ class GetMangaListFromCategory @Inject constructor(
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(categoryId: Long) = serverListeners.combineCategoryManga(
|
||||
categoryRepository.getMangaFromCategory(categoryId)
|
||||
categoryRepository.getMangaFromCategory(categoryId),
|
||||
) { categoryId == it }
|
||||
|
||||
fun asFlow(category: Category) = serverListeners.combineCategoryManga(
|
||||
categoryRepository.getMangaFromCategory(category.id)
|
||||
categoryRepository.getMangaFromCategory(category.id),
|
||||
) { category.id == it }
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -17,7 +17,7 @@ class ModifyCategory @Inject constructor(private val categoryRepository: Categor
|
||||
|
||||
suspend fun await(categoryId: Long, name: String, onError: suspend (Throwable) -> Unit = {}) = asFlow(
|
||||
categoryId = categoryId,
|
||||
name = name
|
||||
name = name,
|
||||
).catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to modify category $categoryId with options: name=$name" }
|
||||
@@ -25,7 +25,7 @@ class ModifyCategory @Inject constructor(private val categoryRepository: Categor
|
||||
|
||||
suspend fun await(category: Category, name: String? = null, onError: suspend (Throwable) -> Unit = {}) = asFlow(
|
||||
category = category,
|
||||
name = name
|
||||
name = name,
|
||||
).catch {
|
||||
onError(it)
|
||||
log.warn(it) { "Failed to modify category ${category.name} with options: name=$name" }
|
||||
@@ -33,12 +33,12 @@ class ModifyCategory @Inject constructor(private val categoryRepository: Categor
|
||||
|
||||
fun asFlow(categoryId: Long, name: String) = categoryRepository.modifyCategory(
|
||||
categoryId = categoryId,
|
||||
name = name
|
||||
name = name,
|
||||
)
|
||||
|
||||
fun asFlow(category: Category, name: String? = null) = categoryRepository.modifyCategory(
|
||||
categoryId = category.id,
|
||||
name = name ?: category.name
|
||||
name = name ?: category.name,
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class RemoveMangaFromCategory @Inject constructor(
|
||||
private val categoryRepository: CategoryRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, categoryId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId, categoryId)
|
||||
|
||||
@@ -19,7 +19,7 @@ class UpdateCategoryMeta @Inject constructor(private val categoryRepository: Cat
|
||||
suspend fun await(
|
||||
category: Category,
|
||||
example: Int = category.meta.example,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(category, example)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -29,13 +29,13 @@ class UpdateCategoryMeta @Inject constructor(private val categoryRepository: Cat
|
||||
|
||||
fun asFlow(
|
||||
category: Category,
|
||||
example: Int = category.meta.example
|
||||
example: Int = category.meta.example,
|
||||
) = flow {
|
||||
if (example != category.meta.example) {
|
||||
categoryRepository.updateCategoryMeta(
|
||||
category.id,
|
||||
"example",
|
||||
example.toString()
|
||||
example.toString(),
|
||||
).collect()
|
||||
}
|
||||
emit(Unit)
|
||||
|
||||
@@ -16,11 +16,11 @@ data class Category(
|
||||
val order: Int,
|
||||
val name: String,
|
||||
val default: Boolean,
|
||||
val meta: CategoryMeta
|
||||
val meta: CategoryMeta,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@Immutable
|
||||
data class CategoryMeta(
|
||||
val example: Int = 0
|
||||
val example: Int = 0,
|
||||
)
|
||||
|
||||
@@ -21,19 +21,19 @@ import kotlinx.coroutines.flow.Flow
|
||||
interface CategoryRepository {
|
||||
@GET("api/v1/manga/{mangaId}/category/")
|
||||
fun getMangaCategories(
|
||||
@Path("mangaId") mangaId: Long
|
||||
@Path("mangaId") mangaId: Long,
|
||||
): Flow<List<Category>>
|
||||
|
||||
@GET("api/v1/manga/{mangaId}/category/{categoryId}")
|
||||
fun addMangaToCategory(
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Path("categoryId") categoryId: Long
|
||||
@Path("categoryId") categoryId: Long,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@DELETE("api/v1/manga/{mangaId}/category/{categoryId}")
|
||||
fun removeMangaFromCategory(
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Path("categoryId") categoryId: Long
|
||||
@Path("categoryId") categoryId: Long,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@GET("api/v1/category/")
|
||||
@@ -42,31 +42,31 @@ interface CategoryRepository {
|
||||
@FormUrlEncoded
|
||||
@POST("api/v1/category/")
|
||||
fun createCategory(
|
||||
@Field("name") name: String
|
||||
@Field("name") name: String,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@FormUrlEncoded
|
||||
@PATCH("api/v1/category/{categoryId}")
|
||||
fun modifyCategory(
|
||||
@Path("categoryId") categoryId: Long,
|
||||
@Field("name") name: String
|
||||
@Field("name") name: String,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@FormUrlEncoded
|
||||
@PATCH("api/v1/category/reorder")
|
||||
fun reorderCategory(
|
||||
@Field("to") to: Int,
|
||||
@Field("from") from: Int
|
||||
@Field("from") from: Int,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@DELETE("api/v1/category/{categoryId}")
|
||||
fun deleteCategory(
|
||||
@Path("categoryId") categoryId: Long
|
||||
@Path("categoryId") categoryId: Long,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@GET("api/v1/category/{categoryId}")
|
||||
fun getMangaFromCategory(
|
||||
@Path("categoryId") categoryId: Long
|
||||
@Path("categoryId") categoryId: Long,
|
||||
): Flow<List<Manga>>
|
||||
|
||||
@FormUrlEncoded
|
||||
@@ -74,6 +74,6 @@ interface CategoryRepository {
|
||||
fun updateCategoryMeta(
|
||||
@Path("categoryId") categoryId: Long,
|
||||
@Field("key") key: String,
|
||||
@Field("value") value: String
|
||||
@Field("value") value: String,
|
||||
): Flow<HttpResponse>
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import kotlin.jvm.JvmName
|
||||
|
||||
class BatchUpdateChapter @Inject constructor(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
@JvmName("awaitChapters")
|
||||
@@ -33,7 +33,7 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isBookmarked: Boolean? = null,
|
||||
lastPageRead: Int? = null,
|
||||
delete: Boolean? = null,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(mangaId, chapters, isRead, isBookmarked, lastPageRead, delete)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -48,7 +48,7 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isBookmarked: Boolean? = null,
|
||||
lastPageRead: Int? = null,
|
||||
delete: Boolean? = null,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(mangaId, chapterIds, isRead, isBookmarked, lastPageRead, delete)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -64,7 +64,7 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isBookmarked: Boolean? = null,
|
||||
lastPageRead: Int? = null,
|
||||
delete: Boolean? = null,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(manga, chapters, isRead, isBookmarked, lastPageRead, delete)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -79,7 +79,7 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isBookmarked: Boolean? = null,
|
||||
lastPageRead: Int? = null,
|
||||
delete: Boolean? = null,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(manga, chapterIds, isRead, isBookmarked, lastPageRead, delete)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -94,7 +94,7 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isBookmarked: Boolean? = null,
|
||||
lastPageRead: Int? = null,
|
||||
delete: Boolean? = null,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(chapters, isRead, isBookmarked, lastPageRead, delete)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -108,7 +108,7 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isBookmarked: Boolean? = null,
|
||||
lastPageRead: Int? = null,
|
||||
delete: Boolean? = null,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(chapterIds, isRead, isBookmarked, lastPageRead, delete)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -123,14 +123,14 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isRead: Boolean? = null,
|
||||
isBookmarked: Boolean? = null,
|
||||
lastPageRead: Int? = null,
|
||||
delete: Boolean? = null
|
||||
delete: Boolean? = null,
|
||||
) = getFlow(
|
||||
mangaId = mangaId,
|
||||
chapterIds = chapters.map { it.id },
|
||||
isRead = isRead,
|
||||
isBookmarked = isBookmarked,
|
||||
lastPageRead = lastPageRead,
|
||||
delete = delete
|
||||
delete = delete,
|
||||
)
|
||||
|
||||
fun asFlow(
|
||||
@@ -139,14 +139,14 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isRead: Boolean? = null,
|
||||
isBookmarked: Boolean? = null,
|
||||
lastPageRead: Int? = null,
|
||||
delete: Boolean? = null
|
||||
delete: Boolean? = null,
|
||||
) = getFlow(
|
||||
mangaId = mangaId,
|
||||
chapterIds = chapterIds,
|
||||
isRead = isRead,
|
||||
isBookmarked = isBookmarked,
|
||||
lastPageRead = lastPageRead,
|
||||
delete = delete
|
||||
delete = delete,
|
||||
)
|
||||
|
||||
@JvmName("asFlowChapters")
|
||||
@@ -156,14 +156,14 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isRead: Boolean? = null,
|
||||
isBookmarked: Boolean? = null,
|
||||
lastPageRead: Int? = null,
|
||||
delete: Boolean? = null
|
||||
delete: Boolean? = null,
|
||||
) = getFlow(
|
||||
mangaId = manga.id,
|
||||
chapterIds = chapters.map { it.id },
|
||||
isRead = isRead,
|
||||
isBookmarked = isBookmarked,
|
||||
lastPageRead = lastPageRead,
|
||||
delete = delete
|
||||
delete = delete,
|
||||
)
|
||||
|
||||
fun asFlow(
|
||||
@@ -172,14 +172,14 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isRead: Boolean? = null,
|
||||
isBookmarked: Boolean? = null,
|
||||
lastPageRead: Int? = null,
|
||||
delete: Boolean? = null
|
||||
delete: Boolean? = null,
|
||||
) = getFlow(
|
||||
mangaId = manga.id,
|
||||
chapterIds = chapterIds,
|
||||
isRead = isRead,
|
||||
isBookmarked = isBookmarked,
|
||||
lastPageRead = lastPageRead,
|
||||
delete = delete
|
||||
delete = delete,
|
||||
)
|
||||
|
||||
@JvmName("asFlowChapters")
|
||||
@@ -188,14 +188,14 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isRead: Boolean? = null,
|
||||
isBookmarked: Boolean? = null,
|
||||
lastPageRead: Int? = null,
|
||||
delete: Boolean? = null
|
||||
delete: Boolean? = null,
|
||||
) = getFlow(
|
||||
mangaId = null,
|
||||
chapterIds = chapters.map { it.id },
|
||||
isRead = isRead,
|
||||
isBookmarked = isBookmarked,
|
||||
lastPageRead = lastPageRead,
|
||||
delete = delete
|
||||
delete = delete,
|
||||
)
|
||||
|
||||
fun asFlow(
|
||||
@@ -203,14 +203,14 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isRead: Boolean? = null,
|
||||
isBookmarked: Boolean? = null,
|
||||
lastPageRead: Int? = null,
|
||||
delete: Boolean? = null
|
||||
delete: Boolean? = null,
|
||||
) = getFlow(
|
||||
mangaId = null,
|
||||
chapterIds = chapterIds,
|
||||
isRead = isRead,
|
||||
isBookmarked = isBookmarked,
|
||||
lastPageRead = lastPageRead,
|
||||
delete = delete
|
||||
delete = delete,
|
||||
)
|
||||
|
||||
private fun getFlow(
|
||||
@@ -219,7 +219,7 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isRead: Boolean? = null,
|
||||
isBookmarked: Boolean? = null,
|
||||
lastPageRead: Int? = null,
|
||||
delete: Boolean? = null
|
||||
delete: Boolean? = null,
|
||||
) = if (mangaId != null) {
|
||||
chapterRepository.batchUpdateChapter(
|
||||
mangaId,
|
||||
@@ -229,9 +229,9 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isRead = isRead,
|
||||
isBookmarked = isBookmarked,
|
||||
lastPageRead = lastPageRead,
|
||||
delete = delete
|
||||
)
|
||||
)
|
||||
delete = delete,
|
||||
),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
chapterRepository.batchUpdateChapter(
|
||||
@@ -241,9 +241,9 @@ class BatchUpdateChapter @Inject constructor(
|
||||
isRead = isRead,
|
||||
isBookmarked = isBookmarked,
|
||||
lastPageRead = lastPageRead,
|
||||
delete = delete
|
||||
)
|
||||
)
|
||||
delete = delete,
|
||||
),
|
||||
),
|
||||
)
|
||||
}.onEach {
|
||||
serverListeners.updateChapters(mangaId, chapterIds)
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class DeleteChapterDownload @Inject constructor(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, index: Int, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId, index)
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class GetChapter @Inject constructor(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, index: Int, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId, index)
|
||||
@@ -50,7 +50,7 @@ class GetChapter @Inject constructor(
|
||||
indexPredate = { id, chapterIndexes ->
|
||||
id == mangaId && (chapterIndexes == null || index in chapterIndexes)
|
||||
},
|
||||
idPredate = { id, _ -> id == mangaId }
|
||||
idPredate = { id, _ -> id == mangaId },
|
||||
)
|
||||
|
||||
fun asFlow(manga: Manga, index: Int) = serverListeners.combineChapters(
|
||||
@@ -58,7 +58,7 @@ class GetChapter @Inject constructor(
|
||||
indexPredate = { id, chapterIndexes ->
|
||||
id == manga.id && (chapterIndexes == null || index in chapterIndexes)
|
||||
},
|
||||
idPredate = { id, _ -> id == manga.id }
|
||||
idPredate = { id, _ -> id == manga.id },
|
||||
)
|
||||
|
||||
fun asFlow(chapter: Chapter) = serverListeners.combineChapters(
|
||||
@@ -66,7 +66,7 @@ class GetChapter @Inject constructor(
|
||||
indexPredate = { id, chapterIndexes ->
|
||||
id == chapter.mangaId && (chapterIndexes == null || chapter.index in chapterIndexes)
|
||||
},
|
||||
idPredate = { id, _ -> id == chapter.mangaId }
|
||||
idPredate = { id, _ -> id == chapter.mangaId },
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -22,7 +22,7 @@ class GetChapterPage @Inject constructor(private val chapterRepository: ChapterR
|
||||
index: Int,
|
||||
pageNum: Int,
|
||||
block: HttpRequestBuilder.() -> Unit,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(mangaId, index, pageNum, block)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -35,7 +35,7 @@ class GetChapterPage @Inject constructor(private val chapterRepository: ChapterR
|
||||
index: Int,
|
||||
pageNum: Int,
|
||||
block: HttpRequestBuilder.() -> Unit,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(manga, index, pageNum, block)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -47,7 +47,7 @@ class GetChapterPage @Inject constructor(private val chapterRepository: ChapterR
|
||||
chapter: Chapter,
|
||||
pageNum: Int,
|
||||
block: HttpRequestBuilder.() -> Unit,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(chapter, pageNum, block)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -59,20 +59,20 @@ class GetChapterPage @Inject constructor(private val chapterRepository: ChapterR
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
pageNum: Int,
|
||||
block: HttpRequestBuilder.() -> Unit
|
||||
block: HttpRequestBuilder.() -> Unit,
|
||||
) = chapterRepository.getPage(mangaId, index, pageNum, block)
|
||||
|
||||
fun asFlow(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
pageNum: Int,
|
||||
block: HttpRequestBuilder.() -> Unit
|
||||
block: HttpRequestBuilder.() -> Unit,
|
||||
) = chapterRepository.getPage(manga.id, index, pageNum, block)
|
||||
|
||||
fun asFlow(
|
||||
chapter: Chapter,
|
||||
pageNum: Int,
|
||||
block: HttpRequestBuilder.() -> Unit
|
||||
block: HttpRequestBuilder.() -> Unit,
|
||||
) = chapterRepository.getPage(chapter.mangaId, chapter.index, pageNum, block)
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class GetChapters @Inject constructor(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId)
|
||||
@@ -39,13 +39,13 @@ class GetChapters @Inject constructor(
|
||||
fun asFlow(mangaId: Long) = serverListeners.combineChapters(
|
||||
chapterRepository.getChapters(mangaId),
|
||||
indexPredate = { id, _ -> id == mangaId },
|
||||
idPredate = { id, _ -> id == mangaId }
|
||||
idPredate = { id, _ -> id == mangaId },
|
||||
)
|
||||
|
||||
fun asFlow(manga: Manga) = serverListeners.combineChapters(
|
||||
chapterRepository.getChapters(manga.id),
|
||||
indexPredate = { id, _ -> id == manga.id },
|
||||
idPredate = { id, _ -> id == manga.id }
|
||||
idPredate = { id, _ -> id == manga.id },
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class RefreshChapters @Inject constructor(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId)
|
||||
|
||||
@@ -18,14 +18,14 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class UpdateChapterBookmarked @Inject constructor(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
bookmarked: Boolean,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(mangaId, index, bookmarked)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -37,7 +37,7 @@ class UpdateChapterBookmarked @Inject constructor(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
bookmarked: Boolean,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(manga, index, bookmarked)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -48,7 +48,7 @@ class UpdateChapterBookmarked @Inject constructor(
|
||||
suspend fun await(
|
||||
chapter: Chapter,
|
||||
bookmarked: Boolean,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(chapter, bookmarked)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -59,30 +59,30 @@ class UpdateChapterBookmarked @Inject constructor(
|
||||
fun asFlow(
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
bookmarked: Boolean
|
||||
bookmarked: Boolean,
|
||||
) = chapterRepository.updateChapter(
|
||||
mangaId = mangaId,
|
||||
chapterIndex = index,
|
||||
bookmarked = bookmarked
|
||||
bookmarked = bookmarked,
|
||||
).onEach { serverListeners.updateChapters(mangaId, index) }
|
||||
|
||||
fun asFlow(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
bookmarked: Boolean
|
||||
bookmarked: Boolean,
|
||||
) = chapterRepository.updateChapter(
|
||||
mangaId = manga.id,
|
||||
chapterIndex = index,
|
||||
bookmarked = bookmarked
|
||||
bookmarked = bookmarked,
|
||||
).onEach { serverListeners.updateChapters(manga.id, index) }
|
||||
|
||||
fun asFlow(
|
||||
chapter: Chapter,
|
||||
bookmarked: Boolean
|
||||
bookmarked: Boolean,
|
||||
) = chapterRepository.updateChapter(
|
||||
mangaId = chapter.mangaId,
|
||||
chapterIndex = chapter.index,
|
||||
bookmarked = bookmarked
|
||||
bookmarked = bookmarked,
|
||||
).onEach { serverListeners.updateChapters(chapter.mangaId, chapter.index) }
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -18,14 +18,14 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class UpdateChapterLastPageRead @Inject constructor(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
lastPageRead: Int,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(mangaId, index, lastPageRead)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -37,7 +37,7 @@ class UpdateChapterLastPageRead @Inject constructor(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
lastPageRead: Int,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(manga, index, lastPageRead)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -48,7 +48,7 @@ class UpdateChapterLastPageRead @Inject constructor(
|
||||
suspend fun await(
|
||||
chapter: Chapter,
|
||||
lastPageRead: Int,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(chapter, lastPageRead)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -59,30 +59,30 @@ class UpdateChapterLastPageRead @Inject constructor(
|
||||
fun asFlow(
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
lastPageRead: Int
|
||||
lastPageRead: Int,
|
||||
) = chapterRepository.updateChapter(
|
||||
mangaId = mangaId,
|
||||
chapterIndex = index,
|
||||
lastPageRead = lastPageRead
|
||||
lastPageRead = lastPageRead,
|
||||
).onEach { serverListeners.updateChapters(mangaId, index) }
|
||||
|
||||
fun asFlow(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
lastPageRead: Int
|
||||
lastPageRead: Int,
|
||||
) = chapterRepository.updateChapter(
|
||||
mangaId = manga.id,
|
||||
chapterIndex = index,
|
||||
lastPageRead = lastPageRead
|
||||
lastPageRead = lastPageRead,
|
||||
).onEach { serverListeners.updateChapters(manga.id, index) }
|
||||
|
||||
fun asFlow(
|
||||
chapter: Chapter,
|
||||
lastPageRead: Int
|
||||
lastPageRead: Int,
|
||||
) = chapterRepository.updateChapter(
|
||||
mangaId = chapter.mangaId,
|
||||
chapterIndex = chapter.index,
|
||||
lastPageRead = lastPageRead
|
||||
lastPageRead = lastPageRead,
|
||||
).onEach { serverListeners.updateChapters(chapter.mangaId, chapter.index) }
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -18,13 +18,13 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class UpdateChapterMarkPreviousRead @Inject constructor(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(mangaId, index)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -35,7 +35,7 @@ class UpdateChapterMarkPreviousRead @Inject constructor(
|
||||
suspend fun await(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(manga, index)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -45,7 +45,7 @@ class UpdateChapterMarkPreviousRead @Inject constructor(
|
||||
|
||||
suspend fun await(
|
||||
chapter: Chapter,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(chapter)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -55,28 +55,28 @@ class UpdateChapterMarkPreviousRead @Inject constructor(
|
||||
|
||||
fun asFlow(
|
||||
mangaId: Long,
|
||||
index: Int
|
||||
index: Int,
|
||||
) = chapterRepository.updateChapter(
|
||||
mangaId = mangaId,
|
||||
chapterIndex = index,
|
||||
markPreviousRead = true
|
||||
markPreviousRead = true,
|
||||
).onEach { serverListeners.updateChapters(mangaId, index) }
|
||||
|
||||
fun asFlow(
|
||||
manga: Manga,
|
||||
index: Int
|
||||
index: Int,
|
||||
) = chapterRepository.updateChapter(
|
||||
mangaId = manga.id,
|
||||
chapterIndex = index,
|
||||
markPreviousRead = true
|
||||
markPreviousRead = true,
|
||||
).onEach { serverListeners.updateChapters(manga.id, index) }
|
||||
|
||||
fun asFlow(
|
||||
chapter: Chapter
|
||||
chapter: Chapter,
|
||||
) = chapterRepository.updateChapter(
|
||||
mangaId = chapter.mangaId,
|
||||
chapterIndex = chapter.index,
|
||||
markPreviousRead = true
|
||||
markPreviousRead = true,
|
||||
).onEach { serverListeners.updateChapters(chapter.mangaId, chapter.index) }
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -17,13 +17,13 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class UpdateChapterMeta @Inject constructor(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(
|
||||
chapter: Chapter,
|
||||
pageOffset: Int = chapter.meta.juiPageOffset,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(chapter, pageOffset)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -33,14 +33,14 @@ class UpdateChapterMeta @Inject constructor(
|
||||
|
||||
fun asFlow(
|
||||
chapter: Chapter,
|
||||
pageOffset: Int = chapter.meta.juiPageOffset
|
||||
pageOffset: Int = chapter.meta.juiPageOffset,
|
||||
) = flow {
|
||||
if (pageOffset != chapter.meta.juiPageOffset) {
|
||||
chapterRepository.updateChapterMeta(
|
||||
chapter.mangaId,
|
||||
chapter.index,
|
||||
"juiPageOffset",
|
||||
pageOffset.toString()
|
||||
pageOffset.toString(),
|
||||
).collect()
|
||||
serverListeners.updateChapters(chapter.mangaId, chapter.index)
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class UpdateChapterRead @Inject constructor(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
read: Boolean,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(mangaId, index, read)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -37,7 +37,7 @@ class UpdateChapterRead @Inject constructor(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
read: Boolean,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(manga, index, read)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -48,7 +48,7 @@ class UpdateChapterRead @Inject constructor(
|
||||
suspend fun await(
|
||||
chapter: Chapter,
|
||||
read: Boolean,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(chapter, read)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -59,30 +59,30 @@ class UpdateChapterRead @Inject constructor(
|
||||
fun asFlow(
|
||||
mangaId: Long,
|
||||
index: Int,
|
||||
read: Boolean
|
||||
read: Boolean,
|
||||
) = chapterRepository.updateChapter(
|
||||
mangaId = mangaId,
|
||||
chapterIndex = index,
|
||||
read = read
|
||||
read = read,
|
||||
).onEach { serverListeners.updateChapters(mangaId, index) }
|
||||
|
||||
fun asFlow(
|
||||
manga: Manga,
|
||||
index: Int,
|
||||
read: Boolean
|
||||
read: Boolean,
|
||||
) = chapterRepository.updateChapter(
|
||||
mangaId = manga.id,
|
||||
chapterIndex = index,
|
||||
read = read
|
||||
read = read,
|
||||
).onEach { serverListeners.updateChapters(manga.id, index) }
|
||||
|
||||
fun asFlow(
|
||||
chapter: Chapter,
|
||||
read: Boolean
|
||||
read: Boolean,
|
||||
) = chapterRepository.updateChapter(
|
||||
mangaId = chapter.mangaId,
|
||||
chapterIndex = chapter.index,
|
||||
read = read
|
||||
read = read,
|
||||
).onEach { serverListeners.updateChapters(chapter.mangaId, chapter.index) }
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -29,11 +29,11 @@ data class Chapter(
|
||||
val pageCount: Int?,
|
||||
val lastReadAt: Int?,
|
||||
val downloaded: Boolean,
|
||||
val meta: ChapterMeta
|
||||
val meta: ChapterMeta,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@Immutable
|
||||
data class ChapterMeta(
|
||||
val juiPageOffset: Int = 0
|
||||
val juiPageOffset: Int = 0,
|
||||
)
|
||||
|
||||
@@ -11,5 +11,5 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class ChapterBatchEditInput(
|
||||
val chapterIds: List<Long>? = null,
|
||||
val change: ChapterChange?
|
||||
val change: ChapterChange?,
|
||||
)
|
||||
|
||||
@@ -13,5 +13,5 @@ data class ChapterChange(
|
||||
val isRead: Boolean? = null,
|
||||
val isBookmarked: Boolean? = null,
|
||||
val lastPageRead: Int? = null,
|
||||
val delete: Boolean? = null
|
||||
val delete: Boolean? = null,
|
||||
)
|
||||
|
||||
@@ -12,5 +12,5 @@ import kotlinx.serialization.Serializable
|
||||
data class MangaChapterBatchEditInput(
|
||||
val chapterIds: List<Long>? = null,
|
||||
val chapterIndexes: List<Int>? = null,
|
||||
val change: ChapterChange?
|
||||
val change: ChapterChange?,
|
||||
)
|
||||
|
||||
@@ -29,13 +29,13 @@ interface ChapterRepository {
|
||||
@GET("api/v1/manga/{mangaId}/chapters")
|
||||
fun getChapters(
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Query("onlineFetch") refresh: Boolean = false
|
||||
@Query("onlineFetch") refresh: Boolean = false,
|
||||
): Flow<List<Chapter>>
|
||||
|
||||
@GET("api/v1/manga/{mangaId}/chapter/{chapterIndex}")
|
||||
fun getChapter(
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Path("chapterIndex") chapterIndex: Int
|
||||
@Path("chapterIndex") chapterIndex: Int,
|
||||
): Flow<Chapter>
|
||||
|
||||
@FormUrlEncoded
|
||||
@@ -46,20 +46,20 @@ interface ChapterRepository {
|
||||
@Field("read") read: Boolean? = null,
|
||||
@Field("bookmarked") bookmarked: Boolean? = null,
|
||||
@Field("lastPageRead") lastPageRead: Int? = null,
|
||||
@Field("markPrevRead") markPreviousRead: Boolean? = null
|
||||
@Field("markPrevRead") markPreviousRead: Boolean? = null,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@POST("api/v1/manga/{mangaId}/chapter/batch")
|
||||
@Headers("Content-Type: application/json")
|
||||
fun batchUpdateChapter(
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Body input: MangaChapterBatchEditInput
|
||||
@Body input: MangaChapterBatchEditInput,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@POST("api/v1/chapter/batch")
|
||||
@Headers("Content-Type: application/json")
|
||||
fun batchUpdateChapter(
|
||||
@Body input: ChapterBatchEditInput
|
||||
@Body input: ChapterBatchEditInput,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@GET("api/v1/manga/{mangaId}/chapter/{chapterIndex}/page/{pageNum}")
|
||||
@@ -67,13 +67,13 @@ interface ChapterRepository {
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Path("chapterIndex") chapterIndex: Int,
|
||||
@Path("pageNum") pageNum: Int,
|
||||
@ReqBuilder block: HttpRequestBuilder.() -> Unit
|
||||
@ReqBuilder block: HttpRequestBuilder.() -> Unit,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@DELETE("api/v1/manga/{mangaId}/chapter/{chapterIndex}")
|
||||
fun deleteChapterDownload(
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Path("chapterIndex") chapterIndex: Int
|
||||
@Path("chapterIndex") chapterIndex: Int,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@FormUrlEncoded
|
||||
@@ -82,6 +82,6 @@ interface ChapterRepository {
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Path("chapterIndex") chapterIndex: Int,
|
||||
@Field("key") key: String,
|
||||
@Field("value") value: String
|
||||
@Field("value") value: String,
|
||||
): Flow<HttpResponse>
|
||||
}
|
||||
|
||||
@@ -20,5 +20,5 @@ data class DownloadChapter(
|
||||
val manga: Manga,
|
||||
val state: DownloadState = DownloadState.Queued,
|
||||
val progress: Float = 0f,
|
||||
val tries: Int = 0
|
||||
val tries: Int = 0,
|
||||
)
|
||||
|
||||
@@ -10,5 +10,5 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class DownloadEnqueue(
|
||||
val chapterIds: List<Long>
|
||||
val chapterIds: List<Long>,
|
||||
)
|
||||
|
||||
@@ -15,5 +15,5 @@ enum class DownloadState(val state: Int) {
|
||||
Queued(0),
|
||||
Downloading(1),
|
||||
Finished(2),
|
||||
Error(3)
|
||||
Error(3),
|
||||
}
|
||||
|
||||
@@ -13,5 +13,5 @@ import kotlinx.serialization.Serializable
|
||||
@Immutable
|
||||
data class DownloadStatus(
|
||||
val status: DownloaderStatus,
|
||||
val queue: List<DownloadChapter>
|
||||
val queue: List<DownloadChapter>,
|
||||
)
|
||||
|
||||
@@ -13,5 +13,5 @@ import kotlinx.serialization.Serializable
|
||||
@Stable
|
||||
enum class DownloaderStatus {
|
||||
Started,
|
||||
Stopped
|
||||
Stopped,
|
||||
}
|
||||
|
||||
@@ -30,25 +30,25 @@ interface DownloadRepository {
|
||||
@GET("api/v1/download/{mangaId}/chapter/{chapterIndex}")
|
||||
fun queueChapterDownload(
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Path("chapterIndex") chapterIndex: Int
|
||||
@Path("chapterIndex") chapterIndex: Int,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@DELETE("api/v1/download/{mangaId}/chapter/{chapterIndex}")
|
||||
fun stopChapterDownload(
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Path("chapterIndex") chapterIndex: Int
|
||||
@Path("chapterIndex") chapterIndex: Int,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@PATCH("api/v1/download/{mangaId}/chapter/{chapterIndex}/reorder/{to}")
|
||||
fun reorderChapterDownload(
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Path("chapterIndex") chapterIndex: Int,
|
||||
@Path("to") to: Int
|
||||
@Path("to") to: Int,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@POST("api/v1/download/batch")
|
||||
@Headers("Content-Type: application/json")
|
||||
fun batchDownload(
|
||||
@Body downloadEnqueue: DownloadEnqueue
|
||||
@Body downloadEnqueue: DownloadEnqueue,
|
||||
): Flow<HttpResponse>
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import me.tatarka.inject.annotations.Inject
|
||||
|
||||
class DownloadService @Inject constructor(
|
||||
serverPreferences: ServerPreferences,
|
||||
client: Http
|
||||
client: Http,
|
||||
) : WebsocketService(serverPreferences, client) {
|
||||
override val _status: MutableStateFlow<Status>
|
||||
get() = status
|
||||
|
||||
@@ -22,5 +22,5 @@ data class Extension(
|
||||
val installed: Boolean,
|
||||
val hasUpdate: Boolean,
|
||||
val obsolete: Boolean,
|
||||
val isNsfw: Boolean
|
||||
val isNsfw: Boolean,
|
||||
)
|
||||
|
||||
@@ -33,28 +33,28 @@ interface ExtensionRepository {
|
||||
@Multipart
|
||||
@POST("api/v1/extension/install")
|
||||
fun installExtension(
|
||||
@Part("") formData: List<PartData>
|
||||
@Part("") formData: List<PartData>,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@GET("api/v1/extension/install/{pkgName}")
|
||||
fun installExtension(
|
||||
@Path("pkgName") pkgName: String
|
||||
@Path("pkgName") pkgName: String,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@GET("api/v1/extension/update/{pkgName}")
|
||||
fun updateExtension(
|
||||
@Path("pkgName") pkgName: String
|
||||
@Path("pkgName") pkgName: String,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@GET("api/v1/extension/uninstall/{pkgName}")
|
||||
fun uninstallExtension(
|
||||
@Path("pkgName") pkgName: String
|
||||
@Path("pkgName") pkgName: String,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@GET("api/v1/extension/icon/{apkName}")
|
||||
fun getApkIcon(
|
||||
@Path("apkName") apkName: String,
|
||||
@ReqBuilder block: HttpRequestBuilder.() -> Unit
|
||||
@ReqBuilder block: HttpRequestBuilder.() -> Unit,
|
||||
): Flow<ByteReadChannel>
|
||||
|
||||
companion object {
|
||||
@@ -65,7 +65,7 @@ interface ExtensionRepository {
|
||||
Headers.build {
|
||||
append(HttpHeaders.ContentType, ContentType.MultiPart.FormData.toString())
|
||||
append(HttpHeaders.ContentDisposition, "filename=file")
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class UpdateGlobalMeta @Inject constructor(private val globalRepository: GlobalR
|
||||
suspend fun await(
|
||||
globalMeta: GlobalMeta,
|
||||
example: Int = globalMeta.example,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(globalMeta, example)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -29,12 +29,12 @@ class UpdateGlobalMeta @Inject constructor(private val globalRepository: GlobalR
|
||||
|
||||
fun asFlow(
|
||||
globalMeta: GlobalMeta,
|
||||
example: Int = globalMeta.example
|
||||
example: Int = globalMeta.example,
|
||||
) = flow {
|
||||
if (example != globalMeta.example) {
|
||||
globalRepository.updateGlobalMeta(
|
||||
"example",
|
||||
example.toString()
|
||||
example.toString(),
|
||||
).collect()
|
||||
}
|
||||
emit(Unit)
|
||||
|
||||
@@ -12,5 +12,5 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
@Immutable
|
||||
data class GlobalMeta(
|
||||
val example: Int = 0
|
||||
val example: Int = 0,
|
||||
)
|
||||
|
||||
@@ -22,6 +22,6 @@ interface GlobalRepository {
|
||||
@PATCH("api/v1/meta")
|
||||
fun updateGlobalMeta(
|
||||
@Field("key") key: String,
|
||||
@Field("value") value: String
|
||||
@Field("value") value: String,
|
||||
): Flow<HttpResponse>
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class AddMangaToLibrary @Inject constructor(
|
||||
private val libraryRepository: LibraryRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId)
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class RemoveMangaFromLibrary @Inject constructor(
|
||||
private val libraryRepository: LibraryRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId)
|
||||
|
||||
@@ -18,7 +18,8 @@ enum class DisplayMode(@Transient val res: StringResource) {
|
||||
CompactGrid(MR.strings.display_compact),
|
||||
ComfortableGrid(MR.strings.display_comfortable),
|
||||
CoverOnlyGrid(MR.strings.display_cover_only),
|
||||
List(MR.strings.display_list);
|
||||
List(MR.strings.display_list),
|
||||
;
|
||||
|
||||
companion object {
|
||||
val values by lazy {
|
||||
|
||||
@@ -14,5 +14,5 @@ import kotlinx.serialization.Serializable
|
||||
enum class FilterState {
|
||||
IGNORED,
|
||||
INCLUDED,
|
||||
EXCLUDED
|
||||
EXCLUDED,
|
||||
}
|
||||
|
||||
@@ -15,5 +15,5 @@ enum class JobStatus {
|
||||
PENDING,
|
||||
RUNNING,
|
||||
COMPLETE,
|
||||
FAILED
|
||||
FAILED,
|
||||
}
|
||||
|
||||
@@ -24,5 +24,5 @@ enum class Sort(@Transient val res: StringResource) {
|
||||
// TOTAL_CHAPTERS,
|
||||
// LATEST_CHAPTER,
|
||||
// DATE_FETCHED,
|
||||
DATE_ADDED(MR.strings.sort_date_added)
|
||||
DATE_ADDED(MR.strings.sort_date_added),
|
||||
}
|
||||
|
||||
@@ -14,5 +14,5 @@ import kotlinx.serialization.Serializable
|
||||
@Immutable
|
||||
data class UpdateStatus(
|
||||
val statusMap: Map<JobStatus, List<Manga>>,
|
||||
val running: Boolean
|
||||
val running: Boolean,
|
||||
)
|
||||
|
||||
@@ -16,11 +16,11 @@ interface LibraryRepository {
|
||||
|
||||
@GET("api/v1/manga/{mangaId}/library")
|
||||
fun addMangaToLibrary(
|
||||
@Path("mangaId") mangaId: Long
|
||||
@Path("mangaId") mangaId: Long,
|
||||
): Flow<HttpResponse>
|
||||
|
||||
@DELETE("api/v1/manga/{mangaId}/library")
|
||||
fun removeMangaFromLibrary(
|
||||
@Path("mangaId") mangaId: Long
|
||||
@Path("mangaId") mangaId: Long,
|
||||
): Flow<HttpResponse>
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class LibraryUpdateService @Inject constructor(
|
||||
serverPreferences: ServerPreferences,
|
||||
client: Http
|
||||
client: Http,
|
||||
) : WebsocketService(serverPreferences, client) {
|
||||
|
||||
override val _status: MutableStateFlow<Status>
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class GetManga @Inject constructor(
|
||||
private val mangaRepository: MangaRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId)
|
||||
@@ -37,11 +37,11 @@ class GetManga @Inject constructor(
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(mangaId: Long) = serverListeners.combineMangaUpdates(
|
||||
mangaRepository.getManga(mangaId)
|
||||
mangaRepository.getManga(mangaId),
|
||||
) { mangaId in it }
|
||||
|
||||
fun asFlow(manga: Manga) = serverListeners.combineMangaUpdates(
|
||||
mangaRepository.getManga(manga.id)
|
||||
mangaRepository.getManga(manga.id),
|
||||
) { manga.id in it }
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class GetMangaFull @Inject constructor(
|
||||
private val mangaRepository: MangaRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId)
|
||||
@@ -37,11 +37,11 @@ class GetMangaFull @Inject constructor(
|
||||
.singleOrNull()
|
||||
|
||||
fun asFlow(mangaId: Long) = serverListeners.combineMangaUpdates(
|
||||
mangaRepository.getMangaFull(mangaId)
|
||||
mangaRepository.getMangaFull(mangaId),
|
||||
) { mangaId in it }
|
||||
|
||||
fun asFlow(manga: Manga) = serverListeners.combineMangaUpdates(
|
||||
mangaRepository.getMangaFull(manga.id)
|
||||
mangaRepository.getMangaFull(manga.id),
|
||||
) { manga.id in it }
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class RefreshManga @Inject constructor(
|
||||
private val mangaRepository: MangaRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId)
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class RefreshMangaFull @Inject constructor(
|
||||
private val mangaRepository: MangaRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, onError: suspend (Throwable) -> Unit = {}) = asFlow(mangaId)
|
||||
|
||||
@@ -19,13 +19,13 @@ import org.lighthousegames.logging.logging
|
||||
|
||||
class UpdateMangaMeta @Inject constructor(
|
||||
private val mangaRepository: MangaRepository,
|
||||
private val serverListeners: ServerListeners
|
||||
private val serverListeners: ServerListeners,
|
||||
) {
|
||||
|
||||
suspend fun await(
|
||||
manga: Manga,
|
||||
readerMode: String = manga.meta.juiReaderMode,
|
||||
onError: suspend (Throwable) -> Unit = {}
|
||||
onError: suspend (Throwable) -> Unit = {},
|
||||
) = asFlow(manga, readerMode)
|
||||
.catch {
|
||||
onError(it)
|
||||
@@ -35,13 +35,13 @@ class UpdateMangaMeta @Inject constructor(
|
||||
|
||||
fun asFlow(
|
||||
manga: Manga,
|
||||
readerMode: String = manga.meta.juiReaderMode.decodeURLQueryComponent()
|
||||
readerMode: String = manga.meta.juiReaderMode.decodeURLQueryComponent(),
|
||||
) = flow {
|
||||
if (readerMode.encodeURLQueryComponent() != manga.meta.juiReaderMode) {
|
||||
mangaRepository.updateMangaMeta(
|
||||
manga.id,
|
||||
"juiReaderMode",
|
||||
readerMode
|
||||
readerMode,
|
||||
).collect()
|
||||
serverListeners.updateManga(manga.id)
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ data class Manga(
|
||||
val chapterCount: Int?,
|
||||
val lastChapterRead: Chapter? = null,
|
||||
val age: Long?,
|
||||
val chaptersAge: Long?
|
||||
val chaptersAge: Long?,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@Immutable
|
||||
data class MangaMeta(
|
||||
val juiReaderMode: String = DEFAULT_READER_MODE
|
||||
val juiReaderMode: String = DEFAULT_READER_MODE,
|
||||
) {
|
||||
companion object {
|
||||
const val DEFAULT_READER_MODE = "default"
|
||||
@@ -66,12 +66,12 @@ enum class MangaStatus(@Transient val res: StringResource) {
|
||||
LICENSED(MR.strings.status_licensed),
|
||||
PUBLISHING_FINISHED(MR.strings.status_publishing_finished),
|
||||
CANCELLED(MR.strings.status_cancelled),
|
||||
ON_HIATUS(MR.strings.status_on_hiatus)
|
||||
ON_HIATUS(MR.strings.status_on_hiatus),
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@Stable
|
||||
enum class UpdateStrategy {
|
||||
ALWAYS_UPDATE,
|
||||
ONLY_FETCH_ONCE
|
||||
ONLY_FETCH_ONCE,
|
||||
}
|
||||
|
||||
@@ -23,19 +23,19 @@ interface MangaRepository {
|
||||
@GET("api/v1/manga/{mangaId}/")
|
||||
fun getManga(
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Query("onlineFetch") refresh: Boolean = false
|
||||
@Query("onlineFetch") refresh: Boolean = false,
|
||||
): Flow<Manga>
|
||||
|
||||
@GET("api/v1/manga/{mangaId}/full")
|
||||
fun getMangaFull(
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Query("onlineFetch") refresh: Boolean = false
|
||||
@Query("onlineFetch") refresh: Boolean = false,
|
||||
): Flow<Manga>
|
||||
|
||||
@GET("api/v1/manga/{mangaId}/thumbnail")
|
||||
fun getMangaThumbnail(
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@ReqBuilder block: HttpRequestBuilder.() -> Unit
|
||||
@ReqBuilder block: HttpRequestBuilder.() -> Unit,
|
||||
): Flow<ByteReadChannel>
|
||||
|
||||
@PATCH("api/v1/manga/{mangaId}/meta")
|
||||
@@ -43,6 +43,6 @@ interface MangaRepository {
|
||||
fun updateMangaMeta(
|
||||
@Path("mangaId") mangaId: Long,
|
||||
@Field("key") key: String,
|
||||
@Field("value") value: String
|
||||
@Field("value") value: String,
|
||||
): Flow<HttpResponse>
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import me.tatarka.inject.annotations.Inject
|
||||
|
||||
class RunMigrations @Inject constructor(
|
||||
private val migrationPreferences: MigrationPreferences,
|
||||
private val readerPreferences: ReaderPreferences
|
||||
private val readerPreferences: ReaderPreferences,
|
||||
) {
|
||||
|
||||
fun runMigrations() {
|
||||
|
||||
@@ -21,8 +21,8 @@ class ReaderModeWatch(
|
||||
private val scope: CoroutineScope,
|
||||
private val mode: StateFlow<String> = readerPreferences.mode().stateIn(scope),
|
||||
initialPreferences: ReaderModePreferences = readerPreferences.getMode(
|
||||
mode.value
|
||||
)
|
||||
mode.value,
|
||||
),
|
||||
) {
|
||||
private val preferenceJobs = mutableListOf<Job>()
|
||||
val direction = MutableStateFlow(initialPreferences.direction().get())
|
||||
|
||||
@@ -15,11 +15,11 @@ enum class DefaultReaderMode(
|
||||
val direction: Direction = Direction.Down,
|
||||
val padding: Int = 0,
|
||||
val imageScale: ImageScale = ImageScale.FitScreen,
|
||||
val navigationMode: NavigationMode = NavigationMode.LNavigation
|
||||
val navigationMode: NavigationMode = NavigationMode.LNavigation,
|
||||
) {
|
||||
RTL("RTL", false, Direction.Left, navigationMode = NavigationMode.RightAndLeftNavigation),
|
||||
LTR("LTR", false, Direction.Right, navigationMode = NavigationMode.RightAndLeftNavigation),
|
||||
Vertical("Vertical", false),
|
||||
ContinuesVertical("Continues Vertical", true, padding = 16),
|
||||
LongStrip("Long Strip", true)
|
||||
LongStrip("Long Strip", true),
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ enum class Direction(@Transient val res: StringResource) {
|
||||
Down(MR.strings.dir_down),
|
||||
Left(MR.strings.dir_rtl),
|
||||
Right(MR.strings.dir_ltr),
|
||||
Up(MR.strings.dir_up);
|
||||
Up(MR.strings.dir_up),
|
||||
;
|
||||
|
||||
val isVertical
|
||||
get() = this == Down || this == Up
|
||||
|
||||
@@ -20,5 +20,5 @@ enum class ImageScale(@Transient val res: StringResource) {
|
||||
FitWidth(MR.strings.scale_fit_width),
|
||||
FitHeight(MR.strings.scale_fit_height),
|
||||
OriginalSize(MR.strings.scale_original),
|
||||
SmartFit(MR.strings.scale_smart)
|
||||
SmartFit(MR.strings.scale_smart),
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@ enum class NavigationMode(@Transient val res: StringResource) {
|
||||
LNavigation(MR.strings.nav_l_shaped),
|
||||
KindlishNavigation(MR.strings.nav_kindle_ish),
|
||||
EdgeNavigation(MR.strings.nav_edge),
|
||||
RightAndLeftNavigation(MR.strings.nav_left_right)
|
||||
RightAndLeftNavigation(MR.strings.nav_left_right),
|
||||
}
|
||||
|
||||
@@ -15,5 +15,5 @@ enum class TappingInvertMode(val shouldInvertHorizontal: Boolean = false, val sh
|
||||
NONE,
|
||||
HORIZONTAL(shouldInvertHorizontal = true),
|
||||
VERTICAL(shouldInvertVertical = true),
|
||||
BOTH(shouldInvertHorizontal = true, shouldInvertVertical = true)
|
||||
BOTH(shouldInvertHorizontal = true, shouldInvertVertical = true),
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class ReaderModePreferences(private val mode: String, private val preferenceStor
|
||||
}
|
||||
} else {
|
||||
0
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class ReaderPreferences(private val preferenceStore: PreferenceStore, private va
|
||||
return preferenceStore.getJsonObject(
|
||||
"modes",
|
||||
DefaultReaderMode.values().map { it.res },
|
||||
ListSerializer(String.serializer())
|
||||
ListSerializer(String.serializer()),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ fun httpClient(serverPreferences: ServerPreferences, json: Json): Http {
|
||||
Proxy.HTTP_PROXY -> ProxyBuilder.http(
|
||||
URLBuilder(
|
||||
host = serverPreferences.proxyHttpHost().get(),
|
||||
port = serverPreferences.proxyHttpPort().get()
|
||||
).build()
|
||||
port = serverPreferences.proxyHttpPort().get(),
|
||||
).build(),
|
||||
)
|
||||
Proxy.SOCKS_PROXY -> ProxyBuilder.socks(
|
||||
serverPreferences.proxySocksHost().get(),
|
||||
serverPreferences.proxySocksPort().get()
|
||||
serverPreferences.proxySocksPort().get(),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ fun httpClient(serverPreferences: ServerPreferences, json: Json): Http {
|
||||
credentials {
|
||||
BasicAuthCredentials(
|
||||
serverPreferences.authUsername().get(),
|
||||
serverPreferences.authPassword().get()
|
||||
serverPreferences.authPassword().get(),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ fun httpClient(serverPreferences: ServerPreferences, json: Json): Http {
|
||||
credentials {
|
||||
DigestAuthCredentials(
|
||||
serverPreferences.authUsername().get(),
|
||||
serverPreferences.authPassword().get()
|
||||
serverPreferences.authPassword().get(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,5 @@ import kotlinx.serialization.Serializable
|
||||
enum class Auth {
|
||||
NONE,
|
||||
BASIC,
|
||||
DIGEST
|
||||
DIGEST,
|
||||
}
|
||||
|
||||
@@ -14,5 +14,5 @@ import kotlinx.serialization.Serializable
|
||||
enum class Proxy {
|
||||
NO_PROXY,
|
||||
HTTP_PROXY,
|
||||
SOCKS_PROXY
|
||||
SOCKS_PROXY,
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class ServerUrlPreference(
|
||||
private val key: String,
|
||||
private val server: Preference<String>,
|
||||
private val port: Preference<Int>,
|
||||
private val pathPrefix: Preference<String>
|
||||
private val pathPrefix: Preference<String>,
|
||||
) : Preference<Url> {
|
||||
override fun key(): String {
|
||||
return key
|
||||
|
||||
@@ -19,12 +19,12 @@ data class About(
|
||||
val buildType: AboutBuildType,
|
||||
val buildTime: Long,
|
||||
val github: String,
|
||||
val discord: String
|
||||
val discord: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@Stable
|
||||
enum class AboutBuildType {
|
||||
Preview,
|
||||
Stable
|
||||
Stable,
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ class GetQuickSearchManga @Inject constructor(private val sourceRepository: Sour
|
||||
page,
|
||||
SourceFilterData(
|
||||
searchTerm?.ifBlank { null },
|
||||
filters?.ifEmpty { null }
|
||||
)
|
||||
filters?.ifEmpty { null },
|
||||
),
|
||||
)
|
||||
|
||||
fun asFlow(sourceId: Long, searchTerm: String?, page: Int, filters: List<SourceFilterChange>?) = sourceRepository.getQuickSearchResults(
|
||||
@@ -45,8 +45,8 @@ class GetQuickSearchManga @Inject constructor(private val sourceRepository: Sour
|
||||
page,
|
||||
SourceFilterData(
|
||||
searchTerm?.ifBlank { null },
|
||||
filters?.ifEmpty { null }
|
||||
)
|
||||
filters?.ifEmpty { null },
|
||||
),
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -32,13 +32,13 @@ class GetSearchManga @Inject constructor(private val sourceRepository: SourceRep
|
||||
fun asFlow(source: Source, searchTerm: String?, page: Int) = sourceRepository.getSearchResults(
|
||||
source.id,
|
||||
searchTerm?.ifBlank { null },
|
||||
page
|
||||
page,
|
||||
)
|
||||
|
||||
fun asFlow(sourceId: Long, searchTerm: String?, page: Int) = sourceRepository.getSearchResults(
|
||||
sourceId,
|
||||
searchTerm?.ifBlank { null },
|
||||
page
|
||||
page,
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -48,22 +48,22 @@ class SetSourceFilter @Inject constructor(private val sourceRepository: SourceRe
|
||||
|
||||
fun asFlow(source: Source, filterIndex: Int, filter: Any) = sourceRepository.setFilter(
|
||||
source.id,
|
||||
SourceFilterChange(filterIndex, filter)
|
||||
SourceFilterChange(filterIndex, filter),
|
||||
)
|
||||
|
||||
fun asFlow(sourceId: Long, filterIndex: Int, filter: Any) = sourceRepository.setFilter(
|
||||
sourceId,
|
||||
SourceFilterChange(filterIndex, filter)
|
||||
SourceFilterChange(filterIndex, filter),
|
||||
)
|
||||
|
||||
fun asFlow(source: Source, filterIndex: Int, childFilterIndex: Int, filter: Any) = sourceRepository.setFilter(
|
||||
source.id,
|
||||
SourceFilterChange(filterIndex, Json.encodeToString(SourceFilterChange(childFilterIndex, filter)))
|
||||
SourceFilterChange(filterIndex, Json.encodeToString(SourceFilterChange(childFilterIndex, filter))),
|
||||
)
|
||||
|
||||
fun asFlow(sourceId: Long, filterIndex: Int, childFilterIndex: Int, filter: Any) = sourceRepository.setFilter(
|
||||
sourceId,
|
||||
SourceFilterChange(filterIndex, Json.encodeToString(SourceFilterChange(childFilterIndex, filter)))
|
||||
SourceFilterChange(filterIndex, Json.encodeToString(SourceFilterChange(childFilterIndex, filter))),
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user