mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Switch Kotlin-Logging to KmLogging
This commit is contained in:
@@ -68,7 +68,7 @@ dependencies {
|
|||||||
// Logging
|
// Logging
|
||||||
implementation(libs.logging.slf4j.api)
|
implementation(libs.logging.slf4j.api)
|
||||||
implementation(libs.logging.slf4j.android)
|
implementation(libs.logging.slf4j.android)
|
||||||
implementation(libs.logging.ktlogging)
|
implementation(libs.logging.kmlogging)
|
||||||
|
|
||||||
// Storage
|
// Storage
|
||||||
implementation(libs.okio)
|
implementation(libs.okio)
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ import androidx.lifecycle.DefaultLifecycleObserver
|
|||||||
import androidx.lifecycle.ProcessLifecycleOwner
|
import androidx.lifecycle.ProcessLifecycleOwner
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import ca.gosyer.jui.android.data.notification.Notifications
|
import ca.gosyer.jui.android.data.notification.Notifications
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.core.prefs.Preference
|
import ca.gosyer.jui.core.prefs.Preference
|
||||||
import ca.gosyer.jui.core.prefs.getAsFlow
|
import ca.gosyer.jui.core.prefs.getAsFlow
|
||||||
import ca.gosyer.jui.data.ui.model.ThemeMode
|
import ca.gosyer.jui.data.ui.model.ThemeMode
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
class App : Application(), DefaultLifecycleObserver {
|
class App : Application(), DefaultLifecycleObserver {
|
||||||
@@ -55,7 +55,7 @@ class App : Application(), DefaultLifecycleObserver {
|
|||||||
try {
|
try {
|
||||||
Notifications.createChannels(this)
|
Notifications.createChannels(this)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
error(e) { "Failed to modify notification channels" }
|
log.error(e) { "Failed to modify notification channels" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,5 +86,7 @@ class App : Application(), DefaultLifecycleObserver {
|
|||||||
.launchIn(ProcessLifecycleOwner.get().lifecycleScope)
|
.launchIn(ProcessLifecycleOwner.get().lifecycleScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import ca.gosyer.jui.android.util.notificationBuilder
|
|||||||
import ca.gosyer.jui.android.util.notificationManager
|
import ca.gosyer.jui.android.util.notificationManager
|
||||||
import ca.gosyer.jui.core.lang.chop
|
import ca.gosyer.jui.core.lang.chop
|
||||||
import ca.gosyer.jui.core.lang.throwIfCancellation
|
import ca.gosyer.jui.core.lang.throwIfCancellation
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.core.prefs.getAsFlow
|
import ca.gosyer.jui.core.prefs.getAsFlow
|
||||||
import ca.gosyer.jui.data.base.WebsocketService.Actions
|
import ca.gosyer.jui.data.base.WebsocketService.Actions
|
||||||
import ca.gosyer.jui.data.base.WebsocketService.Status
|
import ca.gosyer.jui.data.base.WebsocketService.Status
|
||||||
@@ -49,11 +48,12 @@ import kotlinx.coroutines.flow.receiveAsFlow
|
|||||||
import kotlinx.coroutines.job
|
import kotlinx.coroutines.job
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
class AndroidDownloadService : Service() {
|
class AndroidDownloadService : Service() {
|
||||||
|
|
||||||
companion object : CKLogger({}) {
|
companion object {
|
||||||
private var instance: AndroidDownloadService? = null
|
private var instance: AndroidDownloadService? = null
|
||||||
|
|
||||||
fun start(context: Context, actions: Actions) {
|
fun start(context: Context, actions: Actions) {
|
||||||
@@ -72,6 +72,8 @@ class AndroidDownloadService : Service() {
|
|||||||
fun isRunning(): Boolean {
|
fun isRunning(): Boolean {
|
||||||
return instance != null
|
return instance != null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val log = logging()
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var ioScope: CoroutineScope
|
private lateinit var ioScope: CoroutineScope
|
||||||
@@ -103,17 +105,15 @@ class AndroidDownloadService : Service() {
|
|||||||
|
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
val action = intent.action
|
val action = intent.action
|
||||||
info("using an intent with action $action")
|
log.info { "using an intent with action $action" }
|
||||||
when (action) {
|
when (action) {
|
||||||
Actions.START.name,
|
Actions.START.name,
|
||||||
Actions.RESTART.name -> startWebsocket()
|
Actions.RESTART.name -> startWebsocket()
|
||||||
Actions.STOP.name -> stopSelf()
|
Actions.STOP.name -> stopSelf()
|
||||||
else -> info("This should never happen. No action in the received intent")
|
else -> log.info { "This should never happen. No action in the received intent" }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info(
|
log.info { "with a null intent. It has been probably restarted by the system." }
|
||||||
"with a null intent. It has been probably restarted by the system."
|
|
||||||
)
|
|
||||||
startWebsocket()
|
startWebsocket()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ class AndroidDownloadService : Service() {
|
|||||||
.filterIsInstance<Frame.Text>()
|
.filterIsInstance<Frame.Text>()
|
||||||
.mapLatest(::onReceived)
|
.mapLatest(::onReceived)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error running downloader" }
|
log.warn(it) { "Error running downloader" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ class AndroidDownloadService : Service() {
|
|||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
status.value = Status.STOPPED
|
status.value = Status.STOPPED
|
||||||
error(it) { "Error while running websocket service" }
|
log.warn(it) { "Error while running websocket service" }
|
||||||
stopSelf()
|
stopSelf()
|
||||||
}
|
}
|
||||||
.launchIn(ioScope)
|
.launchIn(ioScope)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ kotlin {
|
|||||||
api(libs.ktor.core)
|
api(libs.ktor.core)
|
||||||
api(libs.ktor.serialization)
|
api(libs.ktor.serialization)
|
||||||
api(libs.okio)
|
api(libs.okio)
|
||||||
api(libs.logging.ktlogging)
|
api(libs.logging.kmlogging)
|
||||||
api(libs.multiplatformSettings.core)
|
api(libs.multiplatformSettings.core)
|
||||||
api(libs.multiplatformSettings.coroutines)
|
api(libs.multiplatformSettings.coroutines)
|
||||||
api(libs.multiplatformSettings.serialization)
|
api(libs.multiplatformSettings.serialization)
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package ca.gosyer.jui.core.logging
|
|
||||||
|
|
||||||
import mu.KLogger
|
|
||||||
import mu.KotlinLogging
|
|
||||||
|
|
||||||
abstract class CKLogger(logger: KLogger) : KLogger by logger {
|
|
||||||
constructor(func: () -> Unit) : this(kLogger(func))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun kLogger(func: () -> Unit) = KotlinLogging.logger(func)
|
|
||||||
@@ -7,18 +7,15 @@
|
|||||||
package ca.gosyer.jui.core.io
|
package ca.gosyer.jui.core.io
|
||||||
|
|
||||||
import ca.gosyer.jui.core.build.BuildKonfig
|
import ca.gosyer.jui.core.build.BuildKonfig
|
||||||
import mu.KotlinLogging
|
|
||||||
import net.harawata.appdirs.AppDirsFactory
|
import net.harawata.appdirs.AppDirsFactory
|
||||||
import okio.FileSystem
|
import okio.FileSystem
|
||||||
import okio.Path
|
import okio.Path
|
||||||
import okio.Path.Companion.toPath
|
import okio.Path.Companion.toPath
|
||||||
|
|
||||||
private val logger = KotlinLogging.logger {}
|
|
||||||
|
|
||||||
val userDataDir: Path by lazy {
|
val userDataDir: Path by lazy {
|
||||||
AppDirsFactory.getInstance().getUserDataDir(BuildKonfig.NAME, null, null).toPath().also {
|
AppDirsFactory.getInstance().getUserDataDir(BuildKonfig.NAME, null, null).toPath().also {
|
||||||
if (!FileSystem.SYSTEM.exists(it)) {
|
if (!FileSystem.SYSTEM.exists(it)) {
|
||||||
logger.info("Attempted to create app data dir, result: {}", FileSystem.SYSTEM.createDirectories(it))
|
FileSystem.SYSTEM.createDirectories(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
package ca.gosyer.jui.data.base
|
package ca.gosyer.jui.data.base
|
||||||
|
|
||||||
import ca.gosyer.jui.core.lang.throwIfCancellation
|
import ca.gosyer.jui.core.lang.throwIfCancellation
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.build.BuildKonfig
|
import ca.gosyer.jui.data.build.BuildKonfig
|
||||||
import ca.gosyer.jui.data.server.Http
|
import ca.gosyer.jui.data.server.Http
|
||||||
import ca.gosyer.jui.data.server.ServerPreferences
|
import ca.gosyer.jui.data.server.ServerPreferences
|
||||||
@@ -25,6 +24,7 @@ import kotlinx.coroutines.flow.launchIn
|
|||||||
import kotlinx.coroutines.flow.mapLatest
|
import kotlinx.coroutines.flow.mapLatest
|
||||||
import kotlinx.coroutines.flow.receiveAsFlow
|
import kotlinx.coroutines.flow.receiveAsFlow
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
@OptIn(DelicateCoroutinesApi::class)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
abstract class WebsocketService(
|
abstract class WebsocketService(
|
||||||
@@ -67,7 +67,7 @@ abstract class WebsocketService(
|
|||||||
.filterIsInstance<Frame.Text>()
|
.filterIsInstance<Frame.Text>()
|
||||||
.mapLatest(::onReceived)
|
.mapLatest(::onReceived)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error running websocket" }
|
log.warn(it) { "Error running websocket" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ abstract class WebsocketService(
|
|||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
_status.value = Status.STOPPED
|
_status.value = Status.STOPPED
|
||||||
error(it) { "Error while running websocket service" }
|
log.warn(it) { "Error while running websocket service" }
|
||||||
}
|
}
|
||||||
.launchIn(GlobalScope)
|
.launchIn(GlobalScope)
|
||||||
}
|
}
|
||||||
@@ -100,5 +100,7 @@ abstract class WebsocketService(
|
|||||||
RESTART
|
RESTART
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
package ca.gosyer.jui.data.download
|
package ca.gosyer.jui.data.download
|
||||||
|
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.base.WebsocketService
|
import ca.gosyer.jui.data.base.WebsocketService
|
||||||
import ca.gosyer.jui.data.download.model.DownloadChapter
|
import ca.gosyer.jui.data.download.model.DownloadChapter
|
||||||
import ca.gosyer.jui.data.download.model.DownloadStatus
|
import ca.gosyer.jui.data.download.model.DownloadStatus
|
||||||
@@ -39,7 +38,7 @@ class DownloadService @Inject constructor(
|
|||||||
downloadQueue.value = status.queue
|
downloadQueue.value = status.queue
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object : CKLogger({}) {
|
companion object {
|
||||||
val status = MutableStateFlow(Status.STARTING)
|
val status = MutableStateFlow(Status.STARTING)
|
||||||
val downloadQueue = MutableStateFlow(emptyList<DownloadChapter>())
|
val downloadQueue = MutableStateFlow(emptyList<DownloadChapter>())
|
||||||
val downloaderStatus = MutableStateFlow(DownloaderStatus.Stopped)
|
val downloaderStatus = MutableStateFlow(DownloaderStatus.Stopped)
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
package ca.gosyer.jui.data.library
|
package ca.gosyer.jui.data.library
|
||||||
|
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.base.WebsocketService
|
import ca.gosyer.jui.data.base.WebsocketService
|
||||||
import ca.gosyer.jui.data.library.model.UpdateStatus
|
import ca.gosyer.jui.data.library.model.UpdateStatus
|
||||||
import ca.gosyer.jui.data.server.Http
|
import ca.gosyer.jui.data.server.Http
|
||||||
@@ -18,6 +17,7 @@ import kotlinx.coroutines.DelicateCoroutinesApi
|
|||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
@OptIn(DelicateCoroutinesApi::class)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
class LibraryUpdateService @Inject constructor(
|
class LibraryUpdateService @Inject constructor(
|
||||||
@@ -32,8 +32,10 @@ class LibraryUpdateService @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun onReceived(frame: Frame.Text) {
|
override suspend fun onReceived(frame: Frame.Text) {
|
||||||
val status = json.decodeFromString<UpdateStatus>(frame.readText())
|
val status = json.decodeFromString<UpdateStatus>(frame.readText())
|
||||||
info { status }
|
log.info { status }
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ package ca.gosyer.jui.data.server
|
|||||||
import ca.gosyer.jui.core.io.copyTo
|
import ca.gosyer.jui.core.io.copyTo
|
||||||
import ca.gosyer.jui.core.io.userDataDir
|
import ca.gosyer.jui.core.io.userDataDir
|
||||||
import ca.gosyer.jui.core.lang.withIOContext
|
import ca.gosyer.jui.core.lang.withIOContext
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.build.BuildKonfig
|
import ca.gosyer.jui.data.build.BuildKonfig
|
||||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
@@ -22,12 +21,12 @@ import kotlinx.coroutines.flow.mapLatest
|
|||||||
import kotlinx.coroutines.flow.merge
|
import kotlinx.coroutines.flow.merge
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
import mu.KotlinLogging
|
|
||||||
import okio.FileSystem
|
import okio.FileSystem
|
||||||
import okio.Path
|
import okio.Path
|
||||||
import okio.Path.Companion.toPath
|
import okio.Path.Companion.toPath
|
||||||
import okio.buffer
|
import okio.buffer
|
||||||
import okio.source
|
import okio.source
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
import java.io.File.pathSeparatorChar
|
import java.io.File.pathSeparatorChar
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.Reader
|
import java.io.Reader
|
||||||
@@ -116,7 +115,7 @@ class ServerService @Inject constructor(
|
|||||||
return@mapLatest
|
return@mapLatest
|
||||||
}
|
}
|
||||||
val handler = CoroutineExceptionHandler { _, throwable ->
|
val handler = CoroutineExceptionHandler { _, throwable ->
|
||||||
error(throwable) { "Error launching Tachidesk.jar" }
|
log.error(throwable) { "Error launching Tachidesk.jar" }
|
||||||
if (_initialized.value == ServerResult.STARTING || _initialized.value == ServerResult.STARTED) {
|
if (_initialized.value == ServerResult.STARTING || _initialized.value == ServerResult.STARTED) {
|
||||||
_initialized.value = ServerResult.FAILED
|
_initialized.value = ServerResult.FAILED
|
||||||
}
|
}
|
||||||
@@ -124,7 +123,7 @@ class ServerService @Inject constructor(
|
|||||||
GlobalScope.launch(handler) {
|
GlobalScope.launch(handler) {
|
||||||
val jarFile = userDataDir / "Tachidesk.jar"
|
val jarFile = userDataDir / "Tachidesk.jar"
|
||||||
if (!FileSystem.SYSTEM.exists(jarFile)) {
|
if (!FileSystem.SYSTEM.exists(jarFile)) {
|
||||||
info { "Copying server to resources" }
|
log.info { "Copying server to resources" }
|
||||||
withIOContext { copyJar(jarFile) }
|
withIOContext { copyJar(jarFile) }
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@@ -135,20 +134,20 @@ class ServerService @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (jarVersion != BuildKonfig.SERVER_CODE) {
|
if (jarVersion != BuildKonfig.SERVER_CODE) {
|
||||||
info { "Updating server file from resources" }
|
log.info { "Updating server file from resources" }
|
||||||
withIOContext { copyJar(jarFile) }
|
withIOContext { copyJar(jarFile) }
|
||||||
}
|
}
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
error(e) {
|
log.error(e) {
|
||||||
"Error accessing server jar, cannot update server, ${BuildKonfig.NAME} may not work properly"
|
"Error accessing server jar, cannot update server, ${BuildKonfig.NAME} may not work properly"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val javaPath = getRuntimeJava() ?: getPossibleJava() ?: "java"
|
val javaPath = getRuntimeJava() ?: getPossibleJava() ?: "java"
|
||||||
info { "Starting server with $javaPath" }
|
log.info { "Starting server with $javaPath" }
|
||||||
val properties = serverHostPreferences.properties()
|
val properties = serverHostPreferences.properties()
|
||||||
info { "Using server properties:\n" + properties.joinToString(separator = "\n") }
|
log.info { "Using server properties:\n" + properties.joinToString(separator = "\n") }
|
||||||
|
|
||||||
withIOContext {
|
withIOContext {
|
||||||
val reader: Reader
|
val reader: Reader
|
||||||
@@ -158,8 +157,8 @@ class ServerService @Inject constructor(
|
|||||||
.also {
|
.also {
|
||||||
reader = it.inputStream.reader()
|
reader = it.inputStream.reader()
|
||||||
}
|
}
|
||||||
info { "Server started successfully" }
|
log.info { "Server started successfully" }
|
||||||
val logger = KotlinLogging.logger("Server")
|
val log = logging("Server")
|
||||||
reader.useLines { lines ->
|
reader.useLines { lines ->
|
||||||
lines.forEach {
|
lines.forEach {
|
||||||
if (_initialized.value == ServerResult.STARTING) {
|
if (_initialized.value == ServerResult.STARTING) {
|
||||||
@@ -169,15 +168,15 @@ class ServerService @Inject constructor(
|
|||||||
_initialized.value = ServerResult.FAILED
|
_initialized.value = ServerResult.FAILED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.info { it }
|
log.info { it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_initialized.value == ServerResult.STARTING) {
|
if (_initialized.value == ServerResult.STARTING) {
|
||||||
_initialized.value = ServerResult.FAILED
|
_initialized.value = ServerResult.FAILED
|
||||||
}
|
}
|
||||||
info { "Server closed" }
|
log.info { "Server closed" }
|
||||||
val exitVal = process?.waitFor()
|
val exitVal = process?.waitFor()
|
||||||
info { "Process exitValue: $exitVal" }
|
log.info { "Process exitValue: $exitVal" }
|
||||||
process = null
|
process = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,5 +190,7 @@ class ServerService @Inject constructor(
|
|||||||
FAILED;
|
FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ dependencies {
|
|||||||
implementation(libs.logging.log4j.api)
|
implementation(libs.logging.log4j.api)
|
||||||
implementation(libs.logging.log4j.core)
|
implementation(libs.logging.log4j.core)
|
||||||
implementation(libs.logging.log4j.slf4j)
|
implementation(libs.logging.log4j.slf4j)
|
||||||
implementation(libs.logging.ktlogging)
|
implementation(libs.logging.kmlogging)
|
||||||
|
|
||||||
// Storage
|
// Storage
|
||||||
implementation(libs.okio)
|
implementation(libs.okio)
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ package ca.gosyer.jui.desktop.logging
|
|||||||
|
|
||||||
import ca.gosyer.jui.desktop.build.BuildConfig
|
import ca.gosyer.jui.desktop.build.BuildConfig
|
||||||
import com.github.weisj.darklaf.LafManager
|
import com.github.weisj.darklaf.LafManager
|
||||||
import mu.KotlinLogging
|
|
||||||
import okio.Path
|
import okio.Path
|
||||||
import org.apache.logging.log4j.Level
|
import org.apache.logging.log4j.Level
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
@@ -16,6 +15,7 @@ import org.apache.logging.log4j.core.LoggerContext
|
|||||||
import org.apache.logging.log4j.core.appender.ConsoleAppender
|
import org.apache.logging.log4j.core.appender.ConsoleAppender
|
||||||
import org.apache.logging.log4j.core.config.builder.api.ComponentBuilder
|
import org.apache.logging.log4j.core.config.builder.api.ComponentBuilder
|
||||||
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory
|
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
import org.slf4j.bridge.SLF4JBridgeHandler
|
import org.slf4j.bridge.SLF4JBridgeHandler
|
||||||
import java.util.logging.LogManager as JLogManager
|
import java.util.logging.LogManager as JLogManager
|
||||||
|
|
||||||
@@ -103,8 +103,8 @@ fun initializeLogger(loggingLocation: Path) {
|
|||||||
handlers.forEach { removeHandler(it) }
|
handlers.forEach { removeHandler(it) }
|
||||||
addHandler(SLF4JBridgeHandler())
|
addHandler(SLF4JBridgeHandler())
|
||||||
}
|
}
|
||||||
val logger = KotlinLogging.logger("UncaughtException")
|
val log = logging("UncaughtException")
|
||||||
Thread.setDefaultUncaughtExceptionHandler { t, e ->
|
Thread.setDefaultUncaughtExceptionHandler { t, e ->
|
||||||
logger.error(e) { "Uncaught exception in thread [${t.name}@${t.id}]" }
|
log.error(e) { "Uncaught exception in thread [${t.name}@${t.id}]" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ ktor = "1.6.7"
|
|||||||
slf4j = "1.7.36"
|
slf4j = "1.7.36"
|
||||||
slf4jAndroid = "1.7.36-0"
|
slf4jAndroid = "1.7.36-0"
|
||||||
log4j = "2.17.2"
|
log4j = "2.17.2"
|
||||||
ktlogging = "2.1.21"
|
kmlogging = "1.1.2"
|
||||||
|
|
||||||
# Storage
|
# Storage
|
||||||
okio = "3.0.0"
|
okio = "3.0.0"
|
||||||
@@ -124,7 +124,7 @@ logging-slf4j-android = { module = "uk.uuid.slf4j:slf4j-android", version.ref =
|
|||||||
logging-log4j-api = { module = "org.apache.logging.log4j:log4j-api", version.ref = "log4j" }
|
logging-log4j-api = { module = "org.apache.logging.log4j:log4j-api", version.ref = "log4j" }
|
||||||
logging-log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" }
|
logging-log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" }
|
||||||
logging-log4j-slf4j = { module = "org.apache.logging.log4j:log4j-slf4j-impl", version.ref = "log4j" }
|
logging-log4j-slf4j = { module = "org.apache.logging.log4j:log4j-slf4j-impl", version.ref = "log4j" }
|
||||||
logging-ktlogging = { module = "io.github.microutils:kotlin-logging", version.ref = "ktlogging" }
|
logging-kmlogging = { module = "org.lighthousegames:logging", version.ref = "kmlogging" }
|
||||||
|
|
||||||
# Storage
|
# Storage
|
||||||
appDirs = { module = "net.harawata:appdirs", version.ref = "appDirs" }
|
appDirs = { module = "net.harawata:appdirs", version.ref = "appDirs" }
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
package ca.gosyer.jui.ui.categories
|
package ca.gosyer.jui.ui.categories
|
||||||
|
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.models.Category
|
import ca.gosyer.jui.data.models.Category
|
||||||
import ca.gosyer.jui.data.server.interactions.CategoryInteractionHandler
|
import ca.gosyer.jui.data.server.interactions.CategoryInteractionHandler
|
||||||
import ca.gosyer.jui.uicore.vm.ContextWrapper
|
import ca.gosyer.jui.uicore.vm.ContextWrapper
|
||||||
@@ -19,6 +18,7 @@ import kotlinx.coroutines.flow.launchIn
|
|||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.flow.singleOrNull
|
import kotlinx.coroutines.flow.singleOrNull
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
class CategoriesScreenViewModel @Inject constructor(
|
class CategoriesScreenViewModel @Inject constructor(
|
||||||
private val categoryHandler: CategoryInteractionHandler,
|
private val categoryHandler: CategoryInteractionHandler,
|
||||||
@@ -47,7 +47,7 @@ class CategoriesScreenViewModel @Inject constructor(
|
|||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting categories" }
|
log.warn(it) { "Error getting categories" }
|
||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
@@ -59,7 +59,7 @@ class CategoriesScreenViewModel @Inject constructor(
|
|||||||
newCategories.forEach {
|
newCategories.forEach {
|
||||||
categoryHandler.createCategory(it.name)
|
categoryHandler.createCategory(it.name)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error creating category" }
|
log.warn(it) { "Error creating category" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -68,35 +68,35 @@ class CategoriesScreenViewModel @Inject constructor(
|
|||||||
if (category == null) {
|
if (category == null) {
|
||||||
categoryHandler.deleteCategory(originalCategory)
|
categoryHandler.deleteCategory(originalCategory)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error deleting category $originalCategory" }
|
log.warn(it) { "Error deleting category $originalCategory" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
} else if (category.name != originalCategory.name) {
|
} else if (category.name != originalCategory.name) {
|
||||||
categoryHandler.modifyCategory(originalCategory, category.name)
|
categoryHandler.modifyCategory(originalCategory, category.name)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error modifying category $category" }
|
log.warn(it) { "Error modifying category $category" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var updatedCategories = categoryHandler.getCategories(true)
|
var updatedCategories = categoryHandler.getCategories(true)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting updated categories" }
|
log.warn(it) { "Error getting updated categories" }
|
||||||
}
|
}
|
||||||
.singleOrNull()
|
.singleOrNull()
|
||||||
categories.forEach { category ->
|
categories.forEach { category ->
|
||||||
val updatedCategory = updatedCategories?.find { it.id == category.id || it.name == category.name } ?: return@forEach
|
val updatedCategory = updatedCategories?.find { it.id == category.id || it.name == category.name } ?: return@forEach
|
||||||
if (category.order != updatedCategory.order) {
|
if (category.order != updatedCategory.order) {
|
||||||
debug { "${category.name}: ${updatedCategory.order} to ${category.order}" }
|
log.debug { "${category.name}: ${updatedCategory.order} to ${category.order}" }
|
||||||
categoryHandler.reorderCategory(category.order, updatedCategory.order)
|
categoryHandler.reorderCategory(category.order, updatedCategory.order)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error re-ordering categories" }
|
log.warn(it) { "Error re-ordering categories" }
|
||||||
}
|
}
|
||||||
.singleOrNull()
|
.singleOrNull()
|
||||||
}
|
}
|
||||||
updatedCategories = categoryHandler.getCategories(true)
|
updatedCategories = categoryHandler.getCategories(true)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting updated categories" }
|
log.warn(it) { "Error getting updated categories" }
|
||||||
}
|
}
|
||||||
.singleOrNull()
|
.singleOrNull()
|
||||||
}
|
}
|
||||||
@@ -144,5 +144,7 @@ class CategoriesScreenViewModel @Inject constructor(
|
|||||||
|
|
||||||
data class MenuCategory(val id: Long? = null, var order: Int, val name: String, val default: Boolean = false)
|
data class MenuCategory(val id: Long? = null, var order: Int, val name: String, val default: Boolean = false)
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ import kotlinx.coroutines.CoroutineExceptionHandler
|
|||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import mu.KotlinLogging
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
|
private val log = logging()
|
||||||
|
|
||||||
@OptIn(DelicateCoroutinesApi::class)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
@@ -68,9 +70,8 @@ fun CategoriesScreenContent(
|
|||||||
) {
|
) {
|
||||||
DisposableEffect(Unit) {
|
DisposableEffect(Unit) {
|
||||||
onDispose {
|
onDispose {
|
||||||
val logger = KotlinLogging.logger {}
|
|
||||||
val handler = CoroutineExceptionHandler { _, throwable ->
|
val handler = CoroutineExceptionHandler { _, throwable ->
|
||||||
logger.debug { throwable }
|
log.warn(throwable) { "Error updating remote categories" }
|
||||||
}
|
}
|
||||||
GlobalScope.launch(handler) {
|
GlobalScope.launch(handler) {
|
||||||
updateRemoteCategories()
|
updateRemoteCategories()
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
package ca.gosyer.jui.ui.downloads
|
package ca.gosyer.jui.ui.downloads
|
||||||
|
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.base.WebsocketService.Actions
|
import ca.gosyer.jui.data.base.WebsocketService.Actions
|
||||||
import ca.gosyer.jui.data.download.DownloadService
|
import ca.gosyer.jui.data.download.DownloadService
|
||||||
import ca.gosyer.jui.data.models.Chapter
|
import ca.gosyer.jui.data.models.Chapter
|
||||||
@@ -23,6 +22,7 @@ import kotlinx.coroutines.flow.collect
|
|||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
class DownloadsScreenViewModel @Inject constructor(
|
class DownloadsScreenViewModel @Inject constructor(
|
||||||
private val downloadService: DownloadService,
|
private val downloadService: DownloadService,
|
||||||
@@ -45,7 +45,7 @@ class DownloadsScreenViewModel @Inject constructor(
|
|||||||
fun start() {
|
fun start() {
|
||||||
downloadsHandler.startDownloading()
|
downloadsHandler.startDownloading()
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error starting download" }
|
log.warn(it) { "Error starting download" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ class DownloadsScreenViewModel @Inject constructor(
|
|||||||
fun pause() {
|
fun pause() {
|
||||||
downloadsHandler.stopDownloading()
|
downloadsHandler.stopDownloading()
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error stopping download" }
|
log.warn(it) { "Error stopping download" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ class DownloadsScreenViewModel @Inject constructor(
|
|||||||
fun clear() {
|
fun clear() {
|
||||||
downloadsHandler.clearDownloadQueue()
|
downloadsHandler.clearDownloadQueue()
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error clearing download" }
|
log.warn(it) { "Error clearing download" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ class DownloadsScreenViewModel @Inject constructor(
|
|||||||
fun stopDownload(chapter: Chapter) {
|
fun stopDownload(chapter: Chapter) {
|
||||||
chapterHandler.stopChapterDownload(chapter)
|
chapterHandler.stopChapterDownload(chapter)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error stop chapter download" }
|
log.warn(it) { "Error stop chapter download" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -79,12 +79,12 @@ class DownloadsScreenViewModel @Inject constructor(
|
|||||||
.onEach {
|
.onEach {
|
||||||
chapterHandler.queueChapterDownload(chapter)
|
chapterHandler.queueChapterDownload(chapter)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error adding download" }
|
log.warn(it) { "Error adding download" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error stop chapter download" }
|
log.warn(it) { "Error stop chapter download" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -96,5 +96,7 @@ class DownloadsScreenViewModel @Inject constructor(
|
|||||||
uiScope?.cancel()
|
uiScope?.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
package ca.gosyer.jui.ui.extensions
|
package ca.gosyer.jui.ui.extensions
|
||||||
|
|
||||||
import ca.gosyer.jui.core.lang.displayName
|
import ca.gosyer.jui.core.lang.displayName
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.extension.ExtensionPreferences
|
import ca.gosyer.jui.data.extension.ExtensionPreferences
|
||||||
import ca.gosyer.jui.data.models.Extension
|
import ca.gosyer.jui.data.models.Extension
|
||||||
import ca.gosyer.jui.data.server.interactions.ExtensionInteractionHandler
|
import ca.gosyer.jui.data.server.interactions.ExtensionInteractionHandler
|
||||||
@@ -26,6 +25,7 @@ import kotlinx.coroutines.flow.map
|
|||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
class ExtensionsScreenViewModel @Inject constructor(
|
class ExtensionsScreenViewModel @Inject constructor(
|
||||||
private val extensionHandler: ExtensionInteractionHandler,
|
private val extensionHandler: ExtensionInteractionHandler,
|
||||||
@@ -66,7 +66,7 @@ class ExtensionsScreenViewModel @Inject constructor(
|
|||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting extensions" }
|
log.warn(it) { "Error getting extensions" }
|
||||||
emit(emptyList())
|
emit(emptyList())
|
||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
@@ -74,39 +74,39 @@ class ExtensionsScreenViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun install(extension: Extension) {
|
fun install(extension: Extension) {
|
||||||
info { "Install clicked" }
|
log.info { "Install clicked" }
|
||||||
extensionHandler.installExtension(extension)
|
extensionHandler.installExtension(extension)
|
||||||
.onEach {
|
.onEach {
|
||||||
getExtensions()
|
getExtensions()
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error installing extension ${extension.apkName}" }
|
log.warn(it) { "Error installing extension ${extension.apkName}" }
|
||||||
getExtensions()
|
getExtensions()
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update(extension: Extension) {
|
fun update(extension: Extension) {
|
||||||
info { "Update clicked" }
|
log.info { "Update clicked" }
|
||||||
extensionHandler.updateExtension(extension)
|
extensionHandler.updateExtension(extension)
|
||||||
.onEach {
|
.onEach {
|
||||||
getExtensions()
|
getExtensions()
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error updating extension ${extension.apkName}" }
|
log.warn(it) { "Error updating extension ${extension.apkName}" }
|
||||||
getExtensions()
|
getExtensions()
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun uninstall(extension: Extension) {
|
fun uninstall(extension: Extension) {
|
||||||
info { "Uninstall clicked" }
|
log.info { "Uninstall clicked" }
|
||||||
extensionHandler.uninstallExtension(extension)
|
extensionHandler.uninstallExtension(extension)
|
||||||
.onEach {
|
.onEach {
|
||||||
getExtensions()
|
getExtensions()
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error uninstalling extension ${extension.apkName}" }
|
log.warn(it) { "Error uninstalling extension ${extension.apkName}" }
|
||||||
getExtensions()
|
getExtensions()
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
@@ -153,5 +153,7 @@ class ExtensionsScreenViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ package ca.gosyer.jui.ui.library
|
|||||||
import ca.gosyer.jui.core.lang.getDefault
|
import ca.gosyer.jui.core.lang.getDefault
|
||||||
import ca.gosyer.jui.core.lang.lowercase
|
import ca.gosyer.jui.core.lang.lowercase
|
||||||
import ca.gosyer.jui.core.lang.withDefaultContext
|
import ca.gosyer.jui.core.lang.withDefaultContext
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.library.LibraryPreferences
|
import ca.gosyer.jui.data.library.LibraryPreferences
|
||||||
import ca.gosyer.jui.data.library.model.Sort
|
import ca.gosyer.jui.data.library.model.Sort
|
||||||
import ca.gosyer.jui.data.models.Category
|
import ca.gosyer.jui.data.models.Category
|
||||||
@@ -40,6 +39,7 @@ import kotlinx.coroutines.flow.single
|
|||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import kotlinx.coroutines.flow.toList
|
import kotlinx.coroutines.flow.toList
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
private typealias CategoryItems = Pair<StateFlow<List<Manga>>, MutableStateFlow<List<Manga>>>
|
private typealias CategoryItems = Pair<StateFlow<List<Manga>>, MutableStateFlow<List<Manga>>>
|
||||||
private typealias LibraryMap = MutableMap<Long, CategoryItems>
|
private typealias LibraryMap = MutableMap<Long, CategoryItems>
|
||||||
@@ -104,7 +104,7 @@ class LibraryScreenViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
_error.value = it.message
|
_error.value = it.message
|
||||||
info(it) { "Error getting categories" }
|
log.warn(it) { "Error getting categories" }
|
||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
@@ -181,7 +181,7 @@ class LibraryScreenViewModel @Inject constructor(
|
|||||||
id = category.id,
|
id = category.id,
|
||||||
manga = categoryHandler.getMangaFromCategory(category)
|
manga = categoryHandler.getMangaFromCategory(category)
|
||||||
.catch {
|
.catch {
|
||||||
info { "Error getting manga for category $category" }
|
log.warn(it) { "Error getting manga for category $category" }
|
||||||
emit(emptyList())
|
emit(emptyList())
|
||||||
}
|
}
|
||||||
.single(),
|
.single(),
|
||||||
@@ -206,7 +206,7 @@ class LibraryScreenViewModel @Inject constructor(
|
|||||||
updateCategories(getCategoriesToUpdate(mangaId))
|
updateCategories(getCategoriesToUpdate(mangaId))
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error removing manga from library" }
|
log.warn(it) { "Error removing manga from library" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -218,7 +218,7 @@ class LibraryScreenViewModel @Inject constructor(
|
|||||||
fun updateLibrary() {
|
fun updateLibrary() {
|
||||||
updatesHandler.updateLibrary()
|
updatesHandler.updateLibrary()
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error updating library" }
|
log.warn(it) { "Error updating library" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -226,10 +226,12 @@ class LibraryScreenViewModel @Inject constructor(
|
|||||||
fun updateCategory(category: Category) {
|
fun updateCategory(category: Category) {
|
||||||
updatesHandler.updateCategory(category)
|
updatesHandler.updateCategory(category)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error updating category" }
|
log.warn(it) { "Error updating category" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
package ca.gosyer.jui.ui.manga
|
package ca.gosyer.jui.ui.manga
|
||||||
|
|
||||||
import ca.gosyer.jui.core.lang.withIOContext
|
import ca.gosyer.jui.core.lang.withIOContext
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.download.DownloadService
|
import ca.gosyer.jui.data.download.DownloadService
|
||||||
import ca.gosyer.jui.data.models.Category
|
import ca.gosyer.jui.data.models.Category
|
||||||
import ca.gosyer.jui.data.models.Chapter
|
import ca.gosyer.jui.data.models.Chapter
|
||||||
@@ -38,6 +37,7 @@ import kotlinx.coroutines.flow.single
|
|||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
class MangaScreenViewModel @Inject constructor(
|
class MangaScreenViewModel @Inject constructor(
|
||||||
private val mangaHandler: MangaInteractionHandler,
|
private val mangaHandler: MangaInteractionHandler,
|
||||||
@@ -93,7 +93,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
_categories.value = it
|
_categories.value = it
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting categories" }
|
log.warn(it) { "Error getting categories" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
_manga.value = it
|
_manga.value = it
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting manga" }
|
log.warn(it) { "Error getting manga" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
categoryHandler.getMangaCategories(mangaId)
|
categoryHandler.getMangaCategories(mangaId)
|
||||||
@@ -144,7 +144,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
_mangaCategories.value = it
|
_mangaCategories.value = it
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting manga" }
|
log.warn(it) { "Error getting manga" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
async {
|
async {
|
||||||
_chapters.value = chapterHandler.getChapters(mangaId, refresh)
|
_chapters.value = chapterHandler.getChapters(mangaId, refresh)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting chapters" }
|
log.warn(it) { "Error getting chapters" }
|
||||||
emit(emptyList())
|
emit(emptyList())
|
||||||
}
|
}
|
||||||
.single()
|
.single()
|
||||||
@@ -168,7 +168,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
if (manga.inLibrary) {
|
if (manga.inLibrary) {
|
||||||
libraryHandler.removeMangaFromLibrary(manga)
|
libraryHandler.removeMangaFromLibrary(manga)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error toggling favorite" }
|
log.warn(it) { "Error toggling favorite" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
refreshMangaAsync(manga.id).await()
|
refreshMangaAsync(manga.id).await()
|
||||||
@@ -190,21 +190,21 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
oldCategories.filterNot { it in categories }.forEach {
|
oldCategories.filterNot { it in categories }.forEach {
|
||||||
categoryHandler.removeMangaFromCategory(manga, it)
|
categoryHandler.removeMangaFromCategory(manga, it)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error removing manga from category" }
|
log.warn(it) { "Error removing manga from category" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
libraryHandler.addMangaToLibrary(manga)
|
libraryHandler.addMangaToLibrary(manga)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error Adding manga to library" }
|
log.warn(it) { "Error Adding manga to library" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
categories.filterNot { it in oldCategories }.forEach {
|
categories.filterNot { it in oldCategories }.forEach {
|
||||||
categoryHandler.addMangaToCategory(manga, it)
|
categoryHandler.addMangaToCategory(manga, it)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error adding manga to category" }
|
log.warn(it) { "Error adding manga to category" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -227,12 +227,12 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
read = !_chapters.value.first { it.chapter.index == index }.chapter.read
|
read = !_chapters.value.first { it.chapter.index == index }.chapter.read
|
||||||
)
|
)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error toggling read" }
|
log.warn(it) { "Error toggling read" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
_chapters.value = chapterHandler.getChapters(manga)
|
_chapters.value = chapterHandler.getChapters(manga)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting new chapters after toggling read" }
|
log.warn(it) { "Error getting new chapters after toggling read" }
|
||||||
emit(emptyList())
|
emit(emptyList())
|
||||||
}
|
}
|
||||||
.single()
|
.single()
|
||||||
@@ -250,12 +250,12 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
bookmarked = !_chapters.value.first { it.chapter.index == index }.chapter.bookmarked
|
bookmarked = !_chapters.value.first { it.chapter.index == index }.chapter.bookmarked
|
||||||
)
|
)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error toggling bookmarked" }
|
log.warn(it) { "Error toggling bookmarked" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
_chapters.value = chapterHandler.getChapters(manga)
|
_chapters.value = chapterHandler.getChapters(manga)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting new chapters after toggling bookmarked" }
|
log.warn(it) { "Error getting new chapters after toggling bookmarked" }
|
||||||
emit(emptyList())
|
emit(emptyList())
|
||||||
}
|
}
|
||||||
.single()
|
.single()
|
||||||
@@ -269,12 +269,12 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
manga.value?.let { manga ->
|
manga.value?.let { manga ->
|
||||||
chapterHandler.updateChapter(manga, index, markPreviousRead = true)
|
chapterHandler.updateChapter(manga, index, markPreviousRead = true)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error marking previous as read" }
|
log.warn(it) { "Error marking previous as read" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
_chapters.value = chapterHandler.getChapters(manga)
|
_chapters.value = chapterHandler.getChapters(manga)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting new chapters after marking previous as read" }
|
log.warn(it) { "Error getting new chapters after marking previous as read" }
|
||||||
emit(emptyList())
|
emit(emptyList())
|
||||||
}
|
}
|
||||||
.single()
|
.single()
|
||||||
@@ -287,7 +287,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
manga.value?.let { manga ->
|
manga.value?.let { manga ->
|
||||||
chapterHandler.queueChapterDownload(manga, index)
|
chapterHandler.queueChapterDownload(manga, index)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error downloading chapter" }
|
log.warn(it) { "Error downloading chapter" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -297,7 +297,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
chapters.value.find { it.chapter.index == index }
|
chapters.value.find { it.chapter.index == index }
|
||||||
?.deleteDownload(chapterHandler)
|
?.deleteDownload(chapterHandler)
|
||||||
?.catch {
|
?.catch {
|
||||||
info(it) { "Error deleting download" }
|
log.warn(it) { "Error deleting download" }
|
||||||
}
|
}
|
||||||
?.launchIn(scope)
|
?.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -306,7 +306,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
chapters.value.find { it.chapter.index == index }
|
chapters.value.find { it.chapter.index == index }
|
||||||
?.stopDownloading(chapterHandler)
|
?.stopDownloading(chapterHandler)
|
||||||
?.catch {
|
?.catch {
|
||||||
info(it) { "Error stopping download" }
|
log.warn(it) { "Error stopping download" }
|
||||||
}
|
}
|
||||||
?.launchIn(scope)
|
?.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -317,5 +317,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
|
|
||||||
data class Params(val mangaId: Long)
|
data class Params(val mangaId: Long)
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
package ca.gosyer.jui.ui.reader
|
package ca.gosyer.jui.ui.reader
|
||||||
|
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.reader.ReaderPreferences
|
import ca.gosyer.jui.data.reader.ReaderPreferences
|
||||||
import ca.gosyer.jui.data.server.interactions.ChapterInteractionHandler
|
import ca.gosyer.jui.data.server.interactions.ChapterInteractionHandler
|
||||||
import ca.gosyer.jui.ui.reader.loader.TachideskPageLoader
|
import ca.gosyer.jui.ui.reader.loader.TachideskPageLoader
|
||||||
@@ -17,6 +16,7 @@ import kotlinx.coroutines.flow.drop
|
|||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.flow.take
|
import kotlinx.coroutines.flow.take
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
class ChapterLoader(
|
class ChapterLoader(
|
||||||
private val readerPreferences: ReaderPreferences,
|
private val readerPreferences: ReaderPreferences,
|
||||||
@@ -27,7 +27,7 @@ class ChapterLoader(
|
|||||||
return (chapter.state as ReaderChapter.State.Loaded).pages
|
return (chapter.state as ReaderChapter.State.Loaded).pages
|
||||||
} else {
|
} else {
|
||||||
chapter.state = ReaderChapter.State.Loading
|
chapter.state = ReaderChapter.State.Loading
|
||||||
debug { "Loading pages for ${chapter.chapter.name}" }
|
log.debug { "Loading pages for ${chapter.chapter.name}" }
|
||||||
|
|
||||||
val loader = TachideskPageLoader(chapter, readerPreferences, chapterHandler)
|
val loader = TachideskPageLoader(chapter, readerPreferences, chapterHandler)
|
||||||
|
|
||||||
@@ -52,5 +52,7 @@ class ChapterLoader(
|
|||||||
return chapter.state is ReaderChapter.State.Loaded && chapter.pageLoader != null
|
return chapter.state is ReaderChapter.State.Loaded && chapter.pageLoader != null
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
package ca.gosyer.jui.ui.reader
|
package ca.gosyer.jui.ui.reader
|
||||||
|
|
||||||
import ca.gosyer.jui.core.lang.launchDefault
|
import ca.gosyer.jui.core.lang.launchDefault
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.core.prefs.getAsFlow
|
import ca.gosyer.jui.core.prefs.getAsFlow
|
||||||
import ca.gosyer.jui.data.models.Chapter
|
import ca.gosyer.jui.data.models.Chapter
|
||||||
import ca.gosyer.jui.data.models.Manga
|
import ca.gosyer.jui.data.models.Manga
|
||||||
@@ -46,6 +45,7 @@ import kotlinx.coroutines.flow.singleOrNull
|
|||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
class ReaderMenuViewModel @Inject constructor(
|
class ReaderMenuViewModel @Inject constructor(
|
||||||
private val readerPreferences: ReaderPreferences,
|
private val readerPreferences: ReaderPreferences,
|
||||||
@@ -138,19 +138,19 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun navigate(page: Int) {
|
fun navigate(page: Int) {
|
||||||
info { "Navigate to $page" }
|
log.info { "Navigate to $page" }
|
||||||
scope.launch {
|
scope.launch {
|
||||||
_pageEmitter.emit(PageMove.Page(page))
|
_pageEmitter.emit(PageMove.Page(page))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun progress(index: Int) {
|
fun progress(index: Int) {
|
||||||
info { "Progressed to $index" }
|
log.info { "Progressed to $index" }
|
||||||
_currentPage.value = index
|
_currentPage.value = index
|
||||||
}
|
}
|
||||||
|
|
||||||
fun retry(page: ReaderPage) {
|
fun retry(page: ReaderPage) {
|
||||||
info { "Retrying $page" }
|
log.info { "Retrying $page" }
|
||||||
chapter.value?.pageLoader?.retryPage(page)
|
chapter.value?.pageLoader?.retryPage(page)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
mode
|
mode
|
||||||
)
|
)
|
||||||
?.catch {
|
?.catch {
|
||||||
info(it) { "Error updating manga reader mode" }
|
log.warn(it) { "Error updating manga reader mode" }
|
||||||
}
|
}
|
||||||
?.collect()
|
?.collect()
|
||||||
initManga(params.mangaId)
|
initManga(params.mangaId)
|
||||||
@@ -187,7 +187,7 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
sendProgress()
|
sendProgress()
|
||||||
initChapters(params.mangaId, prevChapter.chapter.index)
|
initChapters(params.mangaId, prevChapter.chapter.index)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
info(e) { "Error loading prev chapter" }
|
log.warn(e) { "Error loading prev chapter" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
sendProgress()
|
sendProgress()
|
||||||
initChapters(params.mangaId, nextChapter.chapter.index)
|
initChapters(params.mangaId, nextChapter.chapter.index)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
info(e) { "Error loading next chapter" }
|
log.warn(e) { "Error loading next chapter" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,7 +212,7 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
_state.value = ReaderChapter.State.Error(it)
|
_state.value = ReaderChapter.State.Error(it)
|
||||||
info(it) { "Error loading manga" }
|
log.warn(it) { "Error loading manga" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -223,7 +223,7 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
chapterHandler.getChapter(mangaId, chapterIndex)
|
chapterHandler.getChapter(mangaId, chapterIndex)
|
||||||
.catch {
|
.catch {
|
||||||
_state.value = ReaderChapter.State.Error(it)
|
_state.value = ReaderChapter.State.Error(it)
|
||||||
info(it) { "Error getting chapter" }
|
log.warn(it) { "Error getting chapter" }
|
||||||
}
|
}
|
||||||
.singleOrNull() ?: return
|
.singleOrNull() ?: return
|
||||||
)
|
)
|
||||||
@@ -232,7 +232,7 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
scope.launchDefault {
|
scope.launchDefault {
|
||||||
val chapters = chapterHandler.getChapters(mangaId)
|
val chapters = chapterHandler.getChapters(mangaId)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting chapter list" }
|
log.warn(it) { "Error getting chapter list" }
|
||||||
emit(emptyList())
|
emit(emptyList())
|
||||||
}
|
}
|
||||||
.single()
|
.single()
|
||||||
@@ -285,7 +285,7 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
private fun markChapterRead(mangaId: Long, chapter: ReaderChapter) {
|
private fun markChapterRead(mangaId: Long, chapter: ReaderChapter) {
|
||||||
chapterHandler.updateChapter(mangaId, chapter.chapter.index, true)
|
chapterHandler.updateChapter(mangaId, chapter.chapter.index, true)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error marking chapter read" }
|
log.warn(it) { "Error marking chapter read" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -296,7 +296,7 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
if (chapter.read) return
|
if (chapter.read) return
|
||||||
chapterHandler.updateChapter(chapter.mangaId, chapter.index, lastPageRead = lastPageRead)
|
chapterHandler.updateChapter(chapter.mangaId, chapter.index, lastPageRead = lastPageRead)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error sending progress" }
|
log.warn(it) { "Error sending progress" }
|
||||||
}
|
}
|
||||||
.launchIn(GlobalScope)
|
.launchIn(GlobalScope)
|
||||||
}
|
}
|
||||||
@@ -309,7 +309,7 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
private fun updateLastPageReadOffset(chapter: Chapter, offset: Int) {
|
private fun updateLastPageReadOffset(chapter: Chapter, offset: Int) {
|
||||||
chapter.updateRemote(chapterHandler, offset)
|
chapter.updateRemote(chapterHandler, offset)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error updating chapter offset" }
|
log.warn(it) { "Error updating chapter offset" }
|
||||||
}
|
}
|
||||||
.launchIn(GlobalScope)
|
.launchIn(GlobalScope)
|
||||||
}
|
}
|
||||||
@@ -321,5 +321,7 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
|
|
||||||
data class Params(val chapterIndex: Int, val mangaId: Long)
|
data class Params(val chapterIndex: Int, val mangaId: Long)
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import ca.gosyer.jui.core.logging.kLogger
|
|
||||||
import ca.gosyer.jui.core.util.replace
|
import ca.gosyer.jui.core.util.replace
|
||||||
import ca.gosyer.jui.data.models.MangaMeta
|
import ca.gosyer.jui.data.models.MangaMeta
|
||||||
import ca.gosyer.jui.data.reader.model.Direction
|
import ca.gosyer.jui.data.reader.model.Direction
|
||||||
@@ -61,8 +60,6 @@ import ca.gosyer.jui.uicore.components.Spinner
|
|||||||
import ca.gosyer.jui.uicore.resources.stringResource
|
import ca.gosyer.jui.uicore.resources.stringResource
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
private val logger = kLogger {}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ReaderSideMenu(
|
fun ReaderSideMenu(
|
||||||
chapter: ReaderChapter,
|
chapter: ReaderChapter,
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ package ca.gosyer.jui.ui.reader.loader
|
|||||||
|
|
||||||
import ca.gosyer.jui.core.lang.IO
|
import ca.gosyer.jui.core.lang.IO
|
||||||
import ca.gosyer.jui.core.lang.throwIfCancellation
|
import ca.gosyer.jui.core.lang.throwIfCancellation
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.reader.ReaderPreferences
|
import ca.gosyer.jui.data.reader.ReaderPreferences
|
||||||
import ca.gosyer.jui.data.server.interactions.ChapterInteractionHandler
|
import ca.gosyer.jui.data.server.interactions.ChapterInteractionHandler
|
||||||
import ca.gosyer.jui.ui.reader.model.ReaderChapter
|
import ca.gosyer.jui.ui.reader.model.ReaderChapter
|
||||||
@@ -29,6 +28,7 @@ import kotlinx.coroutines.flow.collect
|
|||||||
import kotlinx.coroutines.flow.flowOn
|
import kotlinx.coroutines.flow.flowOn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
class TachideskPageLoader(
|
class TachideskPageLoader(
|
||||||
val chapter: ReaderChapter,
|
val chapter: ReaderChapter,
|
||||||
@@ -61,7 +61,7 @@ class TachideskPageLoader(
|
|||||||
try {
|
try {
|
||||||
for (priorityPage in channel) {
|
for (priorityPage in channel) {
|
||||||
val page = priorityPage.page
|
val page = priorityPage.page
|
||||||
debug { "Loading page ${page.index}" }
|
log.debug { "Loading page ${page.index}" }
|
||||||
if (page.status.value == ReaderPage.Status.QUEUE) {
|
if (page.status.value == ReaderPage.Status.QUEUE) {
|
||||||
chapterHandler
|
chapterHandler
|
||||||
.getPage(chapter.chapter, page.index) {
|
.getPage(chapter.chapter, page.index) {
|
||||||
@@ -78,7 +78,7 @@ class TachideskPageLoader(
|
|||||||
page.bitmap.value = null
|
page.bitmap.value = null
|
||||||
page.status.value = ReaderPage.Status.ERROR
|
page.status.value = ReaderPage.Status.ERROR
|
||||||
page.error.value = it.message
|
page.error.value = it.message
|
||||||
info(it) { "Error getting image" }
|
log.warn(it) { "Error getting image" }
|
||||||
}
|
}
|
||||||
.flowOn(Dispatchers.IO)
|
.flowOn(Dispatchers.IO)
|
||||||
.collect()
|
.collect()
|
||||||
@@ -86,7 +86,7 @@ class TachideskPageLoader(
|
|||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.throwIfCancellation()
|
e.throwIfCancellation()
|
||||||
info(e) { "Error in loop" }
|
log.warn(e) { "Error in loop" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,5 +187,7 @@ class TachideskPageLoader(
|
|||||||
channel.close()
|
channel.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
package ca.gosyer.jui.ui.reader.model
|
package ca.gosyer.jui.ui.reader.model
|
||||||
|
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.models.Chapter
|
import ca.gosyer.jui.data.models.Chapter
|
||||||
import ca.gosyer.jui.ui.reader.loader.PageLoader
|
import ca.gosyer.jui.ui.reader.loader.PageLoader
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
@@ -16,6 +15,7 @@ import kotlinx.coroutines.cancel
|
|||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import kotlinx.coroutines.flow.asStateFlow
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
data class ReaderChapter(val chapter: Chapter) {
|
data class ReaderChapter(val chapter: Chapter) {
|
||||||
val scope = CoroutineScope(Dispatchers.Default + Job())
|
val scope = CoroutineScope(Dispatchers.Default + Job())
|
||||||
@@ -40,7 +40,7 @@ data class ReaderChapter(val chapter: Chapter) {
|
|||||||
|
|
||||||
fun recycle() {
|
fun recycle() {
|
||||||
if (pageLoader != null) {
|
if (pageLoader != null) {
|
||||||
debug { "Recycling chapter ${chapter.name}" }
|
log.debug { "Recycling chapter ${chapter.name}" }
|
||||||
}
|
}
|
||||||
pageLoader?.recycle()
|
pageLoader?.recycle()
|
||||||
pageLoader = null
|
pageLoader = null
|
||||||
@@ -55,5 +55,7 @@ data class ReaderChapter(val chapter: Chapter) {
|
|||||||
class Loaded(val pages: StateFlow<List<ReaderPage>>) : State()
|
class Loaded(val pages: StateFlow<List<ReaderPage>>) : State()
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import ca.gosyer.jui.core.io.SYSTEM
|
|||||||
import ca.gosyer.jui.core.io.copyTo
|
import ca.gosyer.jui.core.io.copyTo
|
||||||
import ca.gosyer.jui.core.io.saveTo
|
import ca.gosyer.jui.core.io.saveTo
|
||||||
import ca.gosyer.jui.core.lang.throwIfCancellation
|
import ca.gosyer.jui.core.lang.throwIfCancellation
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.server.interactions.BackupInteractionHandler
|
import ca.gosyer.jui.data.server.interactions.BackupInteractionHandler
|
||||||
import ca.gosyer.jui.i18n.MR
|
import ca.gosyer.jui.i18n.MR
|
||||||
import ca.gosyer.jui.ui.base.dialog.getMaterialDialogProperties
|
import ca.gosyer.jui.ui.base.dialog.getMaterialDialogProperties
|
||||||
@@ -80,6 +79,7 @@ import okio.Path
|
|||||||
import okio.Sink
|
import okio.Sink
|
||||||
import okio.Source
|
import okio.Source
|
||||||
import okio.buffer
|
import okio.buffer
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
class SettingsBackupScreen : Screen {
|
class SettingsBackupScreen : Screen {
|
||||||
@@ -136,7 +136,7 @@ class SettingsBackupViewModel @Inject constructor(
|
|||||||
source.saveTo(file)
|
source.saveTo(file)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
info(e) { "Error creating backup file" }
|
log.warn(e) { "Error creating backup file" }
|
||||||
_restoreStatus.value = Status.Error
|
_restoreStatus.value = Status.Error
|
||||||
e.throwIfCancellation()
|
e.throwIfCancellation()
|
||||||
null
|
null
|
||||||
@@ -152,7 +152,7 @@ class SettingsBackupViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error importing backup" }
|
log.warn(it) { "Error importing backup" }
|
||||||
_restoreStatus.value = Status.Error
|
_restoreStatus.value = Status.Error
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
@@ -173,7 +173,7 @@ class SettingsBackupViewModel @Inject constructor(
|
|||||||
_restoreStatus.value = Status.Success
|
_restoreStatus.value = Status.Success
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error importing backup" }
|
log.warn(it) { "Error importing backup" }
|
||||||
_restoreStatus.value = Status.Error
|
_restoreStatus.value = Status.Error
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
@@ -211,7 +211,7 @@ class SettingsBackupViewModel @Inject constructor(
|
|||||||
backup.content.toSource().saveTo(it)
|
backup.content.toSource().saveTo(it)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.throwIfCancellation()
|
e.throwIfCancellation()
|
||||||
info(e) { "Error creating backup" }
|
log.warn(e) { "Error creating backup" }
|
||||||
_creatingStatus.value = Status.Error
|
_creatingStatus.value = Status.Error
|
||||||
_creating.value = false
|
_creating.value = false
|
||||||
} finally {
|
} finally {
|
||||||
@@ -223,7 +223,7 @@ class SettingsBackupViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error exporting backup" }
|
log.warn(it) { "Error exporting backup" }
|
||||||
_creatingStatus.value = Status.Error
|
_creatingStatus.value = Status.Error
|
||||||
_creating.value = false
|
_creating.value = false
|
||||||
}
|
}
|
||||||
@@ -240,7 +240,7 @@ class SettingsBackupViewModel @Inject constructor(
|
|||||||
_creatingStatus.value = Status.Success
|
_creatingStatus.value = Status.Success
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.throwIfCancellation()
|
e.throwIfCancellation()
|
||||||
error(e) { "Error moving created backup" }
|
log.error(e) { "Error moving created backup" }
|
||||||
_creatingStatus.value = Status.Error
|
_creatingStatus.value = Status.Error
|
||||||
} finally {
|
} finally {
|
||||||
_creating.value = false
|
_creating.value = false
|
||||||
@@ -259,7 +259,9 @@ class SettingsBackupViewModel @Inject constructor(
|
|||||||
object Error : Status()
|
object Error : Status()
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.library.LibraryPreferences
|
import ca.gosyer.jui.data.library.LibraryPreferences
|
||||||
import ca.gosyer.jui.data.library.model.DisplayMode
|
import ca.gosyer.jui.data.library.model.DisplayMode
|
||||||
import ca.gosyer.jui.data.server.interactions.CategoryInteractionHandler
|
import ca.gosyer.jui.data.server.interactions.CategoryInteractionHandler
|
||||||
@@ -63,6 +62,7 @@ import kotlinx.coroutines.flow.catch
|
|||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class SettingsLibraryScreen : Screen {
|
class SettingsLibraryScreen : Screen {
|
||||||
@@ -109,7 +109,7 @@ class SettingsLibraryViewModel @Inject constructor(
|
|||||||
_categories.value = it.size
|
_categories.value = it.size
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting categories" }
|
log.warn(it) { "Error getting categories" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,9 @@ class SettingsLibraryViewModel @Inject constructor(
|
|||||||
fun getDisplayModeChoices() = DisplayMode.values()
|
fun getDisplayModeChoices() = DisplayMode.values()
|
||||||
.associateWith { stringResource(it.res) }
|
.associateWith { stringResource(it.res) }
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.server.ServerPreferences
|
import ca.gosyer.jui.data.server.ServerPreferences
|
||||||
import ca.gosyer.jui.data.server.model.Auth
|
import ca.gosyer.jui.data.server.model.Auth
|
||||||
import ca.gosyer.jui.data.server.model.Proxy
|
import ca.gosyer.jui.data.server.model.Proxy
|
||||||
@@ -116,8 +115,6 @@ class SettingsServerViewModel @Inject constructor(
|
|||||||
fun serverSettingChanged() {
|
fun serverSettingChanged() {
|
||||||
_serverSettingChanged.value = true
|
_serverSettingChanged.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
package ca.gosyer.jui.ui.sources.browse
|
package ca.gosyer.jui.ui.sources.browse
|
||||||
|
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.catalog.CatalogPreferences
|
import ca.gosyer.jui.data.catalog.CatalogPreferences
|
||||||
import ca.gosyer.jui.data.library.LibraryPreferences
|
import ca.gosyer.jui.data.library.LibraryPreferences
|
||||||
import ca.gosyer.jui.data.library.model.DisplayMode
|
import ca.gosyer.jui.data.library.model.DisplayMode
|
||||||
@@ -23,6 +22,7 @@ import kotlinx.coroutines.flow.singleOrNull
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
class SourceScreenViewModel(
|
class SourceScreenViewModel(
|
||||||
private val source: Source,
|
private val source: Source,
|
||||||
@@ -126,7 +126,7 @@ class SourceScreenViewModel(
|
|||||||
else -> sourceHandler.getPopularManga(source, pageNum.value)
|
else -> sourceHandler.getPopularManga(source, pageNum.value)
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting source page" }
|
log.warn(it) { "Error getting source page" }
|
||||||
}
|
}
|
||||||
.singleOrNull()
|
.singleOrNull()
|
||||||
}
|
}
|
||||||
@@ -160,5 +160,7 @@ class SourceScreenViewModel(
|
|||||||
|
|
||||||
data class Params(val source: Source, val initialQuery: String?)
|
data class Params(val source: Source, val initialQuery: String?)
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
package ca.gosyer.jui.ui.sources.browse.filter
|
package ca.gosyer.jui.ui.sources.browse.filter
|
||||||
|
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.models.sourcefilters.SourceFilter
|
import ca.gosyer.jui.data.models.sourcefilters.SourceFilter
|
||||||
import ca.gosyer.jui.data.server.interactions.SourceInteractionHandler
|
import ca.gosyer.jui.data.server.interactions.SourceInteractionHandler
|
||||||
import ca.gosyer.jui.ui.sources.browse.filter.model.SourceFiltersView
|
import ca.gosyer.jui.ui.sources.browse.filter.model.SourceFiltersView
|
||||||
@@ -23,6 +22,7 @@ import kotlinx.coroutines.flow.mapLatest
|
|||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.supervisorScope
|
import kotlinx.coroutines.supervisorScope
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
class SourceFiltersViewModel(
|
class SourceFiltersViewModel(
|
||||||
private val sourceId: Long,
|
private val sourceId: Long,
|
||||||
@@ -87,7 +87,7 @@ class SourceFiltersViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error with filters" }
|
log.warn(it) { "Error with filters" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ class SourceFiltersViewModel(
|
|||||||
_loading.value = false
|
_loading.value = false
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting filters" }
|
log.warn(it) { "Error getting filters" }
|
||||||
_loading.value = false
|
_loading.value = false
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
@@ -119,5 +119,7 @@ class SourceFiltersViewModel(
|
|||||||
SourceFiltersView(index, sourcePreference)
|
SourceFiltersView(index, sourcePreference)
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ package ca.gosyer.jui.ui.sources.globalsearch
|
|||||||
|
|
||||||
import androidx.compose.runtime.snapshots.SnapshotStateMap
|
import androidx.compose.runtime.snapshots.SnapshotStateMap
|
||||||
import ca.gosyer.jui.core.lang.IO
|
import ca.gosyer.jui.core.lang.IO
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.catalog.CatalogPreferences
|
import ca.gosyer.jui.data.catalog.CatalogPreferences
|
||||||
import ca.gosyer.jui.data.models.MangaPage
|
import ca.gosyer.jui.data.models.MangaPage
|
||||||
import ca.gosyer.jui.data.models.Source
|
import ca.gosyer.jui.data.models.Source
|
||||||
@@ -35,6 +34,7 @@ import kotlinx.coroutines.supervisorScope
|
|||||||
import kotlinx.coroutines.sync.Semaphore
|
import kotlinx.coroutines.sync.Semaphore
|
||||||
import kotlinx.coroutines.sync.withPermit
|
import kotlinx.coroutines.sync.withPermit
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
class GlobalSearchViewModel @Inject constructor(
|
class GlobalSearchViewModel @Inject constructor(
|
||||||
private val sourceHandler: SourceInteractionHandler,
|
private val sourceHandler: SourceInteractionHandler,
|
||||||
@@ -80,7 +80,7 @@ class GlobalSearchViewModel @Inject constructor(
|
|||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting sources" }
|
log.warn(it) { "Error getting sources" }
|
||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
@@ -109,7 +109,7 @@ class GlobalSearchViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting search from ${source.displayName}" }
|
log.warn(it) { "Error getting search from ${source.displayName}" }
|
||||||
emit(Search.Failure(it))
|
emit(Search.Failure(it))
|
||||||
}
|
}
|
||||||
.onEach {
|
.onEach {
|
||||||
@@ -122,7 +122,7 @@ class GlobalSearchViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting sources" }
|
log.warn(it) { "Error getting sources" }
|
||||||
}
|
}
|
||||||
.flowOn(Dispatchers.IO)
|
.flowOn(Dispatchers.IO)
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
@@ -146,5 +146,7 @@ class GlobalSearchViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
package ca.gosyer.jui.ui.sources.home
|
package ca.gosyer.jui.ui.sources.home
|
||||||
|
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.catalog.CatalogPreferences
|
import ca.gosyer.jui.data.catalog.CatalogPreferences
|
||||||
import ca.gosyer.jui.data.models.Source
|
import ca.gosyer.jui.data.models.Source
|
||||||
import ca.gosyer.jui.data.server.interactions.SourceInteractionHandler
|
import ca.gosyer.jui.data.server.interactions.SourceInteractionHandler
|
||||||
@@ -22,6 +21,7 @@ import kotlinx.coroutines.flow.map
|
|||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
class SourceHomeScreenViewModel @Inject constructor(
|
class SourceHomeScreenViewModel @Inject constructor(
|
||||||
private val sourceHandler: SourceInteractionHandler,
|
private val sourceHandler: SourceInteractionHandler,
|
||||||
@@ -65,14 +65,14 @@ class SourceHomeScreenViewModel @Inject constructor(
|
|||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting sources" }
|
log.warn(it) { "Error getting sources" }
|
||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setEnabledLanguages(langs: Set<String>) {
|
fun setEnabledLanguages(langs: Set<String>) {
|
||||||
info { langs }
|
log.info { langs }
|
||||||
_languages.value = langs
|
_languages.value = langs
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,5 +80,7 @@ class SourceHomeScreenViewModel @Inject constructor(
|
|||||||
_query.value = query
|
_query.value = query
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
package ca.gosyer.jui.ui.sources.settings
|
package ca.gosyer.jui.ui.sources.settings
|
||||||
|
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.models.sourcepreference.SourcePreference
|
import ca.gosyer.jui.data.models.sourcepreference.SourcePreference
|
||||||
import ca.gosyer.jui.data.server.interactions.SourceInteractionHandler
|
import ca.gosyer.jui.data.server.interactions.SourceInteractionHandler
|
||||||
import ca.gosyer.jui.ui.sources.settings.model.SourceSettingsView
|
import ca.gosyer.jui.ui.sources.settings.model.SourceSettingsView
|
||||||
@@ -23,6 +22,7 @@ import kotlinx.coroutines.flow.mapLatest
|
|||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.supervisorScope
|
import kotlinx.coroutines.supervisorScope
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
class SourceSettingsScreenViewModel @Inject constructor(
|
class SourceSettingsScreenViewModel @Inject constructor(
|
||||||
private val sourceHandler: SourceInteractionHandler,
|
private val sourceHandler: SourceInteractionHandler,
|
||||||
@@ -45,7 +45,7 @@ class SourceSettingsScreenViewModel @Inject constructor(
|
|||||||
.onEach {
|
.onEach {
|
||||||
sourceHandler.setSourceSetting(params.sourceId, setting.index, it)
|
sourceHandler.setSourceSetting(params.sourceId, setting.index, it)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error setting source setting" }
|
log.warn(it) { "Error setting source setting" }
|
||||||
}
|
}
|
||||||
.collect()
|
.collect()
|
||||||
getSourceSettings()
|
getSourceSettings()
|
||||||
@@ -63,7 +63,7 @@ class SourceSettingsScreenViewModel @Inject constructor(
|
|||||||
_loading.value = false
|
_loading.value = false
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error setting source setting" }
|
log.warn(it) { "Error setting source setting" }
|
||||||
_loading.value = false
|
_loading.value = false
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
@@ -75,5 +75,7 @@ class SourceSettingsScreenViewModel @Inject constructor(
|
|||||||
SourceSettingsView(index, sourcePreference)
|
SourceSettingsView(index, sourcePreference)
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
package ca.gosyer.jui.ui.updates
|
package ca.gosyer.jui.ui.updates
|
||||||
|
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.download.DownloadService
|
import ca.gosyer.jui.data.download.DownloadService
|
||||||
import ca.gosyer.jui.data.models.Chapter
|
import ca.gosyer.jui.data.models.Chapter
|
||||||
import ca.gosyer.jui.data.server.interactions.ChapterInteractionHandler
|
import ca.gosyer.jui.data.server.interactions.ChapterInteractionHandler
|
||||||
@@ -24,6 +23,7 @@ import kotlinx.coroutines.flow.onEach
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import me.tatarka.inject.annotations.Inject
|
import me.tatarka.inject.annotations.Inject
|
||||||
|
import org.lighthousegames.logging.logging
|
||||||
|
|
||||||
class UpdatesScreenViewModel @Inject constructor(
|
class UpdatesScreenViewModel @Inject constructor(
|
||||||
private val chapterHandler: ChapterInteractionHandler,
|
private val chapterHandler: ChapterInteractionHandler,
|
||||||
@@ -81,7 +81,7 @@ class UpdatesScreenViewModel @Inject constructor(
|
|||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error getting updates" }
|
log.warn(it) { "Error getting updates" }
|
||||||
if (currentPage.value > 1) {
|
if (currentPage.value > 1) {
|
||||||
currentPage.value--
|
currentPage.value--
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ class UpdatesScreenViewModel @Inject constructor(
|
|||||||
fun downloadChapter(chapter: Chapter) {
|
fun downloadChapter(chapter: Chapter) {
|
||||||
chapterHandler.queueChapterDownload(chapter)
|
chapterHandler.queueChapterDownload(chapter)
|
||||||
.catch {
|
.catch {
|
||||||
info(it) { "Error queueing chapter" }
|
log.warn(it) { "Error queueing chapter" }
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ class UpdatesScreenViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
?.deleteDownload(chapterHandler)
|
?.deleteDownload(chapterHandler)
|
||||||
?.catch {
|
?.catch {
|
||||||
info(it) { "Error deleting download" }
|
log.warn(it) { "Error deleting download" }
|
||||||
}
|
}
|
||||||
?.launchIn(scope)
|
?.launchIn(scope)
|
||||||
}
|
}
|
||||||
@@ -119,10 +119,12 @@ class UpdatesScreenViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
?.stopDownloading(chapterHandler)
|
?.stopDownloading(chapterHandler)
|
||||||
?.catch {
|
?.catch {
|
||||||
info(it) { "Error stopping download" }
|
log.warn(it) { "Error stopping download" }
|
||||||
}
|
}
|
||||||
?.launchIn(scope)
|
?.launchIn(scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object : CKLogger({})
|
private companion object {
|
||||||
|
private val log = logging()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import androidx.compose.runtime.DisposableEffect
|
|||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||||
import ca.gosyer.jui.core.logging.CKLogger
|
|
||||||
import ca.gosyer.jui.data.server.ServerHostPreferences
|
import ca.gosyer.jui.data.server.ServerHostPreferences
|
||||||
import ca.gosyer.jui.data.server.ServerPreferences
|
import ca.gosyer.jui.data.server.ServerPreferences
|
||||||
import ca.gosyer.jui.data.server.ServerService
|
import ca.gosyer.jui.data.server.ServerService
|
||||||
@@ -128,7 +127,6 @@ actual class SettingsServerHostViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}.launchIn(scope)
|
}.launchIn(scope)
|
||||||
}
|
}
|
||||||
private companion object : CKLogger({})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun LazyListScope.ServerHostItems(
|
fun LazyListScope.ServerHostItems(
|
||||||
|
|||||||
Reference in New Issue
Block a user