Skip to content

Commit

Permalink
Make torrents in MainDataSerializer nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartuzen committed Jan 6, 2024
1 parent 4ec1925 commit 8b1afdb
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private object MainDataSerializer : KSerializer<MainData> {

override fun deserialize(decoder: Decoder) = decoder.decodeStructure(descriptor) {
lateinit var serverState: ServerState
lateinit var torrents: Map<String, Torrent>
var torrents: Map<String, Torrent>? = null
var categories: Map<String, Category>? = null
var tags: List<String>? = null
var trackers: Map<String, List<String>>? = null
Expand Down Expand Up @@ -89,9 +89,9 @@ private object MainDataSerializer : KSerializer<MainData> {

MainData(
serverState = serverState,
torrents = torrents.mapValues { (hash, torrent) ->
torrents = torrents?.mapValues { (hash, torrent) ->
torrent.copy(hash = hash)
}.values.toList(),
}?.values?.toList() ?: emptyList(),
categories = categories?.values?.toList()?.sortedWith(
Comparator { category1, category2 ->
val category1Name = category1.name
Expand Down

0 comments on commit 8b1afdb

Please sign in to comment.