From ba3f44b287f6536553c389ed055cc90bbe9a957b Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Sat, 10 Jun 2023 07:33:44 -0400 Subject: [PATCH] Update collection alias when refreshing moved posts (#250) --- CHANGELOG.md | 1 + .../WriteFreelyModel+APIHandlers.swift | 11 +++++++++++ .../project.pbxproj | 16 ++++++++-------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9540fb2..67e90ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [Mac] Fixed some build warnings in the project. - [Mac] Bumped WriteFreely package to v0.3.6 to handle decoding of fractional seconds in dates. - [Mac] Fixed a bug that prevented a remotely-edited post from updating until you navigated away and back. +- [iOS, Mac] Fixed a bug where posts moved from one blog to another on a different client didn't update in the app. ## [1.0.15-ios] - 2022-01-15 diff --git a/Shared/Extensions/WriteFreelyModel+APIHandlers.swift b/Shared/Extensions/WriteFreelyModel+APIHandlers.swift index a7e9918..5843328 100644 --- a/Shared/Extensions/WriteFreelyModel+APIHandlers.swift +++ b/Shared/Extensions/WriteFreelyModel+APIHandlers.swift @@ -113,6 +113,7 @@ extension WriteFreelyModel { } } + // swiftlint:disable function_body_length func fetchUserPostsHandler(result: Result<[WFPost], Error>) { // We're done with the network request. DispatchQueue.main.async { @@ -136,6 +137,15 @@ extension WriteFreelyModel { "Error updating post: could not determine which copy of post is newer." ) } + if managedPost.collectionAlias != fetchedPost.collectionAlias { + // The post has been moved so we update the managed post's collectionAlias property. + DispatchQueue.main.async { + if self.selectedPost == managedPost { + self.selectedPost = nil + } + managedPost.collectionAlias = fetchedPost.collectionAlias + } + } postsToDelete.removeAll(where: { $0.postId == fetchedPost.postId }) } } else { @@ -161,6 +171,7 @@ extension WriteFreelyModel { self.currentError = LocalStoreError.couldNotFetchPosts("cached") } } + // swiftlint:enable function_body_length func publishHandler(result: Result) { // We're done with the network request. diff --git a/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj b/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj index 4d04e3a..ea527e2 100644 --- a/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj +++ b/WriteFreely-MultiPlatform.xcodeproj/project.pbxproj @@ -1063,7 +1063,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 700; + CURRENT_PROJECT_VERSION = 701; DEVELOPMENT_TEAM = TPPAB4YBA6; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "ActionExtension-iOS/Info.plist"; @@ -1075,7 +1075,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.15; + MARKETING_VERSION = 1.0.16; PRODUCT_BUNDLE_IDENTIFIER = "com.abunchtell.WriteFreely-MultiPlatform.ActionExtension-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -1094,7 +1094,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CODE_SIGN_ENTITLEMENTS = "ActionExtension-iOS/ActionExtension-iOS.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 700; + CURRENT_PROJECT_VERSION = 701; DEVELOPMENT_TEAM = TPPAB4YBA6; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "ActionExtension-iOS/Info.plist"; @@ -1106,7 +1106,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.15; + MARKETING_VERSION = 1.0.16; PRODUCT_BUNDLE_IDENTIFIER = "com.abunchtell.WriteFreely-MultiPlatform.ActionExtension-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -1237,7 +1237,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 700; + CURRENT_PROJECT_VERSION = 701; DEVELOPMENT_TEAM = TPPAB4YBA6; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = iOS/Info.plist; @@ -1246,7 +1246,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.15; + MARKETING_VERSION = 1.0.16; PRODUCT_BUNDLE_IDENTIFIER = "com.abunchtell.WriteFreely-MultiPlatform"; PRODUCT_NAME = "WriteFreely-MultiPlatform"; SDKROOT = iphoneos; @@ -1263,7 +1263,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = "WriteFreely-MultiPlatform (iOS).entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 700; + CURRENT_PROJECT_VERSION = 701; DEVELOPMENT_TEAM = TPPAB4YBA6; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = iOS/Info.plist; @@ -1272,7 +1272,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.15; + MARKETING_VERSION = 1.0.16; PRODUCT_BUNDLE_IDENTIFIER = "com.abunchtell.WriteFreely-MultiPlatform"; PRODUCT_NAME = "WriteFreely-MultiPlatform"; SDKROOT = iphoneos;