Skip to content

Commit bbeeb96

Browse files
author
Clément Le Provost
committed
Upgrade to Offline Core 1.0
1 parent 580d8ae commit bbeeb96

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

AlgoliaSearch-Offline-Swift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
1010

1111
s.ios.deployment_target = '8.0'
1212

13-
s.dependency 'AlgoliaSearchOfflineCore-iOS', '~> 0.2'
13+
s.dependency 'AlgoliaSearchOfflineCore-iOS', '~> 1.0'
1414

1515
# Activate Core-dependent code.
1616
# WARNING: Specifying the preprocessor macro is not enough; it must be added to Swift flags as well.

Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
use_frameworks!
44

55
target "AlgoliaSearch-Offline-iOS" do
6-
pod 'AlgoliaSearchOfflineCore-iOS', '~> 0.2'
6+
pod 'AlgoliaSearchOfflineCore-iOS', '~> 1.0'
77
end

Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
PODS:
2-
- AlgoliaSearchOfflineCore-iOS (0.2.1)
2+
- AlgoliaSearchOfflineCore-iOS (1.0)
33

44
DEPENDENCIES:
5-
- AlgoliaSearchOfflineCore-iOS (~> 0.2)
5+
- AlgoliaSearchOfflineCore-iOS (~> 1.0)
66

77
SPEC CHECKSUMS:
8-
AlgoliaSearchOfflineCore-iOS: 37d76ccada33254b6bad6529fb3c0d4ddcd70e94
8+
AlgoliaSearchOfflineCore-iOS: b3eb50575f79c91396bc1aacc529fd3d8954f7ae
99

10-
PODFILE CHECKSUM: 70f8e7e3ce3a1a02df550109e528d546a9555548
10+
PODFILE CHECKSUM: 1b63159de2f97dc9b071134b68eb9eab928c59e2
1111

1212
COCOAPODS: 1.1.0.rc.2

Source/Offline/MirroredIndex.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ import Foundation
114114
}
115115

116116
/// The local index mirroring this remote index (lazy instantiated, only if mirroring is activated).
117-
lazy var localIndex: ASLocalIndex = ASLocalIndex(dataDir: self.offlineClient.rootDataDir, appID: self.client.appID, indexName: self.name)
117+
lazy var localIndex: LocalIndex = LocalIndex(dataDir: self.offlineClient.rootDataDir, appID: self.client.appID, indexName: self.name)
118118

119119
/// The mirrored index settings.
120120
let mirrorSettings = MirrorSettings()
@@ -338,7 +338,7 @@ import Foundation
338338
// Task: build the index using the downloaded files.
339339
buildIndexOperation = BlockOperation() {
340340
if self.syncError == nil {
341-
let status = self.localIndex.build(fromSettingsFile: self.settingsFilePath!, objectFiles: self.objectsFilePaths!, clearIndex: true)
341+
let status = self.localIndex.build(settingsFile: self.settingsFilePath!, objectFiles: self.objectsFilePaths!, clearIndex: true, deletedObjectIDs: nil)
342342
if status != 200 {
343343
self.syncError = HTTPError(statusCode: Int(status))
344344
} else {
@@ -670,7 +670,7 @@ import Foundation
670670
assert(!Thread.isMainThread) // make sure it's run in the background
671671

672672
let searchResults = localIndex.search(query.build())
673-
return OfflineClient.parseSearchResults(searchResults: searchResults)
673+
return OfflineClient.parseResponse(searchResults)
674674
}
675675

676676
// MARK: Multiple queries
@@ -870,6 +870,6 @@ import Foundation
870870
assert(!Thread.isMainThread) // make sure it's run in the background
871871

872872
let searchResults = localIndex.browse(query.build())
873-
return OfflineClient.parseSearchResults(searchResults: searchResults)
873+
return OfflineClient.parseResponse(searchResults)
874874
}
875875
}

Source/Offline/OfflineClient.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import Foundation
5050
userAgents.append(LibraryVersion(name: "AlgoliaSearchOfflineCore-iOS", version: sdk.versionString))
5151
}
5252

53-
var sdk: ASSdk = ASSdk.shared()
53+
var sdk: Sdk = Sdk.shared
5454

5555
/// Path to directory where the local data is stored.
5656
/// Defaults to an `algolia` sub-directory inside the `Library/Application Support` directory.
@@ -100,7 +100,7 @@ import Foundation
100100
}
101101

102102
// Init the SDK.
103-
sdk.initWithLicenseData(licenseKey)
103+
sdk.initialize(licenseKey: licenseKey)
104104
// NOTE: Errors reported by the core itself.
105105
}
106106

@@ -126,14 +126,14 @@ import Foundation
126126
/// - parameter searchResults: Search results to parse.
127127
/// - returns: A (content, error) pair that can be passed to a `CompletionHandler`.
128128
///
129-
internal static func parseSearchResults(searchResults: ASSearchResults) -> (content: JSONObject?, error: Error?) {
129+
internal static func parseResponse(_ response: Response) -> (content: JSONObject?, error: Error?) {
130130
var content: JSONObject?
131131
var error: Error?
132-
let statusCode = Int(searchResults.statusCode)
132+
let statusCode = Int(response.statusCode)
133133
if statusCode == StatusCode.ok.rawValue {
134-
assert(searchResults.data != nil)
134+
assert(response.data != nil)
135135
do {
136-
let json = try JSONSerialization.jsonObject(with: searchResults.data!, options: [])
136+
let json = try JSONSerialization.jsonObject(with: response.data!, options: [])
137137
if json is JSONObject {
138138
content = (json as! JSONObject)
139139
// NOTE: Origin tagging performed by the SDK.

0 commit comments

Comments
 (0)