More formatting fixes

This commit is contained in:
Syer10
2025-10-04 00:23:28 -04:00
parent cf1e9f510a
commit 0516d41de2
25 changed files with 69 additions and 63 deletions

View File

@@ -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

View File

@@ -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> {

View File

@@ -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")

View File

@@ -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(

View File

@@ -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(
"",

View File

@@ -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(
"",

View File

@@ -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)

View File

@@ -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"

View File

@@ -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"

View File

@@ -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--

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -113,7 +113,7 @@ class ReaderMenuViewModel(
cur.orEmpty() +
ReaderPageSeparator(viewerChapters.currChapter, viewerChapters.nextChapter) +
next.orEmpty()
).toImmutableList()
).toImmutableList()
}
}.stateIn(scope, SharingStarted.Eagerly, persistentListOf())

View File

@@ -185,16 +185,17 @@ class SettingsBackupViewModel(
.launchIn(scope)
}
private fun RestoreStatus.toStatus() = when (state) {
RestoreState.IDLE -> Status.Success
RestoreState.SUCCESS -> Status.Success
RestoreState.FAILURE -> Status.Error
RestoreState.RESTORING_CATEGORIES -> Status.InProgress(0.01f)
RestoreState.RESTORING_SETTINGS -> Status.InProgress(0.02f)
RestoreState.RESTORING_MANGA -> Status.InProgress((completed.toFloat() / total).coerceIn(0f, 0.99f))
RestoreState.RESTORING_META -> Status.InProgress(1f)
RestoreState.UNKNOWN -> Status.Error
}
private fun RestoreStatus.toStatus() =
when (state) {
RestoreState.IDLE -> Status.Success
RestoreState.SUCCESS -> Status.Success
RestoreState.FAILURE -> Status.Error
RestoreState.RESTORING_CATEGORIES -> Status.InProgress(0.01f)
RestoreState.RESTORING_SETTINGS -> Status.InProgress(0.02f)
RestoreState.RESTORING_MANGA -> Status.InProgress((completed.toFloat() / total).coerceIn(0f, 0.99f))
RestoreState.RESTORING_META -> Status.InProgress(1f)
RestoreState.UNKNOWN -> Status.Error
}
fun stopRestore() {
_restoreStatus.value = 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(

View File

@@ -887,7 +887,7 @@ private val repoRegex =
(
"https:\\/\\/(?>www\\.|raw\\.)?(github|githubusercontent)\\.com" +
"\\/([^\\/]+)\\/([^\\/]+)(?>(?>\\/tree|\\/blob)?\\/([^\\/\\n]*))?(?>\\/([^\\/\\n]*\\.json)?)?"
).toRegex()
).toRegex()
@Composable
fun ExtensionReposDialog(

View File

@@ -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,

View File

@@ -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,
)

View File

@@ -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) {

View File

@@ -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,

View File

@@ -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

View File

@@ -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)

View File

@@ -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(

View File

@@ -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()

View File

@@ -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()