From f858a3eb071679fa2a0e0c49afe01e79ce856259 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Wed, 14 Nov 2018 13:18:48 -0800 Subject: [PATCH] Adds support for syncing Games and GameCollections --- Delta/Database/Model/Human/Game.swift | 25 +++++++++++++++++++ .../Database/Model/Human/GameCollection.swift | 12 +++++++++ External/Harmony | 2 +- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Delta/Database/Model/Human/Game.swift b/Delta/Database/Model/Human/Game.swift index 43448d5..0498bd5 100644 --- a/Delta/Database/Model/Human/Game.swift +++ b/Delta/Database/Model/Human/Game.swift @@ -9,6 +9,7 @@ import Foundation import DeltaCore +import Harmony @objc(Game) public class Game: _Game, GameProtocol @@ -109,3 +110,27 @@ extension Game } } } + +extension Game: Syncable +{ + public static var syncablePrimaryKey: AnyKeyPath { + return \Game.identifier + } + + public var syncableKeys: Set { + return [\Game.artworkURL, \Game.filename, \Game.name, \Game.type] + } + + public var syncableFiles: Set { + let gameFile = File(identifier: "game", fileURL: self.fileURL) + + let artworkURL = DatabaseManager.artworkURL(for: self) + let artworkFile = File(identifier: "artwork", fileURL: artworkURL) + + return [gameFile, artworkFile] + } + + public var syncableRelationships: Set { + return [\Game.gameCollection] + } +} diff --git a/Delta/Database/Model/Human/GameCollection.swift b/Delta/Database/Model/Human/GameCollection.swift index 6e5fca4..c15d5af 100644 --- a/Delta/Database/Model/Human/GameCollection.swift +++ b/Delta/Database/Model/Human/GameCollection.swift @@ -9,6 +9,7 @@ import CoreData import DeltaCore +import Harmony @objc(GameCollection) public class GameCollection: _GameCollection @@ -28,3 +29,14 @@ public class GameCollection: _GameCollection return system } } + +extension GameCollection: Syncable +{ + public static var syncablePrimaryKey: AnyKeyPath { + return \GameCollection.identifier + } + + public var syncableKeys: Set { + return [\GameCollection.index as AnyKeyPath] + } +} diff --git a/External/Harmony b/External/Harmony index b6541ab..47cc6cd 160000 --- a/External/Harmony +++ b/External/Harmony @@ -1 +1 @@ -Subproject commit b6541ab7931e6b8291387d9e5c46e47fc63cfdca +Subproject commit 47cc6cd87cd7e04765b05204a03f83c9eab7c159