Skip to content

Commit

Permalink
Merge pull request #94 from contentful/bugfix/swapped-sync-spaces
Browse files Browse the repository at this point in the history
Always send diffs to persistence integration after a sync page fetched
  • Loading branch information
loudmouth committed Jul 17, 2017
2 parents b444c9c + 0182ce4 commit 72e8fe3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env
@@ -1 +1 @@
CONTENTFUL_SDK_VERSION=0.7.2
CONTENTFUL_SDK_VERSION=0.7.3
2 changes: 1 addition & 1 deletion .envrc
@@ -1 +1 @@
export CONTENFUL_SDK_VERSION=0.7.2
export CONTENFUL_SDK_VERSION=0.7.3
10 changes: 9 additions & 1 deletion CHANGELOG.md
Expand Up @@ -10,14 +10,22 @@ This project adheres to [Semantic Versioning](http://semver.org/) starting from
## Table of contents

#### 0.x Releases
- `0.7.x` Releases - [0.7.0](#070) | [0.7.1](#071) | [0.7.2](#072)
- `0.7.x` Releases - [0.7.0](#070) | [0.7.1](#071) | [0.7.2](#072)) | [0.7.3](#073)
- `0.6.x` Releases - [0.6.0](#060) | [0.6.1](#061)
- `0.5.x` Releases - [0.5.0](#050)
- `0.4.x` Releases - [0.4.0](#040) | [0.4.1](#041)
- `0.3.x` Releases - [0.3.0](#030) | [0.3.1](#031)

---

## [`0.7.3`](https://github.com/contentful/contentful.swift/releases/tag/0.7.3)
Released on 2017-07-17

#### Fixed
- Delta messages from `/sync` endpoint were only being sent for last page when a sync was returned on multiple pages.

---

## [`0.7.2`](https://github.com/contentful/contentful.swift/releases/tag/0.7.2)
Released on 2017-07-12

Expand Down
2 changes: 1 addition & 1 deletion Config.xcconfig
@@ -1 +1 @@
CONTENTFUL_SDK_VERSION=0.7.2
CONTENTFUL_SDK_VERSION=0.7.3
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -80,7 +80,7 @@ pod 'Contentful'
You can specify a specific version of Contentful depending on your needs. To learn more about operators for dependency versioning within a Podfile, see the [CocoaPods doc on the Podfile][7].

```ruby
pod 'Contentful', '~> 0.7.2'
pod 'Contentful', '~> 0.7.3'
```

Note that for Swift 2.3 support (contentful.swift `v0.2.3`) you will need to add a post-install script to your Podfile if installing with Cocoapods:
Expand All @@ -100,7 +100,7 @@ end
You can also use [Carthage][8] for integration by adding the following to your `Cartfile`:

```
github "contentful/contentful.swift" ~> 0.7.2
github "contentful/contentful.swift" ~> 0.7.3
```

## License
Expand Down
9 changes: 6 additions & 3 deletions Sources/Client.swift
Expand Up @@ -694,7 +694,7 @@ extension Client {

// Send messages to persistence layer about the diffs (pre-merge state).
// Must send messages for the first sync space that was originally passed in.
self.sendDiffMessagesToPersistenceIntegration(for: syncSpace, resolvingLinksWith: newSyncSpace)
self.sendDiffMessagesToPersistenceIntegration(for: newSyncSpace, resolvingLinksWith: syncSpace)
syncSpace.updateWithDiffs(from: newSyncSpace)

completion(Result.success(syncSpace))
Expand Down Expand Up @@ -743,13 +743,16 @@ extension Client {
fileprivate func sync(matching: [String: Any] = [:], completion: @escaping ResultsHandler<SyncSpace>) -> URLSessionDataTask? {

return fetch(url: URL(forComponent: "sync", parameters: matching)) { (result: Result<SyncSpace>) in

if let syncSpace = result.value {

// Whenever we get a page, send the diffs to the persistence integration.
self.sendDiffMessagesToPersistenceIntegration(for: syncSpace, resolvingLinksWith: nil)

if syncSpace.hasMorePages == true { // multipage sync.
self.nextSync(for: syncSpace, matching: matching, completion: completion)
} else {
// Either a single page sync, or, in the recursive case of a multipage sync, the last page.
self.sendDiffMessagesToPersistenceIntegration(for: syncSpace, resolvingLinksWith: nil)
// Merge all the sync spaces together.
completion(Result.success(syncSpace))
}
} else {
Expand Down

0 comments on commit 72e8fe3

Please sign in to comment.