mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
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:
parent
404d557cab
commit
a2f9d23037
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user