From 64e4e52b5ed6bd3878358c66fc2a21050f434629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dr=2E=20Julian-Steffen=20M=C3=BCller?= Date: Thu, 20 May 2021 13:30:47 +0200 Subject: [PATCH] Cleared Library import. Series encoding in Game was not necessary. Encoding through GameSeries object is enough --- Zockerhoehle/CDModel/Game+CoreDataClass.swift | 5 +- Zockerhoehle/Utils/LibraryImport.swift | 79 +------------------ 2 files changed, 2 insertions(+), 82 deletions(-) diff --git a/Zockerhoehle/CDModel/Game+CoreDataClass.swift b/Zockerhoehle/CDModel/Game+CoreDataClass.swift index f97e08c..f932828 100644 --- a/Zockerhoehle/CDModel/Game+CoreDataClass.swift +++ b/Zockerhoehle/CDModel/Game+CoreDataClass.swift @@ -51,14 +51,13 @@ extension Game : Encodable { case isFinished case inWishlist case console - case series case cover_icloud_path case pickupDescription } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - print("UUID: \(self.uuid)") + try container.encode(uuid, forKey: .uuid) try container.encode(name, forKey: .name) try container.encode(notes ?? "", forKey: .notes) @@ -72,8 +71,6 @@ extension Game : Encodable { try container.encode(cover_icloud_path ?? "", forKey: .cover_icloud_path) let consoleUUID : String = console?.uuid.uuidString ?? "" - let gameSeriesUUID : String = series?.uuid.uuidString ?? "" try container.encode(consoleUUID, forKey: .console) - try container.encode(gameSeriesUUID, forKey: .series) } } diff --git a/Zockerhoehle/Utils/LibraryImport.swift b/Zockerhoehle/Utils/LibraryImport.swift index 259012b..b68ed03 100644 --- a/Zockerhoehle/Utils/LibraryImport.swift +++ b/Zockerhoehle/Utils/LibraryImport.swift @@ -201,46 +201,8 @@ struct BHLGame : Decodable { let createdAt : String let pickupDescription : String? let publisher : String? - let console : UUID? - let series : UUID? + let console : UUID let cover_icloud_path : String? - - enum CodingKeys: String, CodingKey { - case uuid - case name - case lentTo - case isDigital - case inWishlist - case isFinished - case notes - case createdAt - case pickupDescription - case publisher - case console - case series - case cover_icloud_path - } - - init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - uuid = try container.decode(UUID.self, forKey: .uuid) - name = try container.decode(String.self, forKey: .name) - lentTo = try container.decode(String?.self, forKey: .lentTo) - isDigital = try container.decode(Bool.self, forKey: .isDigital) - inWishlist = try container.decode(Bool.self, forKey: .inWishlist) - isFinished = try container.decode(Bool.self, forKey: .isFinished) - notes = try container.decode(String?.self, forKey: .notes) - createdAt = try container.decode(String.self, forKey: .createdAt) - pickupDescription = try container.decode(String?.self, forKey: .pickupDescription) - publisher = try container.decode(String?.self, forKey: .publisher) - cover_icloud_path = try container.decode(String?.self, forKey: .cover_icloud_path) - console = try container.decode(UUID?.self, forKey: .console) - do { - series = try container.decode(UUID?.self, forKey: .series) - }catch { - series = .none - } - } } struct BHLAccessory : Decodable { @@ -258,22 +220,6 @@ struct BHLGameSeries : Decodable { let name : String let games : [UUID] let cover_icloud_path : String? - - enum CodingKeys: String, CodingKey { - case uuid - case name - case cover - case games - case cover_icloud_path - } - - init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - uuid = try container.decode(UUID.self, forKey: .uuid) - name = try container.decode(String.self, forKey: .name) - cover_icloud_path = try container.decode(String.self, forKey: .cover_icloud_path) - games = try container.decode([UUID].self, forKey: .games) - } } struct BHLConsole : Decodable { @@ -285,27 +231,4 @@ struct BHLConsole : Decodable { let shortName : String? let accessories : [UUID] let games : [UUID] - - enum CodingKeys: String, CodingKey { - case uuid - case name - case logo_icloud_path - case manufacturer - case releaseDate - case shortName - case accessories - case games - } - - init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - uuid = try container.decode(UUID.self, forKey: .uuid) - name = try container.decode(String.self, forKey: .name) - logo_icloud_path = try container.decode(String.self, forKey: .logo_icloud_path) - manufacturer = try container.decode(String?.self, forKey: .manufacturer) - shortName = try container.decode(String?.self, forKey: .shortName) - accessories = try container.decode([UUID].self, forKey: .accessories) - releaseDate = try container.decode(Date.self, forKey: .releaseDate) - games = try container.decode([UUID].self, forKey: .games) - } }