Last part of GQL conversion

This commit is contained in:
Syer10
2025-10-14 15:43:59 -04:00
parent 5b7228c687
commit 0245ef25fe
56 changed files with 343 additions and 691 deletions

View File

@@ -113,11 +113,6 @@ interface SharedDomainComponent : CoreComponent {
val serverHostPreferencesFactory: ServerHostPreferences
get() = ServerHostPreferences(preferenceFactory.create("host"))
@get:AppScope
@get:Provides
val libraryUpdateServiceFactory: LibraryUpdateService
get() = LibraryUpdateService(serverPreferences, http)
@get:AppScope
@get:Provides
val serverListenersFactory: ServerListeners

View File

@@ -6,9 +6,6 @@
package ca.gosyer.jui.domain.backup.model
import kotlinx.serialization.Serializable
@Serializable
data class BackupValidationResult(
val missingSources: List<String>,
val missingTrackers: List<String>,

View File

@@ -6,8 +6,6 @@
package ca.gosyer.jui.domain.backup.model
import kotlinx.serialization.Serializable
enum class RestoreState {
IDLE,
SUCCESS,
@@ -19,7 +17,6 @@ enum class RestoreState {
UNKNOWN,
}
@Serializable
data class RestoreStatus(
val state: RestoreState,
val completed: Int,

View File

@@ -6,6 +6,7 @@
package ca.gosyer.jui.domain.category.interactor
import ca.gosyer.jui.domain.ServerListeners
import ca.gosyer.jui.domain.category.service.CategoryRepository
import com.diamondedge.logging.logging
import kotlinx.coroutines.flow.catch
@@ -16,6 +17,7 @@ import me.tatarka.inject.annotations.Inject
@Inject
class GetCategories(
private val categoryRepository: CategoryRepository,
private val serverListeners: ServerListeners,
) {
suspend fun await(
dropDefault: Boolean = false,
@@ -27,15 +29,16 @@ class GetCategories(
}
.singleOrNull()
fun asFlow(dropDefault: Boolean = false) =
fun asFlow(dropDefault: Boolean = false) = serverListeners.combineCategoryManga(
categoryRepository.getCategories()
.map { categories ->
if (dropDefault) {
categories.filterNot { it.name.equals("default", true) }
} else {
categories
}
}
).map { categories ->
if (dropDefault) {
categories.filterNot { it.name.equals("default", true) }
} else {
categories
}
}
companion object {
private val log = logging()

View File

@@ -7,9 +7,7 @@
package ca.gosyer.jui.domain.category.model
import androidx.compose.runtime.Immutable
import kotlinx.serialization.Serializable
@Serializable
@Immutable
data class Category(
val id: Long,
@@ -17,10 +15,9 @@ data class Category(
val name: String,
val default: Boolean,
val meta: CategoryMeta,
)
@Serializable
@Immutable
data class CategoryMeta(
val example: Int = 0,
)
) {
@Immutable
data class CategoryMeta(
val example: Int = 0,
)
}

View File

@@ -7,9 +7,7 @@
package ca.gosyer.jui.domain.chapter.model
import androidx.compose.runtime.Immutable
import kotlinx.serialization.Serializable
@Serializable
@Immutable
data class Chapter(
val id: Long,
@@ -29,10 +27,10 @@ data class Chapter(
val lastReadAt: Int?,
val downloaded: Boolean,
val meta: ChapterMeta,
)
) {
@Immutable
data class ChapterMeta(
val juiPageOffset: Int = 0,
)
}
@Serializable
@Immutable
data class ChapterMeta(
val juiPageOffset: Int = 0,
)

View File

@@ -1,15 +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.domain.chapter.model
import kotlinx.serialization.Serializable
@Serializable
data class ChapterBatchEditInput(
val chapterIds: List<Long>? = null,
val change: ChapterChange?,
)

View File

@@ -1,17 +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.domain.chapter.model
import kotlinx.serialization.Serializable
@Serializable
data class ChapterChange(
val isRead: Boolean? = null,
val isBookmarked: Boolean? = null,
val lastPageRead: Int? = null,
val delete: Boolean? = null,
)

View File

@@ -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.domain.chapter.model
import kotlinx.serialization.Serializable
@Serializable
data class MangaChapterBatchEditInput(
val chapterIds: List<Long>? = null,
val chapterIndexes: List<Int>? = null,
val change: ChapterChange?,
)

View File

@@ -1,14 +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.domain.download.model
import kotlinx.serialization.Serializable
@Serializable
data class DownloadEnqueue(
val chapterIds: List<Long>,
)

View File

@@ -7,9 +7,7 @@
package ca.gosyer.jui.domain.extension.model
import androidx.compose.runtime.Immutable
import kotlinx.serialization.Serializable
@Serializable
@Immutable
data class Extension(
val name: String,

View File

@@ -0,0 +1,17 @@
package ca.gosyer.jui.domain.library.model
data class CategoryUpdate(
val category: UpdateCategory,
val status: Status,
) {
enum class Status {
UPDATING,
SKIPPED
}
data class UpdateCategory(
val id: Long,
val name: String,
)
}

View File

@@ -1,17 +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.domain.library.model
import androidx.compose.runtime.Stable
import kotlinx.serialization.Serializable
@Serializable
@Stable
enum class CategoryUpdateStatus {
UPDATING,
SKIPPED,
}

View File

@@ -1,20 +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.domain.library.model
import androidx.compose.runtime.Stable
import kotlinx.serialization.Serializable
@Serializable
@Stable
enum class JobStatus {
PENDING,
RUNNING,
COMPLETE,
FAILED,
SKIPPED,
}

View File

@@ -0,0 +1,19 @@
package ca.gosyer.jui.domain.library.model
data class MangaUpdate(
val manga: UpdateManga,
val status: Status,
) {
enum class Status {
PENDING,
RUNNING,
COMPLETE,
FAILED,
SKIPPED
}
data class UpdateManga(
val id: Long,
val title: String,
)
}

View File

@@ -6,15 +6,8 @@
package ca.gosyer.jui.domain.library.model
import androidx.compose.runtime.Immutable
import ca.gosyer.jui.domain.category.model.Category
import ca.gosyer.jui.domain.manga.model.Manga
import kotlinx.serialization.Serializable
@Serializable
@Immutable
data class UpdateStatus(
val categoryStatusMap: Map<CategoryUpdateStatus, List<Category>> = emptyMap(),
val mangaStatusMap: Map<JobStatus, List<Manga>> = emptyMap(),
val running: Boolean,
val categoryUpdates: List<CategoryUpdate>,
val mangaUpdates: List<MangaUpdate>,
val jobsInfo: UpdaterJobsInfo,
)

View File

@@ -0,0 +1,9 @@
package ca.gosyer.jui.domain.library.model
data class UpdaterJobsInfo(
val finishedJobs: Int,
val isRunning: Boolean,
val skippedCategoriesCount: Int,
val skippedMangasCount: Int,
val totalJobs: Int,
)

View File

@@ -0,0 +1,9 @@
package ca.gosyer.jui.domain.library.model
data class UpdaterUpdates(
val initial: UpdateStatus?,
val categoryUpdates: List<CategoryUpdate>,
val mangaUpdates: List<MangaUpdate>,
val jobsInfo: UpdaterJobsInfo,
val omittedUpdates: Boolean,
)

View File

@@ -6,10 +6,17 @@
package ca.gosyer.jui.domain.library.service
import ca.gosyer.jui.domain.library.model.UpdateStatus
import ca.gosyer.jui.domain.library.model.UpdaterUpdates
import kotlinx.coroutines.flow.Flow
interface LibraryRepository {
fun addMangaToLibrary(mangaId: Long): Flow<Unit>
fun removeMangaFromLibrary(mangaId: Long): Flow<Unit>
fun libraryUpdateSubscription(): Flow<UpdaterUpdates>
fun libraryUpdateStatus(): Flow<UpdateStatus>
}

View File

@@ -8,33 +8,73 @@ package ca.gosyer.jui.domain.library.service
import ca.gosyer.jui.domain.base.WebsocketService
import ca.gosyer.jui.domain.library.model.UpdateStatus
import ca.gosyer.jui.domain.server.Http
import ca.gosyer.jui.domain.server.service.ServerPreferences
import ca.gosyer.jui.domain.library.model.UpdaterJobsInfo
import com.diamondedge.logging.logging
import io.ktor.websocket.Frame
import io.ktor.websocket.readText
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.update
import me.tatarka.inject.annotations.Inject
@Inject
class LibraryUpdateService(
serverPreferences: ServerPreferences,
client: Http,
) : WebsocketService(serverPreferences, client) {
override val status: MutableStateFlow<Status>
get() = LibraryUpdateService.status
private val libraryUpdateRepository: LibraryRepository,
) {
fun getSubscription() = libraryUpdateRepository.libraryUpdateSubscription()
.onStart {
log.info { "Starting library update status subscription" }
status.value = WebsocketService.Status.STARTING
}
.catch { error ->
log.error(error) { "Error in library update status subscription" }
status.value = WebsocketService.Status.STOPPED
}
.map { updates ->
status.value = WebsocketService.Status.RUNNING
if (updates.omittedUpdates) {
log.info { "Omitted updates detected, fetching fresh library update status" }
fetchLibraryUpdateStatus()
return@map
}
if (updates.initial != null) {
updateStatus.value = updates.initial
}
updates.jobsInfo.let { jobsInfo ->
updateStatus.update {
it.copy(
jobsInfo = jobsInfo,
categoryUpdates = updates.categoryUpdates,
mangaUpdates = updates.mangaUpdates
)
}
}
}
override val query: String
get() = "/api/v1/update"
override suspend fun onReceived(frame: Frame.Text) {
updateStatus.value = json.decodeFromString<UpdateStatus>(frame.readText())
private suspend fun fetchLibraryUpdateStatus() {
val status = libraryUpdateRepository.libraryUpdateStatus().firstOrNull()
if (status != null) {
updateStatus.value = status
}
}
companion object {
private val log = logging()
val status = MutableStateFlow(Status.STARTING)
val updateStatus = MutableStateFlow(UpdateStatus(emptyMap(), emptyMap(), false))
val status = MutableStateFlow(WebsocketService.Status.STARTING)
val updateStatus = MutableStateFlow(
UpdateStatus(
emptyList(),
emptyList(),
UpdaterJobsInfo(
0,
false,
0,
0,
0,
)
)
)
}
}

View File

@@ -11,10 +11,8 @@ import androidx.compose.runtime.Stable
import ca.gosyer.jui.domain.source.model.Source
import ca.gosyer.jui.i18n.MR
import dev.icerock.moko.resources.StringResource
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
@Serializable
@Immutable
data class Manga(
val id: Long,
@@ -46,7 +44,6 @@ data class Manga(
val chaptersAge: Long?,
)
@Serializable
@Immutable
data class MangaMeta(
val juiReaderMode: String = DEFAULT_READER_MODE,
@@ -56,7 +53,6 @@ data class MangaMeta(
}
}
@Serializable
@Stable
enum class MangaStatus(
@Transient val res: StringResource,
@@ -70,7 +66,6 @@ enum class MangaStatus(
ON_HIATUS(MR.strings.status_on_hiatus),
}
@Serializable
@Stable
enum class UpdateStrategy {
ALWAYS_UPDATE,

View File

@@ -8,9 +8,7 @@ package ca.gosyer.jui.domain.settings.model
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.Stable
import kotlinx.serialization.Serializable
@Serializable
@Immutable
data class About(
val name: String,
@@ -21,7 +19,6 @@ data class About(
val discord: String,
)
@Serializable
@Stable
enum class AboutBuildType {
Preview,

View File

@@ -8,9 +8,7 @@ package ca.gosyer.jui.domain.source.model
import androidx.compose.runtime.Stable
import ca.gosyer.jui.domain.manga.model.Manga
import kotlinx.serialization.Serializable
@Serializable
@Stable
data class MangaPage(
val mangaList: List<Manga>,

View File

@@ -7,10 +7,8 @@
package ca.gosyer.jui.domain.source.model
import androidx.compose.runtime.Stable
import kotlinx.serialization.Serializable
import ca.gosyer.jui.core.io.Serializable as JvmSerializable
@Serializable
@Stable
data class Source(
val id: Long,

View File

@@ -1,22 +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.domain.source.model.sourcefilters
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@SerialName("CheckBox")
data class CheckBoxFilterOld(
override val filter: CheckBoxProps,
) : SourceFilterOld() {
@Serializable
data class CheckBoxProps(
override val name: String,
override val state: Boolean,
) : Props<Boolean>
}

View File

@@ -1,22 +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.domain.source.model.sourcefilters
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@SerialName("Group")
data class GroupFilterOld(
override val filter: GroupProps,
) : SourceFilterOld() {
@Serializable
data class GroupProps(
override val name: String,
override val state: List<SourceFilterOld>,
) : Props<List<SourceFilterOld>>
}

View File

@@ -1,24 +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.domain.source.model.sourcefilters
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
@Serializable
@SerialName("Header")
data class HeaderFilterOld(
override val filter: HeaderProps,
) : SourceFilterOld() {
@Serializable
data class HeaderProps(
override val name: String,
@Transient
override val state: Int = 0,
) : Props<Int>
}

View File

@@ -1,25 +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.domain.source.model.sourcefilters
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonElement
@Serializable
@SerialName("Select")
data class SelectFilterOld(
override val filter: SelectProps,
) : SourceFilterOld() {
@Serializable
data class SelectProps(
override val name: String,
override val state: Int,
val values: List<JsonElement>,
val displayValues: List<String>? = null,
) : Props<Int>
}

View File

@@ -1,24 +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.domain.source.model.sourcefilters
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
@Serializable
@SerialName("Separator")
data class SeparatorFilterOld(
override val filter: SeparatorProps,
) : SourceFilterOld() {
@Serializable
data class SeparatorProps(
override val name: String,
@Transient
override val state: Int = 0,
) : Props<Int>
}

View File

@@ -1,29 +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.domain.source.model.sourcefilters
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@SerialName("Sort")
data class SortFilterOld(
override val filter: SortProps,
) : SourceFilterOld() {
@Serializable
data class SortProps(
override val name: String,
override val state: Selection?,
val values: List<String>,
) : Props<Selection?>
@Serializable
data class Selection(
val index: Int,
val ascending: Boolean,
)
}

View File

@@ -6,23 +6,6 @@
package ca.gosyer.jui.domain.source.model.sourcefilters
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
@Serializable
data class SourceFilterChangeOld(
val position: Int,
val state: String,
) {
constructor(position: Int, state: Any) : this(
position,
if (state is SortFilterOld.Selection) {
Json.encodeToString(state)
} else {
state.toString()
},
)
}
sealed interface SourceFilter {
val position: Int

View File

@@ -1,15 +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.domain.source.model.sourcefilters
import kotlinx.serialization.Serializable
@Serializable
data class SourceFilterData(
val searchTerm: String?,
val filter: List<SourceFilterChangeOld>?,
)

View File

@@ -1,19 +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.domain.source.model.sourcefilters
import kotlinx.serialization.Serializable
@Serializable
sealed class SourceFilterOld {
abstract val filter: Props<*>
}
interface Props<T> {
val name: String
val state: T
}

View File

@@ -1,22 +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.domain.source.model.sourcefilters
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@SerialName("Text")
data class TextFilterOld(
override val filter: TextProps,
) : SourceFilterOld() {
@Serializable
data class TextProps(
override val name: String,
override val state: String,
) : Props<String>
}

View File

@@ -1,22 +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.domain.source.model.sourcefilters
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@SerialName("TriState")
data class TriStateFilterOld(
override val filter: TriStateProps,
) : SourceFilterOld() {
@Serializable
data class TriStateProps(
override val name: String,
override val state: Int,
) : Props<Int>
}

View File

@@ -1,18 +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.domain.source.model.sourcepreference
import androidx.compose.runtime.Immutable
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@SerialName("CheckBoxPreference")
@Immutable
data class CheckBoxPreferenceOld(
override val props: TwoStateProps,
) : SourcePreferenceOld()

View File

@@ -1,32 +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.domain.source.model.sourcepreference
import androidx.compose.runtime.Immutable
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@SerialName("EditTextPreference")
@Immutable
data class EditTextPreferenceOld(
override val props: EditTextProps,
) : SourcePreferenceOld() {
@Serializable
@Immutable
data class EditTextProps(
override val key: String,
override val title: String?,
override val summary: String?,
override val currentValue: String?,
override val defaultValue: String?,
override val defaultValueType: String,
val dialogTitle: String?,
val dialogMessage: String?,
val text: String?,
) : Props<String?>
}

View File

@@ -1,31 +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.domain.source.model.sourcepreference
import androidx.compose.runtime.Immutable
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@SerialName("ListPreference")
@Immutable
data class ListPreferenceOld(
override val props: ListProps,
) : SourcePreferenceOld() {
@Serializable
@Immutable
data class ListProps(
override val key: String,
override val title: String,
override val summary: String?,
override val currentValue: String?,
override val defaultValue: String?,
override val defaultValueType: String,
val entries: List<String>,
val entryValues: List<String>,
) : Props<String?>
}

View File

@@ -1,33 +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.domain.source.model.sourcepreference
import androidx.compose.runtime.Immutable
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@SerialName("MultiSelectListPreference")
@Immutable
data class MultiSelectListPreferenceOld(
override val props: MultiSelectListProps,
) : SourcePreferenceOld() {
@Serializable
@Immutable
data class MultiSelectListProps(
override val key: String,
override val title: String,
override val summary: String?,
override val currentValue: List<String>?,
override val defaultValue: List<String>?,
override val defaultValueType: String,
val dialogTitle: String?,
val dialogMessage: String?,
val entries: List<String>,
val entryValues: List<String>,
) : Props<List<String>?>
}

View File

@@ -6,25 +6,6 @@
package ca.gosyer.jui.domain.source.model.sourcepreference
import androidx.compose.runtime.Immutable
import kotlinx.serialization.Serializable
@Serializable
@Immutable
sealed class SourcePreferenceOld {
abstract val props: Props<*>
}
@Immutable
interface Props<T> {
val key: String
val title: String?
val summary: String?
val currentValue: T
val defaultValue: T
val defaultValueType: String
}
sealed interface SourcePreference {
val position: Int
}

View File

@@ -1,26 +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.domain.source.model.sourcepreference
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
@Serializable
data class SourcePreferenceChange(
val position: Int,
val value: String,
) {
constructor(position: Int, value: Any) : this(
position,
if (value is List<*>) {
@Suppress("UNCHECKED_CAST")
Json.encodeToString(value as List<String>)
} else {
value.toString()
},
)
}

View File

@@ -1,18 +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.domain.source.model.sourcepreference
import androidx.compose.runtime.Immutable
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@SerialName("SwitchPreferenceCompat")
@Immutable
data class SwitchPreferenceOld(
override val props: TwoStateProps,
) : SourcePreferenceOld()

View File

@@ -1,21 +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.domain.source.model.sourcepreference
import androidx.compose.runtime.Immutable
import kotlinx.serialization.Serializable
@Serializable
@Immutable
data class TwoStateProps(
override val key: String,
override val title: String?,
override val summary: String?,
override val currentValue: Boolean?,
override val defaultValue: Boolean?,
override val defaultValueType: String,
) : Props<Boolean?>

View File

@@ -9,9 +9,7 @@ package ca.gosyer.jui.domain.updates.model
import androidx.compose.runtime.Immutable
import ca.gosyer.jui.domain.chapter.model.Chapter
import ca.gosyer.jui.domain.manga.model.Manga
import kotlinx.serialization.Serializable
@Serializable
@Immutable
data class MangaAndChapter(
val manga: Manga,

View File

@@ -7,9 +7,7 @@
package ca.gosyer.jui.domain.updates.model
import androidx.compose.runtime.Immutable
import kotlinx.serialization.Serializable
@Serializable
@Immutable
data class Updates(
val page: List<MangaAndChapter>,