2019-05-15 01:24:19 +02:00
|
|
|
//
|
|
|
|
// SyncStatus.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 5/14/19.
|
|
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Articles
|
|
|
|
import RSDatabase
|
|
|
|
|
2019-05-15 18:52:56 +02:00
|
|
|
public struct SyncStatus: Hashable, Equatable {
|
2019-05-15 01:24:19 +02:00
|
|
|
|
2020-04-27 23:41:45 +02:00
|
|
|
public enum Key: String {
|
|
|
|
case read = "read"
|
|
|
|
case starred = "starred"
|
|
|
|
case deleted = "deleted"
|
|
|
|
case new = "new"
|
|
|
|
|
|
|
|
public init(_ articleStatusKey: ArticleStatus.Key) {
|
|
|
|
switch articleStatusKey {
|
|
|
|
case .read:
|
|
|
|
self = Self.read
|
|
|
|
case .starred:
|
|
|
|
self = Self.starred
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-05-15 01:24:19 +02:00
|
|
|
public let articleID: String
|
2020-04-27 23:41:45 +02:00
|
|
|
public let key: SyncStatus.Key
|
2019-05-15 01:24:19 +02:00
|
|
|
public let flag: Bool
|
|
|
|
public let selected: Bool
|
|
|
|
|
2020-04-27 23:41:45 +02:00
|
|
|
public init(articleID: String, key: SyncStatus.Key, flag: Bool, selected: Bool = false) {
|
2019-05-15 01:24:19 +02:00
|
|
|
self.articleID = articleID
|
|
|
|
self.key = key
|
|
|
|
self.flag = flag
|
|
|
|
self.selected = selected
|
|
|
|
}
|
|
|
|
|
2019-05-15 18:52:56 +02:00
|
|
|
public func databaseDictionary() -> DatabaseDictionary {
|
2019-05-15 01:24:19 +02:00
|
|
|
return [DatabaseKey.articleID: articleID, DatabaseKey.key: key.rawValue, DatabaseKey.flag: flag, DatabaseKey.selected: selected]
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|