Skip to content

Commit

Permalink
Merge pull request #310 from contentful/feature/fix-syncing-concrete-…
Browse files Browse the repository at this point in the history
…type

Send only SyncSpace parameters when accessing next page of data to be synced
  • Loading branch information
makinwab committed Jul 7, 2020
2 parents 1e25cdc + db95770 commit 16afcd2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CONTENTFUL_SDK_VERSION=5.1.0
CONTENTFUL_SDK_VERSION=5.1.1
2 changes: 1 addition & 1 deletion Config.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CONTENTFUL_SDK_VERSION=5.1.0
CONTENTFUL_SDK_VERSION=5.1.1
11 changes: 9 additions & 2 deletions Sources/Contentful/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,15 @@ extension Client {
completion(.failure(SDKError.previewAPIDoesNotSupportSync))
return nil
}

let parameters = syncableTypes.parameters + syncSpace.parameters

// Send only sync space parameters when accessing another page.
let parameters: [String: String]
if syncSpace.hasMorePages {
parameters = syncSpace.parameters
} else {
parameters = syncableTypes.parameters + syncSpace.parameters
}

return fetch(url: url(endpoint: .sync, parameters: parameters)) { (result: Result<SyncSpace, Error>) in
switch result {
case .success(let newSyncSpace):
Expand Down
1 change: 1 addition & 0 deletions Sources/Contentful/SyncSpace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public final class SyncSpace: Decodable {
}

syncToken = syncSpace.syncToken
hasMorePages = syncSpace.hasMorePages
}

internal func cache(resources: [Resource]) {
Expand Down

0 comments on commit 16afcd2

Please sign in to comment.