From 38423a14cab94c9e38926502eb54cb111ce21119 Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Fri, 1 Dec 2023 09:52:41 +0100 Subject: [PATCH] Preserve isSensitiveToggled state when interacting with posts (IOS-176) --- Mastodon/Protocol/Provider/DataSourceFacade+Bookmark.swift | 5 ++++- Mastodon/Protocol/Provider/DataSourceFacade+Favorite.swift | 7 +++++-- Mastodon/Protocol/Provider/DataSourceFacade+Reblog.swift | 7 +++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Mastodon/Protocol/Provider/DataSourceFacade+Bookmark.swift b/Mastodon/Protocol/Provider/DataSourceFacade+Bookmark.swift index 8612254f3..5e342108b 100644 --- a/Mastodon/Protocol/Provider/DataSourceFacade+Bookmark.swift +++ b/Mastodon/Protocol/Provider/DataSourceFacade+Bookmark.swift @@ -24,6 +24,9 @@ extension DataSourceFacade { authenticationBox: provider.authContext.mastodonAuthenticationBox ).value - provider.update(status: .fromEntity(updatedStatus)) + let newStatus: MastodonStatus = .fromEntity(updatedStatus) + newStatus.isSensitiveToggled = status.isSensitiveToggled + + provider.update(status: newStatus) } } diff --git a/Mastodon/Protocol/Provider/DataSourceFacade+Favorite.swift b/Mastodon/Protocol/Provider/DataSourceFacade+Favorite.swift index e2a4397e5..8e96e28fa 100644 --- a/Mastodon/Protocol/Provider/DataSourceFacade+Favorite.swift +++ b/Mastodon/Protocol/Provider/DataSourceFacade+Favorite.swift @@ -18,11 +18,14 @@ extension DataSourceFacade { let selectionFeedbackGenerator = await UISelectionFeedbackGenerator() await selectionFeedbackGenerator.selectionChanged() - let newStatus = try await provider.context.apiService.favorite( + let updatedStatus = try await provider.context.apiService.favorite( status: status, authenticationBox: provider.authContext.mastodonAuthenticationBox ).value - provider.update(status: .fromEntity(newStatus)) + let newStatus: MastodonStatus = .fromEntity(updatedStatus) + newStatus.isSensitiveToggled = status.isSensitiveToggled + + provider.update(status: newStatus) } } diff --git a/Mastodon/Protocol/Provider/DataSourceFacade+Reblog.swift b/Mastodon/Protocol/Provider/DataSourceFacade+Reblog.swift index 1d445697e..75f0f63aa 100644 --- a/Mastodon/Protocol/Provider/DataSourceFacade+Reblog.swift +++ b/Mastodon/Protocol/Provider/DataSourceFacade+Reblog.swift @@ -18,11 +18,14 @@ extension DataSourceFacade { let selectionFeedbackGenerator = await UISelectionFeedbackGenerator() await selectionFeedbackGenerator.selectionChanged() - let newStatus = try await provider.context.apiService.reblog( + let updatedStatus = try await provider.context.apiService.reblog( status: status, authenticationBox: provider.authContext.mastodonAuthenticationBox ).value - provider.update(status: .fromEntity(newStatus)) + let newStatus: MastodonStatus = .fromEntity(updatedStatus) + newStatus.isSensitiveToggled = status.isSensitiveToggled + + provider.update(status: newStatus) } }