Always use /api/posts/{POST_ID} to avoid stale-post-slug logic

If the post used to have a post slug, it follows the post until it gets a new post slug. If the post was moved, we end up with a situation where the collection/slug combination is out of sync, and so the API sends back a 404 (FIXME: the Swift package silently fails here).
This commit is contained in:
Angelo Stavrow 2020-10-16 14:01:44 -04:00
parent 404d557cab
commit a2f9d23037
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

View File

@ -171,18 +171,14 @@ extension WriteFreelyModel {
DispatchQueue.main.async {
self.selectedPost = post
}
if let postCollectionAlias = post.collectionAlias,
let postSlug = post.slug {
loggedInClient.getPost(bySlug: postSlug, from: postCollectionAlias, completion: updateFromServerHandler)
} else {
loggedInClient.getPost(byId: postId, completion: updateFromServerHandler)
}
loggedInClient.getPost(byId: postId, completion: updateFromServerHandler)
}
func move(post: WFAPost, from oldCollection: WFACollection?, to newCollection: WFACollection?) {
guard let loggedInClient = client,
let postId = post.postId else { return }
selectedPost = post
post.collectionAlias = newCollection?.alias
loggedInClient.movePost(postId: postId, to: newCollection?.alias, completion: movePostHandler)
}