diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist
index e4f812f2..3cd18f0e 100644
--- a/Kiwix-iOS/Info.plist
+++ b/Kiwix-iOS/Info.plist
@@ -49,7 +49,7 @@
CFBundleVersion
- 1.8.3635
+ 1.8.3667
ITSAppUsesNonExemptEncryption
LSRequiresIPhoneOS
diff --git a/Kiwix-iOSWidgets/Bookmarks/Info.plist b/Kiwix-iOSWidgets/Bookmarks/Info.plist
index ab1f1b41..af878bf5 100644
--- a/Kiwix-iOSWidgets/Bookmarks/Info.plist
+++ b/Kiwix-iOSWidgets/Bookmarks/Info.plist
@@ -21,7 +21,7 @@
CFBundleSignature
????
CFBundleVersion
- 1.8.3635
+ 1.8.3682
NSExtension
NSExtensionMainStoryboard
diff --git a/Kiwix.xcodeproj/project.pbxproj b/Kiwix.xcodeproj/project.pbxproj
index e5956492..0a1539eb 100644
--- a/Kiwix.xcodeproj/project.pbxproj
+++ b/Kiwix.xcodeproj/project.pbxproj
@@ -1307,7 +1307,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -1349,7 +1349,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
diff --git a/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
index 32e8dcb3..e2573a59 100644
--- a/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+++ b/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
@@ -13,37 +13,5 @@
stopOnStyle = "0">
-
-
-
-
-
-
-
-
diff --git a/Kiwix/CoreData/Classes/Book.swift b/Kiwix/CoreData/Classes/Book.swift
index f70a4ebd..7f0f3529 100644
--- a/Kiwix/CoreData/Classes/Book.swift
+++ b/Kiwix/CoreData/Classes/Book.swift
@@ -113,17 +113,6 @@ class Book: NSManagedObject {
//
// var record: CKRecord {
// let record = CKRecord(recordType: "Book", recordID: recordID)
-// record["id"] = id as NSString?
-// record["title"] = title as NSString?
-// record["description"] = desc as NSString?
-// record["creator"] = creator as NSString?
-// record["publisher"] = publisher as NSString?
-// record["favicon"] = favIcon as NSData?
-// record["date"] = date as NSDate?
-// record["articleCount"] = articleCount as NSNumber
-// record["mediaCount"] = mediaCount as NSNumber
-// record["fileSize"] = fileSize as NSNumber
-// record["language"] = language?.code as NSString?
// return record
// }
diff --git a/Kiwix/Operations/CloudKit.swift b/Kiwix/Operations/CloudKit.swift
index 804f3778..8313ccc5 100644
--- a/Kiwix/Operations/CloudKit.swift
+++ b/Kiwix/Operations/CloudKit.swift
@@ -23,43 +23,54 @@ class BookmarkSyncOperation: GroupProcedure {
super.init(operations: [zone, book])
}
-
-
}
-//class UpdateArticleOperation: Procedure {
-// let database: CKDatabase
-// let bookID: String
-//
-// init(database: CKDatabase, bookID: String) {
-// self.database = database
-// self.bookID = bookID
-// super.init()
-// }
-//
-// override func execute() {
-// guard let zone = requirement.value else {
-// finish()
-// return
-// }
-//
-// AppDelegate.persistentContainer.performBackgroundTask { (context) in
-// guard let book = Book.fetch(self.bookID, context: context) else {
-// self.finish()
-// return
-// }
-// let fetch = CKFetchRecordsOperation(recordIDs: [bookRecordID])
-// fetch.database = self.database
-// fetch.fetchRecordsCompletionBlock = { records, error in
-// if let book = records?[bookRecordID] {
-//
-// }
-// }
-// }
-//
-//
-// }
-//}
+class FetchArticleRecordOperation: Procedure {
+ let database: CKDatabase
+ let articleURL: URL
+ var recordZone: CKRecordZone?
+ var bookRecord: CKRecord?
+ var articleRecord: CKRecord?
+
+ init(database: CKDatabase, articleURL: URL) {
+ self.database = database
+ self.articleURL = articleURL
+ super.init()
+ }
+
+ override func execute() {
+ guard let zone = recordZone, let bookRecord = bookRecord else {
+ finish()
+ return
+ }
+
+ let recordID = CKRecordID(recordName: articleURL.absoluteString, zoneID: zone.zoneID)
+ let fetch = CKFetchRecordsOperation(recordIDs: [recordID])
+ fetch.database = self.database
+ fetch.fetchRecordsCompletionBlock = { records, error in
+ if let record = records?[recordID] {
+// self.article = record
+
+ self.finish()
+ } else {
+ self.create(recordID: recordID, in: zone)
+ }
+ }
+ CloudKitQueue.shared.add(operations: fetch)
+ }
+
+ private func create(recordID: CKRecordID, in zone: CKRecordZone) {
+ let record = CKRecord(recordType: "Article", recordID: recordID)
+
+ let context = AppDelegate.persistentContainer.newBackgroundContext()
+ }
+
+ private func configure(record: CKRecord, article: Article) {
+
+ }
+}
+
+
class FetchBookRecordOperation: Procedure {
let database: CKDatabase
@@ -78,32 +89,51 @@ class FetchBookRecordOperation: Procedure {
finish()
return
}
- AppDelegate.persistentContainer.performBackgroundTask { (context) in
- let recordID = CKRecordID(recordName: self.bookID, zoneID: zone.zoneID)
- let fetch = CKFetchRecordsOperation(recordIDs: [recordID])
- fetch.database = self.database
- fetch.fetchRecordsCompletionBlock = { records, error in
- if let record = records?[recordID] {
- self.record = record
- // update, or not
- self.finish()
- } else {
- let record = CKRecord(recordType: "Book", recordID: recordID)
- let modify = CKModifyRecordsOperation(recordsToSave: [record], recordIDsToDelete: nil)
- modify.database = self.database
- modify.modifyRecordsCompletionBlock = { saved, _, error in
- if let record = saved?.first {
- self.record = record
- self.finish()
- } else {
- self.finish(withError: error)
- }
- }
- CloudKitQueue.shared.add(operations: modify)
- }
+
+ let recordID = CKRecordID(recordName: self.bookID, zoneID: zone.zoneID)
+ let fetch = CKFetchRecordsOperation(recordIDs: [recordID])
+ fetch.database = self.database
+ fetch.fetchRecordsCompletionBlock = { records, error in
+ if let record = records?[recordID] {
+ self.record = record
+ self.finish()
+ } else {
+ self.create(recordID: recordID, in: zone)
}
- CloudKitQueue.shared.add(operations: fetch)
}
+ CloudKitQueue.shared.add(operations: fetch)
+ }
+
+ private func create(recordID: CKRecordID, in zone: CKRecordZone) {
+ let record = CKRecord(recordType: "Book", recordID: recordID)
+
+ let context = AppDelegate.persistentContainer.newBackgroundContext()
+ context.performAndWait {
+ guard let book = Book.fetch(self.bookID, context: context) else {return}
+ record["id"] = book.id as NSString?
+ record["title"] = book.title as NSString?
+ record["description"] = book.desc as NSString?
+ record["creator"] = book.creator as NSString?
+ record["publisher"] = book.publisher as NSString?
+ record["favicon"] = book.favIcon as NSData?
+ record["date"] = book.date as NSDate?
+ record["articleCount"] = book.articleCount as NSNumber
+ record["mediaCount"] = book.mediaCount as NSNumber
+ record["fileSize"] = book.fileSize as NSNumber
+ record["language"] = book.language?.code as NSString?
+ }
+
+ let modify = CKModifyRecordsOperation(recordsToSave: [record], recordIDsToDelete: nil)
+ modify.database = self.database
+ modify.modifyRecordsCompletionBlock = { saved, _, error in
+ if let record = saved?.first {
+ self.record = record
+ self.finish()
+ } else {
+ self.finish(withError: error)
+ }
+ }
+ CloudKitQueue.shared.add(operations: modify)
}
}
diff --git a/Kiwix/Operations/RefreshLibrary.swift b/Kiwix/Operations/RefreshLibrary.swift
index ef6ebc5d..942f18ff 100644
--- a/Kiwix/Operations/RefreshLibrary.swift
+++ b/Kiwix/Operations/RefreshLibrary.swift
@@ -36,9 +36,8 @@ fileprivate class Retrieve: NetworkDataProcedure {
}
}
-fileprivate class Process: Procedure, ResultInjection, XMLParserDelegate {
- var requirement: PendingValue> = .pending
- fileprivate(set) var result: PendingValue = .void
+fileprivate class Process: Procedure, InputProcedure, XMLParserDelegate {
+ var input: Pending> = .pending
private let context: NSManagedObjectContext
private var storeBookIDs = Set()
@@ -54,7 +53,7 @@ fileprivate class Process: Procedure, ResultInjection, XMLParserDelegate {
}
override func execute() {
- guard let data = requirement.value?.payload else {
+ guard let data = input.value?.payload else {
finish(withError: ProcedureKitError.requirementNotSatisfied())
return
}
diff --git a/Podfile b/Podfile
index c6727e79..03c26f36 100644
--- a/Podfile
+++ b/Podfile
@@ -8,8 +8,9 @@ platform :ios, '10.0'
pod 'DZNEmptyDataSet'
pod 'MBProgressHUD', '~> 1.0.0'
pod 'SwiftyUserDefaults'
-pod 'ProcedureKit', :git => 'https://github.com/ProcedureKit/ProcedureKit.git', :branch => 'release/4.0.0.beta.4'
-pod 'ProcedureKit/Network', :git => 'https://github.com/ProcedureKit/ProcedureKit.git', :branch => 'release/4.0.0.beta.4'
-pod 'ProcedureKit/Mobile', :git => 'https://github.com/ProcedureKit/ProcedureKit.git', :branch => 'release/4.0.0.beta.4'
+pod 'ProcedureKit', :git => 'https://github.com/ProcedureKit/ProcedureKit.git', :branch => 'release/4.0.0.beta.6'
+pod 'ProcedureKit/Cloud', :git => 'https://github.com/ProcedureKit/ProcedureKit.git', :branch => 'release/4.0.0.beta.6'
+pod 'ProcedureKit/Network', :git => 'https://github.com/ProcedureKit/ProcedureKit.git', :branch => 'release/4.0.0.beta.6'
+pod 'ProcedureKit/Mobile', :git => 'https://github.com/ProcedureKit/ProcedureKit.git', :branch => 'release/4.0.0.beta.6'
end
\ No newline at end of file
diff --git a/Podfile.lock b/Podfile.lock
index 74c77f0f..9b8c335a 100644
--- a/Podfile.lock
+++ b/Podfile.lock
@@ -1,39 +1,42 @@
PODS:
- DZNEmptyDataSet (1.8.1)
- MBProgressHUD (1.0.0)
- - ProcedureKit (4.0.0.beta.4):
- - ProcedureKit/Standard (= 4.0.0.beta.4)
- - ProcedureKit/Mobile (4.0.0.beta.4):
+ - ProcedureKit (4.0.0.beta.5):
+ - ProcedureKit/Standard (= 4.0.0.beta.5)
+ - ProcedureKit/Cloud (4.0.0.beta.5):
- ProcedureKit/Standard
- - ProcedureKit/Network (4.0.0.beta.4):
+ - ProcedureKit/Mobile (4.0.0.beta.5):
- ProcedureKit/Standard
- - ProcedureKit/Standard (4.0.0.beta.4)
+ - ProcedureKit/Network (4.0.0.beta.5):
+ - ProcedureKit/Standard
+ - ProcedureKit/Standard (4.0.0.beta.5)
- SwiftyUserDefaults (3.0.0)
DEPENDENCIES:
- DZNEmptyDataSet
- MBProgressHUD (~> 1.0.0)
- - ProcedureKit (from `https://github.com/ProcedureKit/ProcedureKit.git`, branch `release/4.0.0.beta.4`)
- - ProcedureKit/Mobile (from `https://github.com/ProcedureKit/ProcedureKit.git`, branch `release/4.0.0.beta.4`)
- - ProcedureKit/Network (from `https://github.com/ProcedureKit/ProcedureKit.git`, branch `release/4.0.0.beta.4`)
+ - ProcedureKit (from `https://github.com/ProcedureKit/ProcedureKit.git`, branch `release/4.0.0.beta.5`)
+ - ProcedureKit/Cloud (from `https://github.com/ProcedureKit/ProcedureKit.git`, branch `release/4.0.0.beta.5`)
+ - ProcedureKit/Mobile (from `https://github.com/ProcedureKit/ProcedureKit.git`, branch `release/4.0.0.beta.5`)
+ - ProcedureKit/Network (from `https://github.com/ProcedureKit/ProcedureKit.git`, branch `release/4.0.0.beta.5`)
- SwiftyUserDefaults
EXTERNAL SOURCES:
ProcedureKit:
- :branch: release/4.0.0.beta.4
+ :branch: release/4.0.0.beta.5
:git: https://github.com/ProcedureKit/ProcedureKit.git
CHECKOUT OPTIONS:
ProcedureKit:
- :commit: be78bf8bea9928ad24bf6b83bc7b5cfab11b5874
+ :commit: e0d3e52f5052b1004f07e7d595022fc54d6e5336
:git: https://github.com/ProcedureKit/ProcedureKit.git
SPEC CHECKSUMS:
DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7
MBProgressHUD: 4890f671c94e8a0f3cf959aa731e9de2f036d71a
- ProcedureKit: 9160071e54e3885fad82f72acc8474366c764f5b
+ ProcedureKit: 71bf6e0265e406f96bdd4f767ef47c78a2c18ce3
SwiftyUserDefaults: 0f1d45fc3aafb9064dac661e367f8f83fe21a4b4
-PODFILE CHECKSUM: 43f01172d4e3b5f4e0ad68f2a251cc23a4bb0f5a
+PODFILE CHECKSUM: abf95d1f5f7b05e5b977e17595badfbae0a1b862
COCOAPODS: 1.0.1