Changed GameSeries Views to new core data swiftui best practices. Missing import/export yet. Deleted old store files and cleaned up some comments
This commit is contained in:
@@ -48,7 +48,6 @@ class LibraryImport {
|
||||
}
|
||||
|
||||
private func resetDatabase() {
|
||||
print(GameSeriesStore().gameSeries)
|
||||
CDManager.shared.viewContext.reset()
|
||||
CDManager.shared.viewContext.performAndWait {
|
||||
let deleteRequests =
|
||||
@@ -69,7 +68,6 @@ class LibraryImport {
|
||||
print("LibraryImport::resetDatabase - Reset of Database failes!")
|
||||
}
|
||||
}
|
||||
print(GameSeriesStore().gameSeries)
|
||||
}
|
||||
|
||||
private func makeCDGame(from game: BHLGame, _ gameDict: inout [UUID : Game], _ cdConsole: Console) {
|
||||
@@ -117,11 +115,7 @@ class LibraryImport {
|
||||
private func makeCDGameSeries(from gameSeries: BHLGameSeries, _ gameDict: inout [UUID : Game]) {
|
||||
let cdGameSeries = GameSeries(context: CDManager.shared.viewContext)
|
||||
cdGameSeries.name = gameSeries.name
|
||||
|
||||
let cdCover = GameSeriesCover(context: CDManager.shared.viewContext)
|
||||
cdCover.image = gameSeries.cover
|
||||
cdCover.gameSeries = cdGameSeries
|
||||
cdGameSeries.cover = cdCover
|
||||
cdGameSeries.cover_icloud_path = gameSeries.cover_icloud_path
|
||||
|
||||
for uuid in gameSeries.games {
|
||||
if let game = gameDict[uuid] {
|
||||
@@ -248,28 +242,23 @@ struct BHLAccessory : Decodable {
|
||||
struct BHLGameSeries : Decodable {
|
||||
let uuid : UUID
|
||||
let name : String
|
||||
let cover : UIImage?
|
||||
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)
|
||||
|
||||
if let coverBase64 = try container.decode(String?.self, forKey: .cover),
|
||||
let coverData = Data(base64Encoded: coverBase64) {
|
||||
cover = UIImage(data: coverData)
|
||||
}else {
|
||||
cover = .none
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user