Skip to content

Commit c6f7aeb

Browse files
Merge pull request #87 from writeas/fix-crash-on-share-button
Fix crash on share button
2 parents 7f9ba52 + a34a70f commit c6f7aeb

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [1.0.0a1]
8+
## [Unreleased]
9+
10+
### Fixed
11+
12+
- Fixed a link in the change log; added date to the 1.0.0a1 release.
13+
14+
## [1.0.0a1] - 2020-09-30
915

1016
### Added
1117

@@ -86,7 +92,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8692
- Contributing guide
8793
- This changelog
8894

89-
[1.0.0a1]: https://github.com/writeas/writefreely-swiftui-multiplatform/compare/v1.0.0a1...0.1.1
95+
[Unreleased]: https://github.com/writeas/writefreely-swiftui-multiplatform/compare/v1.0.0a1...HEAD
96+
[1.0.0a1]: https://github.com/writeas/writefreely-swiftui-multiplatform/compare/v0.1.1...v1.0.0a1
9097
[0.1.1]: https://github.com/writeas/writefreely-swiftui-multiplatform/compare/v0.1.0...v0.1.1
9198
[0.1.0]: https://github.com/writeas/writefreely-swiftui-multiplatform/compare/v0.0.2...v0.1.0
9299
[0.0.2]: https://github.com/writeas/writefreely-swiftui-multiplatform/compare/v0.0.1...v0.0.2

WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
<key>WriteFreely-MultiPlatform (iOS).xcscheme_^#shared#^_</key>
88
<dict>
99
<key>orderHint</key>
10-
<integer>1</integer>
10+
<integer>0</integer>
1111
</dict>
1212
<key>WriteFreely-MultiPlatform (macOS).xcscheme_^#shared#^_</key>
1313
<dict>
1414
<key>orderHint</key>
15-
<integer>0</integer>
15+
<integer>1</integer>
1616
</dict>
1717
</dict>
1818
</dict>

iOS/PostEditor/PostEditorView.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,20 @@ struct PostEditorView: View {
190190
}
191191

192192
private func sharePost() {
193-
guard let urlString = model.selectedPost?.slug != nil ?
194-
"\(model.account.server)/\((model.selectedPost?.collectionAlias)!)/\((model.selectedPost?.slug)!)" :
195-
"\(model.account.server)/\((model.selectedPost?.postId)!)" else { return }
193+
// If the post doesn't have a post ID, it isn't published, and therefore can't be shared, so return early.
194+
guard let postId = post.postId else { return }
195+
196+
var urlString: String
197+
198+
if let postSlug = post.slug,
199+
let postCollectionAlias = post.collectionAlias {
200+
// This post is in a collection, so share the URL as server/collectionAlias/postSlug.
201+
urlString = "\(model.account.server)/\((postCollectionAlias))/\((postSlug))"
202+
} else {
203+
// This is a draft post, so share the URL as server/postID
204+
urlString = "\(model.account.server)/\((postId))"
205+
}
206+
196207
guard let data = URL(string: urlString) else { return }
197208

198209
let activityView = UIActivityViewController(activityItems: [data], applicationActivities: nil)

0 commit comments

Comments
 (0)