Parcourir la source

Merge pull request #180 from writeas/use-collection-url-for-share-sheet

Use collection.url rather than server + collection alias in share sheets
tags/v1.0.5-ios
Angelo Stavrow il y a 3 ans
committed by GitHub
Parent
révision
94c875bc65
Aucune clé connue n'a été trouvée dans la base pour cette signature ID de la clé GPG: 4AEE18F83AFDEB23
2 fichiers modifiés avec 19 ajouts et 6 suppressions
  1. +5
    -3
      iOS/PostEditor/PostEditorView.swift
  2. +14
    -3
      macOS/Navigation/ActivePostToolbarView.swift

+ 5
- 3
iOS/PostEditor/PostEditorView.swift Voir le fichier

@@ -207,11 +207,13 @@ struct PostEditorView: View {

if let postSlug = post.slug,
let postCollectionAlias = post.collectionAlias {
// This post is in a collection, so share the URL as server/collectionAlias/postSlug.
urlString = "\(model.account.server)/\((postCollectionAlias))/\((postSlug))"
// This post is in a collection, so share the URL as baseURL/postSlug.
let urls = collections.filter { $0.alias == postCollectionAlias }
let baseURL = urls.first?.url ?? "\(model.account.server)/\(postCollectionAlias)/"
urlString = "\(baseURL)\(postSlug)"
} else {
// This is a draft post, so share the URL as server/postID
urlString = "\(model.account.server)/\((postId))"
urlString = "\(model.account.server)/\(postId)"
}

guard let data = URL(string: urlString) else { return }


+ 14
- 3
macOS/Navigation/ActivePostToolbarView.swift Voir le fichier

@@ -106,9 +106,20 @@ struct ActivePostToolbarView: View {

private func createPostUrl() -> [Any] {
guard let postId = model.selectedPost?.postId else { return [] }
guard let urlString = model.selectedPost?.slug != nil ?
"\(model.account.server)/\((model.selectedPost?.collectionAlias)!)/\((model.selectedPost?.slug)!)" :
"\(model.account.server)/\((postId))" else { return [] }

var urlString: String

if let postSlug = model.selectedPost?.slug,
let postCollectionAlias = model.selectedPost?.collectionAlias {
// This post is in a collection, so share the URL as baseURL/postSlug
let urls = collections.filter { $0.alias == postCollectionAlias }
let baseURL = urls.first?.url ?? "\(model.account.server)/\(postCollectionAlias)/"
urlString = "\(baseURL)\(postSlug)"
} else {
// This is a draft post, sho share the URL as server/postID
urlString = "\(model.account.server)/\(postId)"
}

guard let data = URL(string: urlString) else { return [] }
return [data as NSURL]
}


Chargement…
Annuler
Enregistrer