Skip to content

Commit 609a330

Browse files
Merge pull request #93 from writeas/show-post-in-right-collection-after-update
Keep cached post's collectionAlias from being set to nil by fetched post
2 parents b0d440e + 50c521e commit 609a330

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Shared/Models/WriteFreelyModel.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ private extension WriteFreelyModel {
324324
}
325325

326326
func publishHandler(result: Result<WFPost, Error>) {
327+
// ⚠️ NOTE:
328+
// The API does not return a collection alias, so we take care not to overwrite the
329+
// cached post's collection alias with the 'nil' value from the fetched post.
330+
// See: https://github.com/writeas/writefreely-swift/issues/20
327331
do {
328332
let fetchedPost = try result.get()
329333
let foundPostIndex = posts.userPosts.firstIndex(where: {
@@ -333,7 +337,6 @@ private extension WriteFreelyModel {
333337
let cachedPost = self.posts.userPosts[index]
334338
cachedPost.appearance = fetchedPost.appearance
335339
cachedPost.body = fetchedPost.body
336-
cachedPost.collectionAlias = fetchedPost.collectionAlias
337340
cachedPost.createdDate = fetchedPost.createdDate
338341
cachedPost.language = fetchedPost.language
339342
cachedPost.postId = fetchedPost.postId

0 commit comments

Comments
 (0)