mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
More formatting fixes
This commit is contained in:
@@ -49,7 +49,6 @@ import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.mapLatest
|
||||
import kotlinx.coroutines.flow.receiveAsFlow
|
||||
import kotlinx.coroutines.job
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.lighthousegames.logging.logging
|
||||
import java.util.regex.Pattern
|
||||
|
||||
@@ -67,7 +67,13 @@ subprojects {
|
||||
}
|
||||
tasks.withType<org.jmailen.gradle.kotlinter.tasks.FormatTask> {
|
||||
source(files("src"))
|
||||
exclude("ca/gosyer/jui/*/build", "ca/gosyer/jui/*/build")
|
||||
exclude(
|
||||
"ca/gosyer/jui/*/build",
|
||||
"ca/gosyer/jui/*/build",
|
||||
"**/generated/**",
|
||||
"ca/gosyer/jui/data/graphql",
|
||||
"ca/gosyer/jui/uicore/icons/juiassets",
|
||||
)
|
||||
}
|
||||
plugins.withType<com.android.build.gradle.BasePlugin> {
|
||||
configure<com.android.build.gradle.BaseExtension> {
|
||||
|
||||
@@ -10,8 +10,10 @@ import com.russhwolf.settings.PreferencesSettings
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
import java.util.prefs.Preferences
|
||||
|
||||
@Inject
|
||||
actual class PreferenceStoreFactory() {
|
||||
actual class PreferenceStoreFactory {
|
||||
@Inject
|
||||
constructor()
|
||||
|
||||
private val rootNode: Preferences = Preferences.userRoot()
|
||||
.node("ca/gosyer/tachideskjui")
|
||||
|
||||
|
||||
@@ -10,8 +10,10 @@ import com.russhwolf.settings.NSUserDefaultsSettings
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
import platform.Foundation.NSUserDefaults
|
||||
|
||||
@Inject
|
||||
actual class PreferenceStoreFactory() {
|
||||
actual class PreferenceStoreFactory {
|
||||
@Inject
|
||||
constructor()
|
||||
|
||||
actual fun create(vararg names: String): PreferenceStore =
|
||||
StandardPreferenceStore(
|
||||
NSUserDefaultsSettings(
|
||||
|
||||
@@ -5,8 +5,10 @@ import ca.gosyer.jui.core.lang.toPlatform
|
||||
import kotlinx.datetime.Instant
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
|
||||
@Inject
|
||||
actual class DateHandler() {
|
||||
actual class DateHandler {
|
||||
@Inject
|
||||
constructor()
|
||||
|
||||
actual val formatOptions by lazy {
|
||||
listOf(
|
||||
"",
|
||||
|
||||
@@ -9,8 +9,10 @@ import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.format.FormatStyle
|
||||
|
||||
@Inject
|
||||
actual class DateHandler() {
|
||||
actual class DateHandler {
|
||||
@Inject
|
||||
constructor()
|
||||
|
||||
actual val formatOptions by lazy {
|
||||
listOf(
|
||||
"",
|
||||
|
||||
@@ -34,7 +34,7 @@ abstract class WebsocketService(
|
||||
protected val json = Json {
|
||||
ignoreUnknownKeys = true
|
||||
}
|
||||
protected abstract val _status: MutableStateFlow<Status>
|
||||
protected abstract val status: MutableStateFlow<Status>
|
||||
|
||||
protected val serverUrl = serverPreferences.serverUrl().stateIn(GlobalScope)
|
||||
|
||||
@@ -47,10 +47,10 @@ abstract class WebsocketService(
|
||||
job?.cancel()
|
||||
job = serverUrl
|
||||
.mapLatest { serverUrl ->
|
||||
_status.value = Status.STARTING
|
||||
status.value = Status.STARTING
|
||||
while (true) {
|
||||
if (errorConnectionCount > 3) {
|
||||
_status.value = Status.STOPPED
|
||||
status.value = Status.STOPPED
|
||||
throw CancellationException("Finish")
|
||||
}
|
||||
runCatching {
|
||||
@@ -65,7 +65,7 @@ abstract class WebsocketService(
|
||||
},
|
||||
) {
|
||||
errorConnectionCount = 0
|
||||
_status.value = Status.RUNNING
|
||||
status.value = Status.RUNNING
|
||||
send(Frame.Text("STATUS"))
|
||||
|
||||
incoming.receiveAsFlow()
|
||||
@@ -77,13 +77,13 @@ abstract class WebsocketService(
|
||||
.collect()
|
||||
}
|
||||
}.throwIfCancellation().isFailure.let {
|
||||
_status.value = Status.STARTING
|
||||
status.value = Status.STARTING
|
||||
if (it) errorConnectionCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
.catch {
|
||||
_status.value = Status.STOPPED
|
||||
status.value = Status.STOPPED
|
||||
log.warn(it) { "Error while running websocket service" }
|
||||
}
|
||||
.launchIn(GlobalScope)
|
||||
|
||||
@@ -23,8 +23,8 @@ class DownloadService(
|
||||
serverPreferences: ServerPreferences,
|
||||
client: Http,
|
||||
) : WebsocketService(serverPreferences, client) {
|
||||
override val _status: MutableStateFlow<Status>
|
||||
get() = status
|
||||
override val status: MutableStateFlow<Status>
|
||||
get() = DownloadService.status
|
||||
|
||||
override val query: String
|
||||
get() = "/api/v1/downloads"
|
||||
|
||||
@@ -21,8 +21,8 @@ class LibraryUpdateService(
|
||||
serverPreferences: ServerPreferences,
|
||||
client: Http,
|
||||
) : WebsocketService(serverPreferences, client) {
|
||||
override val _status: MutableStateFlow<Status>
|
||||
get() = status
|
||||
override val status: MutableStateFlow<Status>
|
||||
get() = LibraryUpdateService.status
|
||||
|
||||
override val query: String
|
||||
get() = "/api/v1/update"
|
||||
|
||||
@@ -41,9 +41,9 @@ class SourcePager(
|
||||
) : CoroutineScope by CoroutineScope(Dispatchers.Default + SupervisorJob()) {
|
||||
private val sourceMutex = Mutex()
|
||||
|
||||
private val _sourceManga = MutableStateFlow<List<Manga>>(emptyList())
|
||||
private val sourceManga = MutableStateFlow<List<Manga>>(emptyList())
|
||||
|
||||
private val mangaIds = _sourceManga.map { mangas -> mangas.map { it.id } }
|
||||
private val mangaIds = sourceManga.map { mangas -> mangas.map { it.id } }
|
||||
.stateIn(this, SharingStarted.Eagerly, emptyList())
|
||||
|
||||
private val changedManga =
|
||||
@@ -57,7 +57,7 @@ class SourcePager(
|
||||
}
|
||||
}.stateIn(this, SharingStarted.Eagerly, emptyMap())
|
||||
|
||||
val mangas = combine(_sourceManga, changedManga) { sourceManga, changedManga ->
|
||||
val mangas = combine(sourceManga, changedManga) { sourceManga, changedManga ->
|
||||
sourceManga.map { changedManga[it.id] ?: it }
|
||||
}.stateIn(this, SharingStarted.Eagerly, emptyList())
|
||||
|
||||
@@ -76,7 +76,7 @@ class SourcePager(
|
||||
_pageNum.value++
|
||||
val page = fetcher.get(_pageNum.value)
|
||||
if (page != null) {
|
||||
_sourceManga.value = _sourceManga.value + page.mangaList
|
||||
sourceManga.value += page.mangaList
|
||||
_hasNextPage.value = page.hasNextPage
|
||||
} else {
|
||||
_pageNum.value--
|
||||
|
||||
@@ -8,6 +8,4 @@ package ca.gosyer.jui.ios
|
||||
|
||||
import ca.gosyer.jui.uicore.vm.ContextWrapper
|
||||
|
||||
actual fun create(context: ContextWrapper): AppComponent {
|
||||
return AppComponent.create(context)
|
||||
}
|
||||
actual fun create(context: ContextWrapper): AppComponent = AppComponent.create(context)
|
||||
|
||||
@@ -8,6 +8,4 @@ package ca.gosyer.jui.ios
|
||||
|
||||
import ca.gosyer.jui.uicore.vm.ContextWrapper
|
||||
|
||||
actual fun create(context: ContextWrapper): AppComponent {
|
||||
return AppComponent.create(context)
|
||||
}
|
||||
actual fun create(context: ContextWrapper): AppComponent = AppComponent.create(context)
|
||||
|
||||
@@ -8,6 +8,4 @@ package ca.gosyer.jui.ios
|
||||
|
||||
import ca.gosyer.jui.uicore.vm.ContextWrapper
|
||||
|
||||
actual fun create(context: ContextWrapper): AppComponent {
|
||||
return AppComponent.create(context)
|
||||
}
|
||||
actual fun create(context: ContextWrapper): AppComponent = AppComponent.create(context)
|
||||
|
||||
@@ -185,7 +185,8 @@ class SettingsBackupViewModel(
|
||||
.launchIn(scope)
|
||||
}
|
||||
|
||||
private fun RestoreStatus.toStatus() = when (state) {
|
||||
private fun RestoreStatus.toStatus() =
|
||||
when (state) {
|
||||
RestoreState.IDLE -> Status.Success
|
||||
RestoreState.SUCCESS -> Status.Success
|
||||
RestoreState.FAILURE -> Status.Error
|
||||
@@ -206,7 +207,8 @@ class SettingsBackupViewModel(
|
||||
fun exportBackup() {
|
||||
exportBackupFile
|
||||
.asFlow(
|
||||
true, true, // todo
|
||||
true,
|
||||
true, // todo
|
||||
) {
|
||||
onDownload { bytesSentTotal, contentLength ->
|
||||
_creatingStatus.value = Status.InProgress(
|
||||
|
||||
@@ -26,8 +26,8 @@ import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.mapLatest
|
||||
import kotlinx.coroutines.flow.merge
|
||||
|
||||
private fun SourceFiltersView<*, *>.toSourceFilter(): SourceFilter {
|
||||
return when (this) {
|
||||
private fun SourceFiltersView<*, *>.toSourceFilter(): SourceFilter =
|
||||
when (this) {
|
||||
is SourceFiltersView.CheckBox -> filter.copy(value = state.value)
|
||||
is SourceFiltersView.Group -> filter.copy(value = state.value.map { it.toSourceFilter() })
|
||||
is SourceFiltersView.Header -> filter
|
||||
@@ -37,7 +37,6 @@ private fun SourceFiltersView<*, *>.toSourceFilter(): SourceFilter {
|
||||
is SourceFiltersView.Text -> filter.copy(value = state.value)
|
||||
is SourceFiltersView.TriState -> filter.copy(value = state.value)
|
||||
}
|
||||
}
|
||||
|
||||
class SourceScreen(
|
||||
val source: Source,
|
||||
|
||||
@@ -45,7 +45,7 @@ sealed class SourceSettingsView<T : SourcePreference, R : Any?> {
|
||||
override val title: String?,
|
||||
override val subtitle: String?,
|
||||
override val props: CheckBoxSourcePreference,
|
||||
) : SourceSettingsView<CheckBoxSourcePreference, Boolean>(){
|
||||
) : SourceSettingsView<CheckBoxSourcePreference, Boolean>() {
|
||||
private val _state = MutableStateFlow(
|
||||
props.currentValue ?: props.default,
|
||||
)
|
||||
|
||||
@@ -19,8 +19,7 @@ import me.tatarka.inject.annotations.Inject
|
||||
import org.lighthousegames.logging.logging
|
||||
|
||||
@Inject
|
||||
class TrayViewModel
|
||||
constructor(
|
||||
class TrayViewModel(
|
||||
updateChecker: UpdateChecker,
|
||||
contextWrapper: ContextWrapper,
|
||||
) : ViewModel(contextWrapper) {
|
||||
|
||||
@@ -67,8 +67,7 @@ actual fun getServerHostItems(viewModel: @Composable () -> SettingsServerHostVie
|
||||
}
|
||||
|
||||
@Inject
|
||||
actual class SettingsServerHostViewModel
|
||||
constructor(
|
||||
actual class SettingsServerHostViewModel(
|
||||
serverPreferences: ServerPreferences,
|
||||
serverHostPreferences: ServerHostPreferences,
|
||||
private val serverService: ServerService,
|
||||
|
||||
@@ -12,8 +12,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
|
||||
@Inject
|
||||
actual class DebugOverlayViewModel
|
||||
constructor(
|
||||
actual class DebugOverlayViewModel(
|
||||
contextWrapper: ContextWrapper,
|
||||
) : ViewModel(contextWrapper) {
|
||||
actual val maxMemory: String
|
||||
|
||||
@@ -16,7 +16,6 @@ import me.tatarka.inject.annotations.Inject
|
||||
actual fun getServerHostItems(viewModel: @Composable () -> SettingsServerHostViewModel): LazyListScope.() -> Unit = {}
|
||||
|
||||
@Inject
|
||||
actual class SettingsServerHostViewModel
|
||||
constructor(
|
||||
actual class SettingsServerHostViewModel(
|
||||
contextWrapper: ContextWrapper,
|
||||
) : ViewModel(contextWrapper)
|
||||
|
||||
@@ -10,7 +10,8 @@ import androidx.compose.ui.text.intl.Locale
|
||||
import platform.Foundation.NSString
|
||||
import platform.Foundation.localizedCaseInsensitiveCompare
|
||||
|
||||
actual class CollatorComparator() : Comparator<String> {
|
||||
actual class CollatorComparator : Comparator<String> {
|
||||
constructor()
|
||||
actual constructor(locale: Locale) : this()
|
||||
|
||||
actual override fun compare(
|
||||
|
||||
@@ -17,8 +17,7 @@ import me.tatarka.inject.annotations.Inject
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
@Inject
|
||||
actual class DebugOverlayViewModel
|
||||
constructor(
|
||||
actual class DebugOverlayViewModel(
|
||||
contextWrapper: ContextWrapper,
|
||||
) : ViewModel(contextWrapper) {
|
||||
override val scope = MainScope()
|
||||
|
||||
@@ -15,8 +15,10 @@ import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.asSharedFlow
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
|
||||
@Inject
|
||||
actual class ContextWrapper() {
|
||||
actual class ContextWrapper {
|
||||
@Inject
|
||||
constructor()
|
||||
|
||||
private val _toasts = MutableSharedFlow<Pair<String, Length>>()
|
||||
val toasts = _toasts.asSharedFlow()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user